From e5e6413da1ea1e6e86cdaa0e0a95ceb86e41274f Mon Sep 17 00:00:00 2001 From: Charlie Swanson Date: Wed, 24 Jun 2015 10:45:52 -0400 Subject: SERVER-19110 Ignore failed operations in mixed_storage_version_replication.js (cherry picked from commit 51cd740ce156485f5b4fcfad159fe3cf22d89065) --- .../mixed_storage_version_replication.js | 23 +++++++++++++++++----- 1 file 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); -- cgit v1.2.1