: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 SSH gateway connection failure as non-retryable (#64622)
Tom Owers6e435ee18688
diff --git a/posthog/temporal/data_imports/sources/mysql/source.py b/posthog/temporal/data_imports/sources/mysql/source.pyindex b90b8190de93..e334579a9c3e 100644--- a/posthog/temporal/data_imports/sources/mysql/source.py+++ b/posthog/temporal/data_imports/sources/mysql/source.py@@ -133,6 +133,14 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase"ProgrammingError: (1146": None, # Table not found error"OperationalError: (1356": None, # View not found error"Bad handshake": None,+ # Raised by the `sshtunnel` library (via the shared `open_ssh_tunnel` helper) when the+ # SSH tunnel can't be brought up — the bastion host is unreachable, the host/port is+ # wrong, the SSH key/credentials are rejected, or a firewall blocks PostHog's IPs. The+ # main streaming path already classifies this via `Any_Source_Errors`, but the schema-+ # discovery activity only checks the per-source dict, so without this entry it keeps+ # retrying and reporting the customer's gateway misconfig as error-tracking noise.+ # Postgres and MSSQL already treat this identical error as non-retryable.+ "Could not establish session to SSH gateway": "Could not connect to your SSH tunnel. Check that the SSH host, port, and credentials are correct, the bastion host is running and reachable, and that PostHog's IP addresses are allowed through its firewall.",# MySQL/MariaDB error 1129 (ER_HOST_IS_BLOCKED): the server has blocked our import# host because aborted/interrupted connections from it exceeded `max_connect_errors`.# The block is server-side state that only a DB admin can clear (FLUSH HOSTS /diff --git a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.pyindex d3cf02ca1ee8..cc00af6696b9 100644--- a/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py+++ b/posthog/temporal/data_imports/sources/mysql/tests/test_mysql.py@@ -1143,6 +1143,19 @@ class TestMySQLSourceNonRetryableErrors:is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())assert is_non_retryable, f"Host-blocked error should be non-retryable: {error_msg}"+ @pytest.mark.parametrize(+ "error_msg",+ [+ "Could not establish session to SSH gateway",+ # Temporal-wrapped form carrying the sshtunnel exception class name.+ "BaseSSHTunnelForwarderError: Could not establish session to SSH gateway",+ ],+ )+ def test_ssh_gateway_failure_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"SSH gateway failure should be non-retryable: {error_msg}"+@pytest.mark.parametrize("error_msg",[