-
Type:
Task
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
Fully Compatible
-
QI 2025-02-17
-
200
-
None
-
None
-
None
-
None
-
None
-
None
-
None
jstests/sharding/query/change_streams/change_stream_read_preference.js samples $indexStats accesses.ops for the id index on each shard secondary around the change-stream getMore and asserts the delta is exactly 1 — the optimized post-image update lookup.
Mirrored reads can break that assertion: an update served by the shard primary is mirrored to a secondary as a synthesized find of its filter (CmdUpdate::supportsReadMirroring, write_commands.cpp), recording an extra id index access on the secondary. Mirroring is on by default and 1%-sampled (mirrorReads parameter); on slow debug/UBSan variants the mirrored find can execute inside the test's $indexStats window, failing with "expected 2 to equal 1 ... indexOpsDelta:
{"_id_":2}". Same flake class as the applier race fixed in SERVER-135633.
Fix: disable mirrored reads in the test's ShardingTest startup setParameter:
mirrorReads: {samplingRate: 0.0, targetedMirroring: {samplingRate: 0.0}}.
Red/green verified locally on sharding_config_shard (repro: samplingRate 1.0 + failCommand blocking find on the secondaries). Details and failure timeline on BF-47240.