global snapshot find and aggregate intermittently fails with SnapshotTooOld error even with retries, This indicates that the snapshot window is just too short.
assert.soon(() => { const res = sessionDb.runCommand(cmdObj); if (!res.ok) { assert(res.code === ErrorCodes.SnapshotTooOld || res.code === ErrorCodes.TransactionAborted, "expected command to fail with SnapshotTooOld or TransactionAborted, cmd: " tojson(cmdObj) + ", result: " + tojson(res)); print("Retrying because of SnapshotTooOld or TransactionAborted error."); txnNumber++; cmdObj.txnNumber = NumberLong(txnNumber); return false; } assert.commandWorked(res, "expected command to succeed, cmd: " + tojson(cmdObj)); return true; });
Thnis is a test case where cmd is any mongos find or aggregate commands with readConcern:
{snapshot: true}