diff options
author | Pierlauro Sciarelli <pierlauro.sciarelli@mongodb.com> | 2021-03-19 10:49:41 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-03-19 11:20:12 +0000 |
commit | f3919cf092f76e317d539a1cde33cf2123c54055 (patch) | |
tree | 216185e1eb3551dbbb4b8da64a1eace55a75c1d2 | |
parent | 76d86a901685b7de79cb28df7c52ba91b43d5b75 (diff) | |
download | mongo-f3919cf092f76e317d539a1cde33cf2123c54055.tar.gz |
SERVER-55248 CRUD state on FSM workload can fail if executed concurrently with a rename
-rw-r--r-- | jstests/concurrency/fsm_workloads/random_DDL_CRUD_operations.js | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/jstests/concurrency/fsm_workloads/random_DDL_CRUD_operations.js b/jstests/concurrency/fsm_workloads/random_DDL_CRUD_operations.js index 9f31c2f494c..7000d6d6660 100644 --- a/jstests/concurrency/fsm_workloads/random_DDL_CRUD_operations.js +++ b/jstests/concurrency/fsm_workloads/random_DDL_CRUD_operations.js @@ -128,26 +128,36 @@ var $config = (function() { } mutexLock(db, data.CRUDMutex, tid); - jsTestLog('CRUD - Insert tid: ' + tid + ' currentTid: ' + this.tid); - // Check if insert succeeded - assertAlways.commandWorked(insertBulkOp.execute()); - let currentDocs = coll.countDocuments({generation: generation}); - // Check guarantees IF NO CONCURRENT DROP is running. - // If a concurrent rename came in, then either the full operation succeded (meaning - // there will be 0 documents left) or the insert came in first. - assertAlways(currentDocs === numDocs || currentDocs === 0); - - jsTestLog('CRUD - Update tid: ' + tid + ' currentTid: ' + this.tid); - assertAlways.commandWorked( - coll.update({generation: generation}, {$set: {updated: true}}, {multi: true})); - - // Delete Data - jsTestLog('CRUD - Remove tid: ' + tid + ' currentTid: ' + this.tid); - // Check if delete succeeded - coll.remove({generation: generation}, {multi: true}); - // Check guarantees IF NO CONCURRENT DROP is running. - assertAlways.eq(coll.countDocuments({generation: generation}), 0); - mutexUnlock(db, data.CRUDMutex, tid); + try { + jsTestLog('CRUD - Insert tid: ' + tid + ' currentTid: ' + this.tid); + // Check if insert succeeded + assertAlways.commandWorked(insertBulkOp.execute()); + let currentDocs = coll.countDocuments({generation: generation}); + // Check guarantees IF NO CONCURRENT DROP is running. + // If a concurrent rename came in, then either the full operation succeded (meaning + // there will be 0 documents left) or the insert came in first. + assertAlways(currentDocs === numDocs || currentDocs === 0); + + jsTestLog('CRUD - Update tid: ' + tid + ' currentTid: ' + this.tid); + assertAlways.commandWorked( + coll.update({generation: generation}, {$set: {updated: true}}, {multi: true})); + + // Delete Data + jsTestLog('CRUD - Remove tid: ' + tid + ' currentTid: ' + this.tid); + // Check if delete succeeded + coll.remove({generation: generation}, {multi: true}); + // Check guarantees IF NO CONCURRENT DROP is running. + assertAlways.eq(coll.countDocuments({generation: generation}), 0); + } catch (e) { + if (e.writeError && e.writeError === ErrorCodes.QueryPlanKilled) { + // It is fine for a CRUD operation to throw ErrorCodes::QueryPlanKilled if + // performed concurrently with a rename (SERVER-31695). + return; + } + throw e; + } finally { + mutexUnlock(db, data.CRUDMutex, tid); + } } }; |