diff --git a/jstests/replsets/read_committed_no_snapshots.js b/jstests/replsets/read_committed_no_snapshots.js index 008d7a08356..5b3e22a7781 100644 --- a/jstests/replsets/read_committed_no_snapshots.js +++ b/jstests/replsets/read_committed_no_snapshots.js @@ -35,12 +35,19 @@ if (!db.serverStatus().storageEngine.supportsCommittedReads) { } // Do a write, wait for it to replicate, and ensure it is visible. -assert.writeOK(db.foo.save({_id: 1, state: 0}, {writeConcern: {w: "majority", wtimeout: 60*1000}})); +var res = db.runCommandWithMetadata( + "insert", + { + insert: "foo", + documents: [{_id: 1, state: 0}], + writeConcern: {w: "majority", wtimeout: 60*1000} + }, + {"$replData": 1}); +assert.commandWorked(res.commandReply); -// We need to propagate the lastOp from the primary as afterOpTime in the secondary to ensure we -// wait for the write to be in the majority committed view. -// TODO SERVER-19890 Fix this to get the real optime rather than constructing a fake one. -var lastOp = {ts: db.getLastErrorObj().lastOp, term: 1}; +// We need to propagate the lastOpVisible from the primary as afterOpTime in the secondary to ensure +// we wait for the write to be in the majority committed view. +var lastOp = res.metadata["$replData"].lastOpVisible; secondary.setSlaveOk(); // Timeout is based on heartbeat timeout.