: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): treat SSL wrong-version-number handshake error as non-retryable (#63091)
Tom Owersac3537bb8f4a
diff --git a/posthog/temporal/data_imports/sources/mysql/source.py b/posthog/temporal/data_imports/sources/mysql/source.pyindex aad7a31baaff..0ab3ee0efab5 100644--- a/posthog/temporal/data_imports/sources/mysql/source.py+++ b/posthog/temporal/data_imports/sources/mysql/source.py@@ -119,6 +119,13 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase"ProgrammingError: (1146": None, # Table not found error"OperationalError: (1356": None, # View not found error"Bad handshake": None,+ # OpenSSL's signature for "tried to speak TLS to an endpoint that replied with+ # non-TLS bytes" — the source has SSL enabled but the server (or a proxy in front+ # of it, e.g. a plain TCP proxy) doesn't speak TLS, or the host/port is wrong. This+ # arrives wrapped as a pymysql OperationalError(2013, 'Lost connection ...'), but it+ # is a deterministic config mismatch, not the transient connection-drop that 2013+ # usually signals — so match only the stable SSL token, never the generic 2013 text.+ "[SSL: WRONG_VERSION_NUMBER]": "We couldn't establish an SSL connection to your MySQL server — it responded as if SSL is not enabled. If your server (or a proxy in front of it) doesn't support SSL, set 'Use SSL?' to No; otherwise check that you're connecting to an SSL-enabled host and port.",# Raised from the shared `_decimal_array_from_values` fallback in# `pipelines/pipeline/utils.py` when a numeric/decimal value exceeds Delta Lake's# decimal budget (precision > 76 or scale > 32). Fixed source-data shape — retryingdiff --git a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.pyindex b1d44ef52337..c05354445bf1 100644--- a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py+++ b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py@@ -778,3 +778,31 @@ class TestMySQLSourceNonRetryableErrors: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"Widened integer column error should be non-retryable: {error_msg}"++ @pytest.mark.parametrize(+ "error_msg",+ [+ "[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2657)",+ # The signature also arrives wrapped in pymysql's OperationalError(2013) — we must+ # still catch it without making the bare 2013/"Lost connection" text non-retryable.+ "OperationalError: (2013, 'Lost connection to MySQL server during query "+ "([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:2657))')",+ ],+ )+ def test_ssl_wrong_version_number_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"SSL version mismatch should be non-retryable: {error_msg}"++ @pytest.mark.parametrize(+ "error_msg",+ [+ # A genuine transient connection drop (no SSL signature) must stay retryable.+ "OperationalError: (2013, 'Lost connection to MySQL server during query')",+ "Lost connection to MySQL server during query",+ ],+ )+ def test_transient_lost_connection_stays_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 not is_non_retryable, f"Transient lost-connection error should remain retryable: {error_msg}"