-
Type: Bug
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 4.0.6, 4.1.8
-
Component/s: Querying, Replication
-
None
-
ALL
-
-
Query 2019-04-08
When running a getMore command against a cursor that was originally created by an aggregate command with read concern "majority", we may return data that is not majority committed if the command is run against a replica set secondary. The read concern for a getMore command is not stored directly on its OperationContext. It instead inherits its read concern from the cursor object, and we will set the timestamp read source to kMajorityCommitted for getMore commands here. This happens before we generate the getMore batch, however. For aggregate commands, locks will only be taken once we enter the batch generation phase, and, for reads, these locks will be taken inside the AutoGetCollectionForRead constructor. The AutoGetCollectionForRead constructor determines if a command should read at the lastApplied timestamp based on the read concern on the OperationContext. For a getMore command, there shouldn't be a read concern on the OperationContext since it is inherited from the cursor. This means that we will decide to read at the lastApplied timestamp on secondaries, overriding the majority committed read source we previously set.
This has implications for getMore commands run on standard aggregate query cursors and also for change streams, since they create cursors via the aggregate command i.e. it is possible for a change stream run against a secondary to return data that are not majority committed. I believe this issue goes back to 4.0, since that was when the logic around reading from the lastApplied timestamp on secondaries was added. The attached repro shows the same issue when run against a 4.0 server.
- duplicates
-
SERVER-39356 Change stream updateLookup queries with speculative majority may return uncommitted data
- Closed