-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
DB Integration & Observability
-
QI 2025-02-17, QE 2026-10-26
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Deliverable
ChangeStreamCheckResumabilityStage becomes a detector that signals rather than emits.
- Feature flag off: Translate OplogQueryMinTsMissing to ChangeStreamHistoryLost (286).
- Feature flag on: Apply the same translation, and also catch a mid-stream CappedPositionLost and rethrow it as ChangeStreamOplogCursorLost (533, retriable).
- History loss: The oplog scan records the earliest surviving timestamp in changeStreamOplogFloorAfterRollover instead of throwing. The stage builds a ChangeStreamHistoryLost gap over the client’s requested token, tags error.shardId on a shard, stashes it in pendingChangeStreamResumeGap, and signals with uasserted(ChangeStreamHistoryLost).
- Position error events crossing from below or from ashard: Forward a gap naming the client’s requested token (per shard, without deduplication). Swallow errors at or before the token; fail closed on an unsplit-fragment error; and, on a surpassing error, deliver the stashed gap.
- Buffer E+1: Preserve E+1 when a gap takes its place, then re-record the buffered event’s identity when draining it.
Files
- src/mongo/db/exec/agg/change_stream_check_resumability_stage.{h,cpp}
- src/mongo/db/pipeline/document_source_change_stream_check_resumability.{h,cpp}
- src/mongo/db/exec/agg/change_stream_handle_topology_change_v2_stage.cpp — oplog-scan floor recording
Tests
- Unit (document_source_check_resume_token_test): Verify translation, gap build/stash/signal, buffered E+1 identity re-recording, positioning, and fail-closed fragment behavior.
- Integration: Verify an oplog-rollover history-lost gap on a replica set.
Dependencies
ChangeStreamError stage, Expression context support, recording.