The compareOps function in trace_missing_docs.js compares the optimes of two oplog entries using the JavaScript < operator. This (probably) coerces the objects to strings and compares their string representations.
var compareOps = function( opA, opB ) { if ( opA.ts < opB.ts ) return -1; if ( opB.ts < opA.ts ) return 1; else return 0; } allOps.sort( compareOps );
The test fails because it expects the insert operation to be first for this shard key, but '10' < '4' causes the delete operation to come first. bsonWoCompare(Timestamp(1444326827, 10), Timestamp(1444326827, 4)) returns 1 as expected, so the fix should be to use the bsonWoCompare() function instead.
[js_test:trace_missing_docs_test] 2015-10-08T17:53:47.938+0000 ---- [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.939+0000 Using shard key : { "sk" : 67890 } [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.939+0000 ---- [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.939+0000 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.939+0000 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.941+0000 Ops found for doc { "_id" : 12345, "sk" : 67890 } on each shard: [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.941+0000 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.941+0000 { [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "ts" : Timestamp(1444326827, 10), [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "h" : NumberLong(0), [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "v" : 2, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "op" : "d", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "ns" : "foo.bar", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "o" : { [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.942+0000 "_id" : 12345 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 }, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 "shard" : "shard0000", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 "realTime" : ISODate("2015-10-08T17:53:47Z") [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 } [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 { [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 "ts" : Timestamp(1444326827, 4), [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 "h" : NumberLong(0), [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.943+0000 "v" : 2, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "op" : "i", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "ns" : "foo.bar", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "o" : { [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "_id" : 12345, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "sk" : 67890, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "hello" : "world" [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 }, [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.944+0000 "shard" : "shard0000", [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.945+0000 "realTime" : ISODate("2015-10-08T17:53:47Z") [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.945+0000 } ... [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 2015-10-08T17:53:47.943+0000 E QUERY [thread1] Error: ["d"] != ["i"] are not equal : undefined : [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 doassert@src/mongo/shell/assert.js:15:14 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 assert.eq@src/mongo/shell/assert.js:43:5 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 testDocMissing@jstests/sharding/trace_missing_docs_test.js:39:1 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 @jstests/sharding/trace_missing_docs_test.js:49:1 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 [js_test:trace_missing_docs_test] 2015-10-08T17:53:47.950+0000 failed to load: jstests/sharding/trace_missing_docs_test.js
- related to
-
SERVER-21941 Automatically handle Timestamp comparisons in assert helpers
- Closed