01Context
+
A change-stream consumer restarts and resumes from its latest token, but a downstream record is missing. The consumer stored progress before the destination write completed. Another team stores tokens afterward and occasionally sees duplicates instead. Checkpoint timing determines the recovery contract. A useful design must combine resumable source progress with durable downstream processing and an explicit resynchronisation path.
02Understand what the token represents
+
MongoDB documents change streams and resume tokens for returning to a position in the supported change history. Resumption depends on the deployment, available history, and compatible stream options. The documentation also explains invalidation and other cases requiring particular handling. Review the current guide for the exact MongoDB version and pipeline.
A token identifies stream progress; it does not prove the downstream business action completed. Keep the token's role separate from the destination's transaction or idempotency mechanism. The consumer must decide when advancing progress is safe.
03An illustrative missing projection
+
Imagine a consumer updating a search index. It receives an event, saves the resume token, and then calls the index. The process crashes before the call succeeds. On restart, it resumes after the event, so the document remains stale.
Saving progress after destination completion avoids that particular skip, but a crash between completion and checkpoint can repeat the event. Design the destination to recognise repetition or apply a version-aware update. The goal is not merely to choose “before” or “after,” but to define the full recovery boundary.
04Keep a durable processing record
+
Associate stream identity, pipeline version, source deployment, token, event identity, and destination result. Persist enough context to distinguish a token from a different stream configuration or environment. Avoid storing a bare opaque value with no ownership information.
Where the source checkpoint and destination effect cannot share a transaction, use an explicit at-least-once processing model with idempotent or reconciled effects. A queue, operation ledger, or another supported architecture may help. Choose the mechanism based on the destination and business consequence.
05Review event interpretation
+
Determine whether the consumer applies deltas, reads the current document, or uses another event representation. A later lookup can reflect state beyond the exact change event, depending on the selected options. Understand that distinction before treating every event as a complete historical snapshot.
Handle deletes and missing documents deliberately. A lookup returning no document can be a valid consequence of later deletion, not a transient failure to retry forever. Preserve the source entity identifier and operation type so the destination can remove or reconcile the corresponding projection correctly.
06Budget the resumable history
+
Measure the longest credible consumer outage, investigation, and catch-up period against available source history. Watch the relevant retention window and backlog. A consumer can be healthy today while an extended pause would make its saved token unusable.
Define what happens when resumption is impossible. The correct answer may be a controlled rebuild from authoritative data followed by a coordinated stream transition. Do not skip to the latest position merely to restore a green process status if doing so abandons unprocessed business changes.
07Version pipeline changes
+
Record the filtering and transformation pipeline with the checkpoint. Changing which events are visible can affect resumption and downstream assumptions. Test the documented compatibility rules and relevant event cases before deploying a new consumer version.
Keep a migration plan for destination schema changes. A replayed event from an older period may not fit a newly assumed representation. Validate representative historical events and maintain an exception path that does not silently discard unrecognised data.
08Rehearse crash boundaries
+
Interrupt the consumer before destination write, after destination acceptance, and before checkpoint persistence. Restart it and inspect both stream progress and destination state. Confirm that duplicates are handled and missing effects are repaired.
Test source unavailability, a token beyond the available history, and a delete event. Include a downstream timeout after an uncertain write. The runbook should tell operators when to resume normally, when to reconcile a specific event, and when a controlled rebuild is required.
09Quick diagnostic map
+
| Evidence | Interpretation | Next check |
|---|---|---|
| Destination misses an event | Checkpoint advanced too early | Inspect durable handoff |
| Event repeats after restart | Checkpoint follows effect | Use idempotent apply |
| Resume history unavailable | Recovery window exceeded | Run controlled rebuild |
10A focused operator exercise
+
Prepare a synthetic source collection with inserts, updates, and deletion, and retain the expected downstream projection. Record stream options, pipeline version, token, and destination operation identity. Interrupt the consumer before destination write, after destination acceptance, and before checkpoint persistence. Restart after each interruption and verify both replay behaviour and final business state.
Introduce a downstream timeout with an uncertain write result. The consumer should reconcile or safely repeat using the stable event identity. Then test a missing-document lookup and a duplicate event. These cases should have explicit outcomes rather than causing an endless retry or silent skip. Keep the source event interpretation consistent with the chosen stream options.
Finally, exercise the documented response to unavailable resume history in an isolated environment. Rebuild or resynchronise through the intended procedure and verify the handoff to ongoing changes. The receipt should explain checkpoint ownership, retained history, repeated effects, and any reconciliation exceptions. A running cursor is accepted only after the destination converges to the intended state.
11Verify business convergence
+
Monitor checkpoint age, unprocessed event age, destination failures, repeated event identifiers, and reconciliation differences. A running cursor is not evidence that the search index, cache, or reporting view is correct.
Clouvenix can help design change-stream checkpoints around the actual downstream completion boundary. The outcome is recovery that explains both replay and gaps, with a tested route back to a correct business view.
12Frequently asked questions
+
Should the token be saved immediately after receiving an event?
Only if the architecture has durably taken ownership of the event elsewhere before advancing. Otherwise, a crash can skip unfinished downstream work. Define the handoff boundary and test it explicitly.
Can a resume token replace periodic reconciliation?
It tracks source progress but does not detect every destination defect, manual change, or interpretation bug. Use reconciliation appropriate to the business importance of the projection and keep a supported rebuild procedure.
Explore Clouvenix mongodb administration for implementation and operational handover.