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): stop retrying a server in offline mode (#113166)

Tom Owersaa6ef6d8408e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
index 8e705cbe8a8f..8b7585c6c360 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/source.py
@@ -478,6 +478,16 @@ class MySQLSource(
# branch never comes back, so every retry fails identically. Match the stable phrase,
# excluding the volatile branch id that follows it.
"branch is missing or sleeping": "The PlanetScale (or Vitess) branch this source connects to has been deleted or put to sleep. Wake it from the PlanetScale dashboard (or resolve any billing issue), or point this source at a database that exists, then resync.",
+ # MySQL/MariaDB error 3032 (ER_SERVER_OFFLINE_MODE): a DB admin put the server into
+ # offline mode (`SET GLOBAL offline_mode = ON`), typically to drain non-admin clients
+ # ahead of maintenance. An already-open connection is allowed to finish its current
+ # statement but gets this error on the next one — which is exactly the streaming read
+ # this source is mid-way through when it hits this. Only an admin with CONNECTION_ADMIN/
+ # SUPER can turn it back off, and every retry reconnects as the same non-admin user, so it
+ # fails identically until they do — the same "wait for an admin action" class as the
+ # locked-account (4151) and host-blocked (1129) entries above. Match the locale-independent
+ # error code (the message text is translated on non-English servers).
+ "(3032,": "Your MySQL/MariaDB server is in offline mode (error 3032), which a database admin turned on to block non-admin connections, usually ahead of maintenance. Ask your database admin to turn it back off ('SET GLOBAL offline_mode = OFF'), then retry the sync.",
}
def get_retryable_errors(self) -> set[str]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
index 812487fb588c..79511a438b51 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mysql/tests/test_mysql.py
@@ -2337,6 +2337,24 @@ class TestMySQLSourceNonRetryableErrors:
assert friendly is not None, f"Locked account error should be non-retryable: {error_msg}"
assert "locked" in friendly
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "(3032, 'The server is currently in offline mode')",
+ "OperationalError: (3032, 'The server is currently in offline mode')",
+ ],
+ )
+ def test_server_offline_mode_is_non_retryable(self, source, error_msg):
+ # A DB admin put the server into offline mode — only they can turn it back off, and
+ # every retry reconnects as the same non-admin user and fails identically until they do.
+ non_retryable = source.get_non_retryable_errors()
+ friendly = next(
+ (message for pattern, message in non_retryable.items() if pattern in error_msg),
+ None,
+ )
+ assert friendly is not None, f"Server offline mode error should be non-retryable: {error_msg}"
+ assert "offline mode" in friendly
+
@pytest.mark.parametrize(
"error_msg",
[