: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): recognize Vitess-wrapped unknown-column errors as non-retryable (#78474)
Tom Owers9d813ac08613
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 5cba0b578183..56a217457f9c 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@@ -271,11 +271,13 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase# longer exists in the source table — almost always the configured incremental field# after the column was renamed or dropped (schema drift). The streaming query reissues# the same WHERE/ORDER BY on every attempt, so it fails identically forever; the COUNT(*)- # probe already swallows this same error expecting it to be classified here. Match on the- # locale-independent error code (the column name and clause are volatile, and the message- # text is translated on non-English servers) so it catches both the raw pymysql string and- # the Temporal-wrapped `OperationalError: (1054, ...)` form.- '(1054, "Unknown column': "A column referenced during sync no longer exists in your source table (MySQL error 1054). This usually means a column was renamed or dropped — if it's the table's incremental field, update it to a column that exists (or switch to a full re-sync), then resync.",+ # probe already swallows this same error expecting it to be classified here. Match on+ # "Unknown column" alone (not anchored to a `(1054, "` prefix) so it also catches Vitess/+ # PlanetScale's vtgate, which re-wraps the same 1054 error with its own gRPC preamble —+ # e.g. `(1054, 'unknown: target: ...: vttablet: rpc error: code = NotFound desc = Unknown+ # column ... (errno 1054) ...')` — where the message text sits well after `(1054, ` and+ # behind a single quote rather than the double quote pymysql itself uses.+ "Unknown column": "A column referenced during sync no longer exists in your source table (MySQL error 1054). This usually means a column was renamed or dropped — if it's the table's incremental field, update it to a column that exists (or switch to a full re-sync), then resync.",# MySQL/MariaDB error 1130 (ER_HOST_NOT_PRIVILEGED): the server has no grant permitting# PostHog's connecting host, so the handshake is rejected before any credentials are# checked. Only a DB admin can fix this server-side (GRANT for the host, or allow ourdiff --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 9c93874bea99..c7aa7f0a221a 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@@ -1895,6 +1895,17 @@ class TestMySQLSourceNonRetryableErrors:"OperationalError: (1054, \"Unknown column 'favoritor_id' in 'where clause'\")",# Other clause variants share the same 1054 code and "Unknown column" prefix."OperationalError: (1054, \"Unknown column 'deleted_at' in 'order clause'\")",+ # Vitess/PlanetScale's vtgate re-wraps the same 1054 error with its own gRPC preamble,+ # so "Unknown column" sits well after `(1054, ` and behind a single quote rather than+ # pymysql's own double quote — this shape doesn't share a contiguous `(1054, "` prefix+ # with the raw pymysql form above.+ str(+ pymysql.err.OperationalError(+ 1054,+ "unknown: target: ks.-.primary: vttablet: rpc error: code = NotFound desc = "+ "Unknown column 'team_id' in 'field list' (errno 1054) (sqlstate 42S22)",+ )+ ),],)def test_unknown_column_is_non_retryable(self, source, error_msg):