-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Change streams
-
None
-
DB Integration & Observability
-
Fully Compatible
-
QI 2025-02-17
-
None
-
None
-
None
-
None
-
None
-
None
-
None
For replica set and single shard transactions, gate the synthesis of the endOfTransaction change events on the allowEndOfTransaction flag in the final applyOps oplog entry if the change stream is opened with the showEndOfTransaction option set to whenAvailable or required and both the server parameter allowEndOfTransaction and the feature flag featureFlagEndOfTransactionEventSynthesis are enabled.
The legacy path for emitting endOfTransaction events from the final applyOps oplog entry is preserved. The legacy path is gated on the feature flag featureFlagEndOfTransactionEvent and the change stream opened with the showExpandedEvents option.
If both paths qualify, the new path gated on the allowEndOfTransaction flag in the applyOps oplog entry will take precedence. For endOfTransaction events emitted via that path, the txnOpIndex of the endOfTransaction event is set to INT32_MAX.
The endOfTransaction event synthesis path for sharded transactions is not implemented by this PR, but will be added later in follow-up PRs.
The change also modifies the change stream's oplog match filter so that it only filters on o2.endOfTransaction oplog entries if no endOfTransaction change events need to be synthesized.
It also adds a check to the getMore executor for change stream started with showEndOfTransaction: required that verifies that the both the server parameter allowEndOfTransaction and the feature flag featureFlagEndOfTransactionEventSynthesis are still enabled, when the getMore executes. If either is disabled, it fails the change stream with a fatal error, because the change stream cannot produce endOfTransaction change events anymore.
Finally, this change modifies the change stream's "classic" operation filter to include endOfTransaction events if the change stream is opened with the showEndOfTransaction flag and without showExpandedEvents, because otherwise that event type would be excluded by the change stream's internal $match.