[SERVER-42478] Remove DB MODE_X locks from oplog application of create/createIndexes Created: 29/Jul/19  Updated: 29/Oct/23  Resolved: 16/Sep/19

Status: Closed
Project: Core Server
Component/s: Concurrency, Replication
Affects Version/s: None
Fix Version/s: 4.2.1, 4.3.1

Type: Bug Priority: Major - P3
Reporter: Geert Bosch Assignee: Daniel Gottlieb (Inactive)
Resolution: Fixed Votes: 0
Labels: KS
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
is related to SERVER-53846 Clarify locking requirements in creat... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Steps To Reproduce:

Found by code inspection, no reproducer yet.

Sprint: Execution Team 2019-09-09, Execution Team 2019-09-23
Participants:

 Description   

In oplog application, there are still places (here and here) where we take MODE_X database locks. This could affect secondary read performance in presence of DDL operations on other collections in the same database.



 Comments   
Comment by Githook User [ 24/Sep/19 ]

Author:

{'username': 'dgottlieb', 'email': 'daniel.gottlieb@mongodb.com', 'name': 'Daniel Gottlieb'}

Message: SERVER-42478: Relax create collection in oplog application to take a DB_IX lock.

(cherry picked from commit 8357a1d76883e8a20c014c58c6b1feabffb91742)
Branch: v4.2
https://github.com/mongodb/mongo/commit/4fc3e8d5910547e22d3c4afb22454ffaab343aa2

Comment by Githook User [ 16/Sep/19 ]

Author:

{'name': 'Daniel Gottlieb', 'username': 'dgottlieb', 'email': 'daniel.gottlieb@mongodb.com'}

Message: SERVER-42478: Relax create collection in oplog application to take a DB_IX lock.
Branch: master
https://github.com/mongodb/mongo/commit/8357a1d76883e8a20c014c58c6b1feabffb91742

Comment by Judah Schvimer [ 30/Jul/19 ]

I also wonder if SERVER-41061 or SERVER-39995 would have caught this.

Comment by Judah Schvimer [ 29/Jul/19 ]

In theory something like this should be able to test it in concurrency_sharded_replication, but it hasn't reproduced:

diff --git a/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js b/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
index 56a8b5d3a1..8e12131b50 100644
--- a/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
+++ b/jstests/concurrency/fsm_workloads/multi_statement_transaction_atomicity_isolation.js
@@ -289,6 +289,16 @@ var $config = (function() {
                     }
                     throw e;
                 }
+            },
+
+            createCollection: function createCollection(db, collName) {
+                const collection = this.collections[Random.randInt(this.collections.length)];
+                const randomDbName = collection.getDB().getName();
+
+                assert.commandWorkedOrFailedWithCode(
+                    db.createCollection("random_coll_" + Random.randInt(99999999)),
+                    ErrorCodes.NamespaceExists);
+
             }
         };
     })();
@@ -318,9 +328,10 @@ var $config = (function() {
 
     const transitions = {
         init: {update: 0.9, checkConsistency: 0.1},
-        update: {update: 0.8, checkConsistency: 0.1, causalRead: 0.1},
+        update: {update: 0.7, createCollection: 0.1, checkConsistency: 0.1, causalRead: 0.1},
         checkConsistency: {update: 1},
         causalRead: {update: 1},
+        createCollection: {update: 1},
     };

Generated at Thu Feb 08 05:00:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.