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 deleted or sleeping PlanetScale branch (#78480)

Tom Owersfe704e931f08
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 f2f9753c8e5f..5cba0b578183 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
@@ -320,6 +320,14 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase
# the sync path classifies and in the " ".join(e.args) form validate_credentials builds
# (the formatted "codec can't encode character" text is reconstructed in neither).
"ordinal not in range(256)": "One of your connection details contains an invisible or unsupported character (for example a zero-width space pasted in from another app). Retype the affected field — host, database, user, or password — by hand instead of pasting it, then re-enable the sync.",
+ # Vitess/PlanetScale vtgate error 1105 (ER_UNKNOWN_ERROR) raised when the target
+ # keyspace ("branch" in PlanetScale) has been deleted or put to sleep. Unlike the other
+ # transient 1105 payloads mysql.py already retries in-process (`code = Unavailable`,
+ # `reparent operation in progress`), a sleeping branch never wakes on its own — PlanetScale
+ # only wakes it from the dashboard or once a billing issue is resolved — and a deleted
+ # 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.",
}
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 46842345f120..9c93874bea99 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
@@ -2059,6 +2059,20 @@ class TestMySQLSourceNonRetryableErrors:
is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())
assert is_non_retryable, f"Non-latin-1 connection field error should be non-retryable: {error_msg}"
+ @pytest.mark.parametrize(
+ "error_msg",
+ [
+ # Raw pymysql str(error) form the import/sync path classifies.
+ str(pymysql.err.OperationalError(1105, "not_found: branch is missing or sleeping: aaaaaaaaaaaa")),
+ # Temporal-wrapped str(e.cause) form — different branch id, same stable phrase.
+ "OperationalError: (1105, 'not_found: branch is missing or sleeping: bbbbbbbbbbbb')",
+ ],
+ )
+ def test_planetscale_branch_sleeping_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"PlanetScale sleeping/missing branch error should be non-retryable: {error_msg}"
+
@pytest.mark.parametrize(
"error_msg",
[