: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(mysql): stop retrying a locked MySQL/MariaDB account (#110926)
Tom Owers97529d3164ce
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.pyindex 527e22dc132b..1b9f32bca229 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@@ -270,6 +270,13 @@ class MySQLSource("prefix (see TiDB Cloud's connection docs). Otherwise check the user and password ""for this source and try again."),+ # MySQL/MariaDB error 4151 (ER_ACCOUNT_HAS_BEEN_LOCKED): a DB admin locked the connecting+ # account (`ALTER USER ... ACCOUNT LOCK`, or an automatic lock after too many failed+ # logins under `failed_login_attempts`/`password_lock_time`). Only a DB admin can unlock+ # it, and every retry authenticates as the same locked account, so it fails identically+ # forever. Match the locale-independent error code (the message text is translated on+ # non-English servers).+ "(4151,": "Your MySQL/MariaDB user account is locked (error 4151). Ask your database admin to unlock it (for example with 'ALTER USER ... ACCOUNT UNLOCK'), then retry the sync.",# MySQL/MariaDB error 1049 (ER_BAD_DB_ERROR): the configured database doesn't exist on# the server — it was renamed or dropped after the source was set up, or the connection# was reconfigured to point at a different server. `validate_credentials` alreadydiff --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.pyindex 290deded7954..863d8ee9b001 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@@ -2231,6 +2231,24 @@ class TestMySQLSourceNonRetryableErrors:assert friendly is not None, f"TiDB Cloud access-denied error should be non-retryable: {error_msg}"assert "TiDB Cloud" in friendly+ @pytest.mark.parametrize(+ "error_msg",+ [+ "(4151, 'Access denied, this account is locked')",+ "OperationalError: (4151, 'Access denied, this account is locked')",+ ],+ )+ def test_locked_account_is_non_retryable(self, source, error_msg):+ # A locked account only a DB admin can unlock — retrying authenticates as the same+ # account and fails identically forever.+ 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"Locked account error should be non-retryable: {error_msg}"+ assert "locked" in friendly+@pytest.mark.parametrize("error_msg",[