-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Change streams
-
None
-
DB Integration & Observability
-
Fully Compatible
-
QE 2026-10-12
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The cluster-level post-batch resume token is read once per returned document when mongos fills a batch, and once per event in degraded (ignoreRemovedShards) mode. Each read deep-copied the resume token, so every change stream event paid a malloc+memcpy even though the bytes are immediately re-serialized into the batch response. The high watermarks are immutable, ref-counted BSON buffers that are only ever reassigned and never mutated in place. The high watermark getters can share the existing buffer with the returned sub-object rather than copying it. The returned object keeps the buffer alive independently of the merger, and the downstream call of `getOwned()` in `setPostBatchResumeToken()` becomes a no-op.
`shareOwnershipWith()` enforces that the source is already owned, so it is not called when the source BSONObj is empty.