diff options
author | David Hows <howsdav@gmail.com> | 2015-06-01 17:04:30 +1000 |
---|---|---|
committer | David Hows <howsdav@gmail.com> | 2015-06-15 12:27:58 +1000 |
commit | 546e2943af3c9d0eb50062c26f52303452423f29 (patch) | |
tree | afd861dee0bb9ae2ddf601f49d908dc1674e42ad | |
parent | 5fe6c4c3ec75a50c7e3d46a7e503c6fd4562db58 (diff) | |
download | mongo-546e2943af3c9d0eb50062c26f52303452423f29.tar.gz |
SERVER-18679 Wrong key count for reverse indexes in WT
-rw-r--r-- | jstests/noPassthroughWithMongod/validate_command.js | 41 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | 2 |
2 files changed, 42 insertions, 1 deletions
diff --git a/jstests/noPassthroughWithMongod/validate_command.js b/jstests/noPassthroughWithMongod/validate_command.js new file mode 100644 index 00000000000..9f92bc0bed8 --- /dev/null +++ b/jstests/noPassthroughWithMongod/validate_command.js @@ -0,0 +1,41 @@ +// Tests that the basic values returned from the validate command are correct + +(function() { + // Set the number of documents to insert + var count = 10; + + function testValidate(output) { + assert.eq(output.nrecords, count, "validate returned an invalid count") + assert.eq(output.nIndexes, 3, "validate returned an invalid number of indexes") + + var indexNames = output.keysPerIndex + + for (var i in indexNames) { + if (!indexNames.hasOwnProperty(i)) + continue; + assert.eq(indexNames[i], count, "validate returned an invalid number of indexes") + } + } + + // Test to confirm that validate is working as expected. + + // SETUP DATA + t = db.jstests_validate; + t.drop(); + + for(var i = 0; i < count; i++){ + t.insert({x:i}); + } + + t.ensureIndex({x:1}, {name: "forward"}) + t.ensureIndex({x:-1}, {name: "reverse"}) + + + // TEST NORMAL VALIDATE + var output = t.validate() + testValidate(output); + + // TEST FULL + var output = t.validate({full:true}) + testValidate(output); +}());
\ No newline at end of file diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index 38fd883886f..54a25954f44 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -289,7 +289,7 @@ namespace { TRACE_INDEX << " fullValidate"; const auto requestedInfo = TRACING_ENABLED ? Cursor::kKeyAndLoc : Cursor::kJustExistance; - for (auto kv = cursor->seek(minKey, true, requestedInfo); kv; kv = cursor->next()) { + for (auto kv = cursor->seek(BSONObj(), true, requestedInfo); kv; kv = cursor->next()) { TRACE_INDEX << "\t" << kv->key << ' ' << kv->loc; count++; } |