@@ -10,7 +10,7 @@ function doTest(storageEngine) {
1010
1111 const replSet = new ReplSetTest ( {
1212 // Set the syncdelay to 1s to speed up checkpointing.
13- nodeOptions : { syncdelay : 1 } ,
13+ nodeOptions : { syncdelay : 1 , setParameter : { logComponentVerbosity : tojson ( { storage : 1 } ) } } ,
1414 nodes : [ { } , { rsConfig : { priority : 0 , votes : 0 } } ]
1515 } ) ;
1616 // Set max oplog size to 1MB.
@@ -27,11 +27,19 @@ function doTest(storageEngine) {
2727 const longString = new Array ( 400 * 1024 ) . join ( "a" ) ;
2828
2929 function numInsertOplogEntry ( oplog ) {
30+ print ( `Oplog times for ${ oplog . getMongo ( ) . host } : ${
31+ tojsononeline ( oplog . find ( ) . projection ( { ts : 1 , t : 1 , op : 1 , ns : 1 } ) . toArray ( ) ) } `) ;
3032 return oplog . find ( { op : "i" , "ns" : "test.foo" } ) . itcount ( ) ;
3133 }
3234
3335 // Insert the first document.
34- assert . commandWorked ( coll . insert ( { _id : 0 , longString : longString } , { writeConcern : { w : 2 } } ) ) ;
36+ const firstInsertTimestamp =
37+ assert
38+ . commandWorked ( coll . runCommand (
39+ "insert" , { documents : [ { _id : 0 , longString : longString } ] , writeConcern : { w : 2 } } ) )
40+ . operationTime ;
41+ jsTestLog ( "First insert timestamp: " + firstInsertTimestamp ) ;
42+
3543 // Test that oplog entry of the first insert exists on both primary and secondary.
3644 assert . eq ( 1 , numInsertOplogEntry ( primaryOplog ) ) ;
3745 assert . eq ( 1 , numInsertOplogEntry ( secondaryOplog ) ) ;
@@ -42,6 +50,8 @@ function doTest(storageEngine) {
4250 . commandWorked ( coll . runCommand (
4351 "insert" , { documents : [ { _id : 1 , longString : longString } ] , writeConcern : { w : 2 } } ) )
4452 . operationTime ;
53+ jsTestLog ( "Second insert timestamp: " + secondInsertTimestamp ) ;
54+
4555 // Test that oplog entries of both inserts exist on both primary and secondary.
4656 assert . eq ( 2 , numInsertOplogEntry ( primaryOplog ) ) ;
4757 assert . eq ( 2 , numInsertOplogEntry ( secondaryOplog ) ) ;
@@ -64,15 +74,11 @@ function doTest(storageEngine) {
6474 const secondaryTimestamp =
6575 assert . commandWorked ( secondary . adminCommand ( { replSetGetStatus : 1 } ) )
6676 . lastStableRecoveryTimestamp ;
67- if ( primaryTimestamp >= secondInsertTimestamp &&
68- secondaryTimestamp >= secondInsertTimestamp ) {
69- return true ;
70- } else {
71- jsTestLog ( "Awaiting last stable recovery timestamp " +
72- `(primary: ${ primaryTimestamp } , secondary: ${ secondaryTimestamp } ) ` +
73- `target: ${ secondInsertTimestamp } ` ) ;
74- return false ;
75- }
77+ jsTestLog ( "Awaiting last stable recovery timestamp " +
78+ `(primary: ${ primaryTimestamp } , secondary: ${ secondaryTimestamp } ) ` +
79+ `target: ${ secondInsertTimestamp } ` ) ;
80+ return ( ( timestampCmp ( primaryTimestamp , secondInsertTimestamp ) >= 0 ) &&
81+ ( timestampCmp ( secondaryTimestamp , secondInsertTimestamp ) >= 0 ) ) ;
7682 } ,
7783 "Timeout waiting for checkpointing to catch up with the second insert" ,
7884 ReplSetTest . kDefaultTimeoutMS ,
@@ -82,7 +88,13 @@ function doTest(storageEngine) {
8288 // oplog cap maintainer thread will then be unblocked on the creation of the new oplog
8389 // stone and will start truncating oplog entries. The oplog entry for the first
8490 // insert will be truncated after the oplog cap maintainer thread finishes.
85- assert . commandWorked ( coll . insert ( { _id : 2 , longString : longString } , { writeConcern : { w : 2 } } ) ) ;
91+ const thirdInsertTimestamp =
92+ assert
93+ . commandWorked ( coll . runCommand (
94+ "insert" ,
95+ { documents : [ { _id : 2 , longString : longString } ] , writeConcern : { w : 2 } } ) )
96+ . operationTime ;
97+ jsTestLog ( "Third insert timestamp: " + thirdInsertTimestamp ) ;
8698
8799 // Test that oplog entry of the initial insert rolls over on both primary and secondary.
88100 // Use assert.soon to wait for oplog cap maintainer thread to run.
0 commit comments