summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Swanson <cswanson310@gmail.com>2015-06-24 10:45:52 -0400
committerRamon Fernandez <ramon@mongodb.com>2016-01-14 18:32:58 -0500
commite5e6413da1ea1e6e86cdaa0e0a95ceb86e41274f (patch)
tree9bf3d1e7ee81deb4985dd3ce3c29372f47a5730e
parent761473b023c938d50c8835599514667fbd8b6dd9 (diff)
downloadmongo-e5e6413da1ea1e6e86cdaa0e0a95ceb86e41274f.tar.gz
SERVER-19110 Ignore failed operations in mixed_storage_version_replication.js
(cherry picked from commit 51cd740ce156485f5b4fcfad159fe3cf22d89065)
-rw-r--r--jstests/multiVersion/mixed_storage_version_replication.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/jstests/multiVersion/mixed_storage_version_replication.js b/jstests/multiVersion/mixed_storage_version_replication.js
index 601aa48388f..b7c034fbef3 100644
--- a/jstests/multiVersion/mixed_storage_version_replication.js
+++ b/jstests/multiVersion/mixed_storage_version_replication.js
@@ -86,8 +86,12 @@ var RandomOps = {
},
getRandomDoc: function(collection) {
- var randIndex = Random.randInt(0, collection.find().count());
- return collection.find().sort({$natural: 1}).skip(randIndex).limit(1)[0];
+ try {
+ var randIndex = Random.randInt(0, collection.find().count());
+ return collection.find().sort({$natural: 1}).skip(randIndex).limit(1)[0];
+ } catch(e) {
+ return undefined;
+ }
},
/*
@@ -151,13 +155,17 @@ var RandomOps = {
if (coll === null || coll.find().count() === 0) {
return null; // No data, can't delete anything.
}
- // If multithreaded, doc might be undefined.
var doc = this.getRandomDoc(coll);
+ if (doc === undefined) {
+ // If multithreaded, there could have been issues finding a random doc.
+ // If so, just skip this operation.
+ return;
+ }
+
if (this.verbose) {
print("Deleting:");
printjson(doc);
}
- // If multithreaded, doc might not exist anymore.
try {
coll.remove(doc);
} catch(e) {
@@ -175,8 +183,13 @@ var RandomOps = {
if (coll === null || coll.find().count() === 0) {
return null; // No data, can't update anything.
}
- // If multithreaded, doc might be undefined.
var doc = this.getRandomDoc(coll);
+ if (doc === undefined) {
+ // If multithreaded, there could have been issues finding a random doc.
+ // If so, just skip this operation.
+ return;
+ }
+
var field = this.randomChoice(this.fieldNames);
var updateDoc = {$set: {}};
updateDoc.$set[field] = this.randomChoice(this.fieldValues);