From 624ffeeb25a8982f32295053d30ae1fe000cc15b Mon Sep 17 00:00:00 2001 From: Jack Mulrow Date: Mon, 1 Jul 2019 11:33:28 -0400 Subject: [PATCH] SERVER-41859 logical_time_metadata.js shouldn't assume lastApplied opTime equals $clusterTime --- jstests/sharding/logical_time_metadata.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/jstests/sharding/logical_time_metadata.js b/jstests/sharding/logical_time_metadata.js index 1ba5a10ac11..e8afac2f5b3 100644 --- a/jstests/sharding/logical_time_metadata.js +++ b/jstests/sharding/logical_time_metadata.js @@ -30,12 +30,16 @@ res = st.rs0.getPrimary().adminCommand({replSetGetStatus: 1}); + // Cluster time may advance after replSetGetStatus finishes executing and before its logical + // time metadata is computed, in which case the response's $clusterTime will be greater than the + // appliedOpTime timestamp in its body. Assert the timestamp is <= $clusterTime to account for + // this. var appliedTime = res.optimes.appliedOpTime.ts; var logicalTimeMetadata = res.$clusterTime; - assert.eq(0, - timestampCmp(appliedTime, logicalTimeMetadata.clusterTime), - 'appliedTime: ' + tojson(appliedTime) + ' != clusterTime: ' + - tojson(logicalTimeMetadata.clusterTime)); + assert.lte(0, + timestampCmp(appliedTime, logicalTimeMetadata.clusterTime), + 'appliedTime: ' + tojson(appliedTime) + ' not less than or equal to clusterTime: ' + + tojson(logicalTimeMetadata.clusterTime)); assert.commandWorked(db.runCommand({ping: 1, '$clusterTime': logicalTimeMetadata}));