Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mysql): treat host-blocked (error 1129) as non-retryable (#63705)

Tom Owersa99b901db417
diff --git a/posthog/temporal/data_imports/sources/mysql/source.py b/posthog/temporal/data_imports/sources/mysql/source.py
index 4fd24f0b758d..5618d79da901 100644
--- a/posthog/temporal/data_imports/sources/mysql/source.py
+++ b/posthog/temporal/data_imports/sources/mysql/source.py
@@ -121,6 +121,13 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
"ProgrammingError: (1146": None, # Table not found error
"OperationalError: (1356": None, # View not found error
"Bad handshake": None,
+ # MySQL/MariaDB error 1129 (ER_HOST_IS_BLOCKED): the server has blocked our import
+ # host because aborted/interrupted connections from it exceeded `max_connect_errors`.
+ # The block is server-side state that only a DB admin can clear (FLUSH HOSTS /
+ # `mysqladmin flush-hosts`, a restart, or raising `max_connect_errors`) — retrying just
+ # adds more failed connections and keeps the host blocked. Match only the stable phrase,
+ # not the volatile host IP or the `mysqladmin`/`mariadb-admin` wording that varies by server.
+ "is blocked because of many connection errors": "Your MySQL/MariaDB server has blocked PostHog's host after too many interrupted connections (error 1129). Ask your database admin to run 'FLUSH HOSTS' (or 'mysqladmin flush-hosts') and consider raising 'max_connect_errors', then retry the sync.",
# OpenSSL's signature for "tried to speak TLS to an endpoint that replied with
# non-TLS bytes" — the source has SSL enabled but the server (or a proxy in front
# of it, e.g. a plain TCP proxy) doesn't speak TLS, or the host/port is wrong. This
diff --git a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
index c2ec5bdb39e9..3960925189e3 100644
--- a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
+++ b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py
@@ -801,6 +801,23 @@ class TestMySQLSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"SSL version mismatch should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "is blocked because of many connection errors",
+ # MariaDB phrasing (suggests mariadb-admin) — what we actually observed in the wild.
+ "OperationalError: (1129, \"Host '172.31.4.130' is blocked because of many connection "
+ "errors; unblock with 'mariadb-admin flush-hosts'\")",
+ # MySQL phrasing (suggests mysqladmin) — same root cause, different unblock hint.
+ "OperationalError: (1129, \"Host '10.0.1.5' is blocked because of many connection "
+ "errors; unblock with 'mysqladmin flush-hosts'\")",
+ ],
+ )
+ def test_host_blocked_is_non_retryable(self, source, error_msg):
+ non_retryable = source.get_non_retryable_errors()
+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
+ assert is_non_retryable, f"Host-blocked error should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[