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 reporting a Vitess reparent as error-tracking noise (#79129)

Tom Owersc148ac6dc0f0
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 d67c2153f483..52b615d37d31 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
@@ -349,7 +349,18 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# "Can't create a new thread" (MySQL error 1135) is the same class of transient host-capacity
# condition — the server hit its OS thread/process limit rather than `max_connections` — and is
# retried in-process the same way (see `_is_transient_cant_create_thread`).
- return {"Lost connection to MySQL server during query", "Too many connections", "Can't create a new thread"}
+ #
+ # A Vitess/PlanetScale shard mid-reparent (see `_is_transient_vitess_reparent`) shares the same
+ # contract too: `_retry_on_transient_tablet_unavailable` already retries it in-process during
+ # metadata discovery, but a reparent can outlast that bounded in-process budget, so match the
+ # stable phrase here as a backstop — Temporal's own activity retry lands on the newly promoted
+ # primary once the reparent completes.
+ return {
+ "Lost connection to MySQL server during query",
+ "Too many connections",
+ "Can't create a new thread",
+ "reparent operation in progress",
+ }
def reconcile_schema_metadata(
self,
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 145f39255e96..2aefb8d2c98d 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
@@ -2225,6 +2225,24 @@ class TestMySQLSourceNonRetryableErrors:
is_retryable = any(pattern in error_msg for pattern in retryable)
assert is_retryable, f"Too-many-connections error should be classified retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ "(1105, 'unknown: target: keyspace.-.primary: primary is not serving, "
+ "there may be a reparent operation in progress')",
+ "reparent operation in progress",
+ ],
+ )
+ def test_vitess_reparent_is_classified_retryable(self, source, error_msg):
+ # `_retry_on_transient_tablet_unavailable` already retries this in-process during metadata
+ # discovery, but a reparent can outlast that bounded budget; once exhausted it re-raises for
+ # Temporal to retry the whole activity. Without this classification `_handle_import_error`
+ # logs it at `exception` on every occurrence, flooding error tracking with a self-recovering
+ # Vitess/PlanetScale failover.
+ retryable = source.get_retryable_errors()
+ is_retryable = any(pattern in error_msg for pattern in retryable)
+ assert is_retryable, f"Vitess reparent error should be classified retryable: {error_msg}"
+
class TestMySQLSourceValidateCredentials:
@pytest.fixture