: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(mongodb): classify DNS SRV lifetime timeout as retryable (#73390)
Tom Owers50810654513a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.pyindex f9d9d3b670f2..7c72b8649acd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/source.py@@ -151,6 +151,16 @@ class MongoDBSource(SimpleSource[MongoDBSourceConfig], ValidateDatabaseHostMixin"Topology Description:": _MONGO_UNREACHABLE_MESSAGE,}+ def get_retryable_errors(self) -> set[str]:+ # For a `mongodb+srv://` URI, pymongo resolves the SRV record via dnspython inside the+ # MongoClient constructor, before any of our own connectivity handling runs. dnspython+ # already retries across nameservers for the whole resolution lifetime before giving up+ # with a ConfigurationError wrapping its LifetimeTimeout — a momentary DNS blip on the+ # resolver PostHog's worker queries, unrelated to the user's cluster hostname — so Temporal+ # retrying the whole activity is self-recovering. Match dnspython's fixed message prefix,+ # not the variable timeout duration or nameserver address it's followed by.+ return {"The resolution lifetime expired"}+def get_schemas(self,config: MongoDBSourceConfig,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/test_mongo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/test_mongo.pyindex 1fd8e5551187..fed4c5f86947 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/test_mongo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mongodb/test_mongo.py@@ -463,6 +463,27 @@ class TestMongoDBNonRetryableErrors(SimpleTestCase):assert expected_substring in message.lower()+class TestGetRetryableErrors(SimpleTestCase):+ """DNS SRV resolution for `mongodb+srv://` happens inside the MongoClient constructor, before+ any of our own connectivity handling runs. dnspython already retries across nameservers for+ the whole resolution lifetime before giving up, so once Temporal retries the whole activity+ the failure is self-recovering and must not flood error tracking as an exception."""++ def setUp(self):+ from products.warehouse_sources.backend.temporal.data_imports.sources.mongodb.source import MongoDBSource++ self.retryable = MongoDBSource().get_retryable_errors()++ def test_dns_lifetime_timeout_is_classified_retryable(self):+ error_msg = (+ "The resolution lifetime expired after 20.763 seconds: Server Do53:10.0.0.53@53 "+ "answered The DNS operation timed out."+ )+ assert any(pattern in error_msg for pattern in self.retryable), (+ f"MongoDB DNS SRV resolution timeout should be classified retryable: {error_msg}"+ )++class TestGetRowsToSync(SimpleTestCase):"""rows_to_sync is a best-effort progress estimate; a failed count must degrade to0 without failing the sync, and expected pymongo errors must not be reported to