Skip to content

Commit 47c4ce9

Browse files
committed
SERVER-42024 Fix opTime race in shards_and_config_return_last_committed_optime.js
1 parent 624ffee commit 47c4ce9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

jstests/sharding/shards_and_config_return_last_committed_optime.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@
5050
"Expected response from a " + connType + " to contain lastCommittedOpTime," +
5151
" received: " + tojson(res) + ", cmd was: " + tojson(cmdObj));
5252

53+
// The last committed opTime may advance after replSetGetStatus finishes executing and
54+
// before its response's metadata is computed, in which case the response's
55+
// lastCommittedOpTime will be greater than the lastCommittedOpTime timestamp in its
56+
// body. Assert the timestamp is <= lastCommittedOpTime to account for this.
5357
const statusRes = assert.commandWorked(testDB.adminCommand({replSetGetStatus: 1}));
54-
assert.eq(
58+
assert.lte(
5559
0,
5660
bsonWoCompare(res.lastCommittedOpTime, statusRes.optimes.lastCommittedOpTime.ts),
5761
"lastCommittedOpTime in command response, " + res.lastCommittedOpTime +
58-
", does not equal the replSetGetStatus lastCommittedOpTime timestamp, " +
62+
", is not <= to the replSetGetStatus lastCommittedOpTime timestamp, " +
5963
statusRes.optimes.lastCommittedOpTime.ts + ", cmd was: " + tojson(cmdObj));
6064

6165
return true;

0 commit comments

Comments
 (0)