ExportXMLWordPrintableJSON

    • Python Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Describe the background behind the problem.

      tests/unit_tests/test_sync.py::test_ttl sets ttl=1 second and ttlMonitorSleepSecs=2 (the interval between MongoDB's background TTL sweeps), then does a single sleep(ttl + monitor_period) (3 seconds total) before asserting the expired checkpoint is gone.

      ttlMonitorSleepSecs controls the interval between sweeps, not a deadline: worst case, a sweep just completed as the document became eligible, so the next one is up to a full monitor_period away, plus the delete itself takes non-zero time. A single fixed sleep of exactly ttl + monitor_period leaves essentially no margin and races the background thread.

      Hit in a real release run for langgraph-checkpoint-mongodb 0.5.0 (INTPYTHON-1042, now merged): AssertionError: assert 1 == 0 — the checkpoint hadn't been swept yet when the assertion ran. Job: https://github.com/langchain-ai/langchain-mongodb/actions/runs/33817503742/job/100852843438

      This is a real design race in the test (tight, un-buffered timing), not random infrastructure flakiness.

      Fix

      What was done.

      Replaced the fixed sleep + single assert with a poll loop: check every 0.5s for up to ttl + 5 * monitor_period (11s), returning as soon as the TTL sweep has run, and only failing if it never converges within that generous budget. Verified locally against a real local-Atlas container: 5/5 consecutive runs pass, completing in 1.6-3.2s each (vs. the previous fixed 3s every time), so the common case isn't slowed down.

      Pitfalls

      What should the implementer watch out for? What are the risks?

      None specific - contained to one test file, no production code changes.

            Assignee:
            Casey Clements
            Reporter:
            Casey Clements
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: