Mysql – Flush Host Connection Blocked, but some connections allowed

connectivityMySQLmysql-5.6percona

We are running Percona MySQL 5.6.30. We've had an issue where a PHP script on a different host was reporting an issue connecting to the database:

Database may be down : SQLSTATE[HY000] [1129] Host 'x.x.x.101' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

We did the flush hosts, and it resolved the issue.

When we went back to check the Percona Audit Logs for the same time, we see a number of connections at that same time, from that same host ('x.x.x.101').

I'm trying to understand how a host could be blocked, and not blocked, at the same time. 🙂 Any ideas?

Best Answer

That host was blocked because there have been too many connection errors. The maximum number of errors before a host is blocked is represented by the max_connection_errors variable. Before reaching that number of errors, the host was not blocked.

The FLUSH HOSTS commands (or mysqladmin flush-hosts) empties the host cache. After that, the host can connect again and the errors counter is reset.