286 — ChangeStreamHistoryLost

transactionconfiguration

This operation is not supported inside a multi-document transaction

What is happening?

OperationNotSupportedInTransaction is returned when an operation that cannot run inside a multi-document transaction is attempted within one. MongoDB transactions support most CRUD operations, but certain operations like creating collections, creating indexes, DDL commands, and some administrative commands are not allowed inside transactions.

Common causes

  1. Attempting to create a collection inside a transaction
  2. Running createIndex or dropIndex inside a transaction
  3. Using $out or $merge aggregation stages inside a transaction
  4. Executing administrative commands (listCollections, dbStats) inside a transaction
  5. Calling count() inside a transaction (use countDocuments() or an aggregation instead)

Diagnostic Steps

Related Issues

SERVER-137325In Progress
Implement EnsureResumeTokenPresent error-event positioning and gap materialization
h2. Deliverable Implement {{{}ChangeStreamEnsureResumeTokenPresentStage{}}}, a subclass of {{{}CheckResumability{}}}. The stage delivers and positions the outcome decided by the detector. h2. Behavior * *Materialize the stashed gap:* Release the gap stashed by {{CheckResumability}} only when the exact {{ChangeStreamHistoryLost}} signal is received. * *Build and position error events:* Build per-event error events from recoverable failures using {{{}tryBuildErrorEvent{}}}. Compare each
SERVER-137324In Progress
Implement CheckResumability error-event detection and history-loss handling
h2. 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}} ins
SERVER-121956Closed
Adding a new node/shard to a replica may cause "ChangeStreamHistoryLost"
Adding a new node to a replica set and making it primary may cause "ChangeStreamHistoryLost" error when trying to resume from it, because the new node's oplog will neither contain past events nor "initiating set" entry. This is a known limitation of change streams, but it could be somewhat surprising to the user. We can improve the situation in a several ways: Option 1: better error diagnostics pointing at this situation, e.g., "your primary does not have the same history as your secondari