: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): stop retrying when the source server is out of disk space (#75073)
Tom Owers73138b99a290
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 9e92679e92a8..bd3790529445 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,6 +271,20 @@ class MySQLSource(SQLSource[MySQLSourceConfig], SSHTunnelMixin, ValidateDatabase# locale-independent error code (the trailing message text is translated on non-English# servers) so it catches both the raw pymysql string and the wrapped `(1038, ...)` form."(1038,": "Your MySQL/MariaDB server ran out of sort buffer memory while ordering this table by its incremental field (error 1038). We try to avoid the sort by forcing the incremental field's index, but this table has no usable index on that field. Add an index on the incremental field, raise the server's 'sort_buffer_size', or switch this table to a full re-sync, then resync.",+ # MySQL/MariaDB error 3 (EE_WRITE): the server hit ENOSPC writing a temporary file to+ # its own temp directory (e.g. `/rdsdbdata/tmp/...`) — almost always a large filesort+ # spilling the `ORDER BY <incremental_field>` sort to disk. The server's temp filesystem+ # being full is static customer-side state, so every retry filesorts the same rows and+ # fails identically. Match only the errno marker MySQL/MariaDB itself renders in English+ # (`OS errno 28 -` / `Errcode: 28`), not the trailing OS `strerror(28)` text, which is+ # locale-dependent and translated on non-English servers (e.g. French renders "No space+ # left on device" as "Aucun espace disponible sur le périphérique") — matching that text+ # would leave the sync retrying forever on exactly the servers this entry targets. Also+ # deliberately excludes a Python `OSError` (`[Errno 28] No space left on device`) — a+ # full *worker* disk is our own transient infra problem that must stay retryable, not the+ # customer's server running out of space.+ "OS errno 28 -": "Your MySQL/MariaDB server ran out of disk space while writing a temporary file for this sync ('No space left on device'). Syncing a large table can spill a big sort to the server's temporary directory. Free up disk space on your database server, add an index on this table's incremental field so the sync avoids the large sort, or switch the table to a full re-sync, then resync.",+ "Errcode: 28": "Your MySQL/MariaDB server ran out of disk space while writing a temporary file for this sync ('No space left on device'). Syncing a large table can spill a big sort to the server's temporary directory. Free up disk space on your database server, add an index on this table's incremental field so the sync avoids the large sort, or switch the table to a full re-sync, then resync.",# pymysql encodes the handshake fields (host, user, password, database) as latin-1;# a value carrying a non-latin-1 character — most often an invisible zero-width space# (U+200B) pasted in from another app — raises UnicodeEncodeError before any packet isdiff --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 8e820f1e1f14..5da06eb804bf 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@@ -1930,6 +1930,45 @@ class TestMySQLSourceNonRetryableErrors:is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())assert is_non_retryable, f"Out-of-sort-memory error should be non-retryable: {error_msg}"+ @pytest.mark.parametrize(+ "error_msg",+ [+ # MariaDB / RDS rendering seen in the wild (error 3, EE_WRITE).+ str(+ pymysql.err.InternalError(+ 3, "Error writing file '/rdsdbdata/tmp/MYfd=260' (OS errno 28 - No space left on device)"+ )+ ),+ # Temporal-wrapped form of the above.+ "InternalError: (3, \"Error writing file '/rdsdbdata/tmp/MYfd=99' (OS errno 28 - No space left on device)\")",+ # Classic MySQL storage-engine rendering (`Errcode:`, strerror quoted).+ '(3, "Error writing file \'/tmp/MYXXXXXX\' (Errcode: 28 \\"No space left on device\\")")',+ # A non-English OS locale translates the trailing strerror(28) text (French shown here),+ # but the `OS errno 28 -` marker MySQL/MariaDB itself emits is not translated — this must+ # still match, or the sync retries forever on exactly the servers this entry targets.+ "(3, \"Error writing file '/rdsdbdata/tmp/MYfd=42' (OS errno 28 - Aucun espace disponible sur le périphérique)\")",+ ],+ )+ def test_out_of_disk_space_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"Out-of-disk-space error should be non-retryable: {error_msg}"++ @pytest.mark.parametrize(+ "error_msg",+ [+ # A full disk on our *own* worker surfaces as a Python OSError, whose `[Errno 28]`+ # rendering must NOT be swallowed by the MySQL-server disk-full match — it's a transient+ # infra problem that should keep retrying (a fresh worker may have space).+ str(OSError(28, "No space left on device")),+ "[Errno 28] No space left on device: '/tmp/pipeline/part-0.parquet'",+ ],+ )+ def test_worker_disk_full_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"Worker-side disk-full error should remain retryable: {error_msg}"+@pytest.mark.parametrize("error_msg",[