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(mongodb): classify connection pool paused as retryable (#75476)

Tom Owersb293ccf02cd4
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.py
index c52a5eef897b..4e8b88b51980 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
@@ -156,7 +156,14 @@ class MongoDBSource(SimpleSource[MongoDBSourceConfig], ValidateDatabaseHostMixin
# 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"}
+ #
+ # pymongo also raises a bare AutoReconnect("<address>: connection pool paused ...") when a
+ # connection checkout finds the pool not yet READY after an earlier network blip — the
+ # pool's background monitor clears this on its own once it reconnects, so it's distinct
+ # from the persistent "Topology Description:" server-selection failures above. Match the
+ # fixed "connection pool paused" phrase pymongo always uses for this state, not the
+ # surrounding host/timeout values.
+ return {"The resolution lifetime expired", "connection pool paused"}
def get_schemas(
self,
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.py
index 988ca68cb3df..7aec50e76880 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
@@ -487,6 +487,18 @@ class TestGetRetryableErrors(SimpleTestCase):
f"MongoDB DNS SRV resolution timeout should be classified retryable: {error_msg}"
)
+ def test_connection_pool_paused_is_classified_retryable(self):
+ # Bare AutoReconnect raised on connection checkout while the pool is recovering from an
+ # earlier network blip — no "Topology Description:" suffix, so it must not be mistaken
+ # for the persistent server-selection failure classified non-retryable above.
+ error_msg = (
+ "cluster0.example.mongodb.net:27017: connection pool paused "
+ "(configured timeouts: connectTimeoutMS: 20000.0ms)"
+ )
+ assert any(pattern in error_msg for pattern in self.retryable), (
+ f"MongoDB connection pool paused should be classified retryable: {error_msg}"
+ )
+
class TestGetRowsToSync(SimpleTestCase):
"""rows_to_sync is a best-effort progress estimate; a failed count must degrade to