PrefixReadTestCase launches O(oplog entries) readers instead of O(events), causing FSM test timeouts

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • QE 2026-07-06
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      The change stream FSM test suite's PrefixReadTestCase times out on loaded all-feature-flags builds. The db_present test case stalls at lastSeq=69 — the FSM test itself completes but the verifier phase never finishes within the allowed window.

      Root Cause

      PrefixReadTestCase._buildWorkItems() in jstests/libs/util/change_stream/change_stream_verifier.js builds one resume-verification work item per oplog cluster time. On a busy replica set, large numbers of noop and metadata oplog entries accumulate between consecutive change events. Many consecutive cluster times therefore map to the exact same event window (same startIdx into the events array), producing duplicate work items with identical expected output.

      The verifier then launches up to kParallelReadersCount (8) readers concurrently for each of these duplicate items. With hundreds of oplog entries the reader count grows to O(oplog entries) instead of O(change events), exhausting FSM test time.

      Fix

      Add a deduplication guard in _buildWorkItems: track lastStartIdx and skip any cluster time that resolves to the same startIdx as the previous work item. Testing one representative per unique event window is sufficient — all timestamps in the same window produce the same expected output by construction.

      if (startIdx === lastStartIdx) {
          continue;
      }
      lastStartIdx = startIdx;
      

      This bounds the work-item count to at most O(change events) regardless of oplog volume.

      Tests

      Added jstests/change_stream_fsm/test_change_stream_sharding_fsm_verifier.js — a --nodb unit test for _buildWorkItems covering:

      • Deduplicated case: 10 oplog cluster times → 3 unique event windows → 3 work items.
      • No-redundancy case: all cluster times unique → work item count unchanged.
      • BF scenario repro: 401 oplog entries spanning 5 events → ≤ 5 work items.

            Assignee:
            Daniel Tabacaru
            Reporter:
            Daniel Tabacaru
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: