@@ -206,15 +206,16 @@ use for document level locking storage engines:
206
206
207
207
.. _faq-concurrency-database-lock:
208
208
209
- Which administrative commands lock the database?
210
- ------------------------------------------------
209
+ Which administrative commands lock a database?
210
+ ----------------------------------------------
211
211
212
- Certain administrative commands can exclusively lock the database for
213
- extended periods of time. In some deployments, for large databases,
214
- you may consider taking the :binary:`~bin.mongod` instance offline so that
215
- clients are not affected. For example, if a :binary:`~bin.mongod` is part
216
- of a :term:`replica set`, take the :binary:`~bin.mongod` offline and let
217
- other members of the set service load while maintenance is in progress.
212
+ Some administrative commands can exclusively lock a database for
213
+ extended time periods. For large database deployments, you may consider
214
+ taking the :binary:`~bin.mongod` instance offline so that clients are
215
+ not affected. For example, if a :binary:`~bin.mongod` is part of a
216
+ :term:`replica set`, take the :binary:`~bin.mongod` offline and let
217
+ other members of the replica set process requests while maintenance is
218
+ performed.
218
219
219
220
Administrative Commands Taking Extended Locks
220
221
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -226,33 +227,66 @@ database level for extended periods:
226
227
- :dbcommand:`collMod` command
227
228
- :dbcommand:`compact` command
228
229
- :dbcommand:`convertToCapped` command
229
- - :dbcommand:`renameCollection` command and corresponding
230
- :method:`db.collection.renameCollection()` shell method (see below).
231
-
232
- .. versionchanged:: 4.2
233
230
234
- If renaming a collection within the same database, the operation
235
- takes an exclusive (W) lock on the source and target collections.
236
- Prior to MongoDB 4.2, the operation takes an exclusive (W) lock on
237
- the database when renaming within the same database.
231
+ In addition, the :dbcommand:`renameCollection` command and corresponding
232
+ :method:`db.collection.renameCollection()` shell method take the
233
+ following locks depending on the version of MongoDB:
234
+
235
+ .. list-table::
236
+ :header-rows: 1
237
+
238
+ * - Command
239
+
240
+ - MongoDB 4.2.2 or later
238
241
239
- (For :dbcommand:`renameCollection` *only*) If the target namespace
240
- is in a different database as the source collection, the locking
241
- behavior is version dependent:
242
+ - MongoDB 4.2.0 - 4.2.1
242
243
243
- - *(MongoDB 4.2.2 and later)* The operation takes an exclusive
244
- (W) lock on the target database when renaming a collection
245
- across databases and blocks other operations on that database
246
- until it finishes.
244
+ - MongoDB 4.0.X and previous
247
245
248
- - *(MongoDB 4.2.1 and earlier)* The operation takes a global
249
- exclusive (W) lock when renaming a collection across
246
+
247
+ * - :dbcommand:`renameCollection`
248
+
249
+ - If renaming a collection within the same database, the
250
+ :dbcommand:`renameCollection` command takes an exclusive (W) lock
251
+ on the source and target collections.
252
+
253
+ If the target namespace is in a different database as the source
254
+ collection, The :dbcommand:`renameCollection` command takes an
255
+ exclusive (W) lock on the target database when renaming a
256
+ collection across databases and blocks other operations on that
257
+ database until it finishes.
258
+
259
+ - If renaming a collection within the same database, the
260
+ :dbcommand:`renameCollection` command takes an exclusive (W) lock
261
+ on the source and target collections.
262
+
263
+ If the target namespace is in a different database as the source
264
+ collection, The :dbcommand:`renameCollection` command takes a
265
+ global exclusive (W) lock when renaming a collection across
250
266
databases and blocks other operations until it finishes.
251
267
268
+ - Prior to MongoDB 4.2, the :dbcommand:`renameCollection` command
269
+ takes an exclusive (W) lock on the database when renaming within
270
+ the same database.
271
+
272
+
273
+ * - :method:`~db.collection.renameCollection()`
274
+
275
+ - If renaming a collection within the same database, the
276
+ :method:`~db.collection.renameCollection()` method takes an
277
+ exclusive (W) lock on the source and target collections.
278
+
279
+ - (same behavior as MongoDB 4.2.2 or later)
280
+
281
+ - Prior to MongoDB 4.2, the
282
+ :method:`~db.collection.renameCollection()` method takes an
283
+ exclusive (W) lock on the database when renaming within the same
284
+ database.
285
+
252
286
Administrative Commands Taking Brief Locks
253
287
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
254
288
255
- The following administrative operations lock the database but only hold
289
+ These administrative operations lock a database but only hold
256
290
the lock for a very short time:
257
291
258
292
- :dbcommand:`authenticate` command and corresponding
@@ -261,9 +295,7 @@ the lock for a very short time:
261
295
- :dbcommand:`createUser` command and corresponding
262
296
:method:`db.createUser()` shell method
263
297
264
- .. seealso::
265
-
266
- :ref:`faq-concurrency-lock-multiple-dbs`
298
+ :ref:`faq-concurrency-lock-multiple-dbs`
267
299
268
300
.. _faq-concurrency-collection-lock:
269
301
@@ -290,54 +322,52 @@ the collection level:
290
322
:method:`db.collection.dropIndex()` and
291
323
:method:`db.collection.dropIndexes()` shell methods
292
324
293
- - :dbcommand:`renameCollection` command and corresponding
294
- :method:`db.collection.renameCollection()` shell method (see below)
295
-
296
- .. versionchanged:: 4.2
325
+ - the :dbcommand:`renameCollection` command and corresponding
326
+ :method:`db.collection.renameCollection()` shell method take the
327
+ following locks, depending on version:
297
328
298
- If renaming a collection within the same database, the operation
299
- takes an exclusive (W) lock on the source and target collections.
300
- Prior to MongoDB 4.2 , the operation takes an exclusive (W) lock
301
- on the database when renaming within the same database .
302
-
303
- (:dbcommand:`renameCollection` *only*) If the target namespace is
304
- in a different database as the source collection, the locking
305
- behavior is version dependent:
306
-
307
- - *MongoDB 4.2.2 and later* The operation takes an exclusive
308
- (W) lock on the target database when renaming a collection
309
- across databases and blocks other operations on that database
310
- until it finishes.
311
-
312
- - *MongoDB 4.2.1 and earlier* The operation takes a global
313
- exclusive (W) lock when renaming a collection across
314
- databases and blocks other operations until it finishes.
315
-
316
- - :dbcommand:`reIndex` command and corresponding
317
- :method:`db.collection.reIndex()` shell method (see below)
318
-
319
- .. versionchanged:: 4.2
320
-
321
- - For MongoDB 4.2.2 and later, these operations obtain an
322
- exclusive
323
- (W) lock on the collection and block other operations on the
324
- collection until finished.
329
+ - For :dbcommand:`renameCollection` and
330
+ :method:`db.collection.renameCollection()`: If renaming a
331
+ collection within the same database , the operation takes an
332
+ exclusive (W) lock on the source and target collections .
333
+ Prior to MongoDB 4.2, the operation takes an exclusive (W) lock
334
+ on the database when renaming within the same database.
335
+
336
+ - For :dbcommand:`renameCollection` *only*:: If the target namespace
337
+ is in a different database as the source collection, the locking
338
+ behavior is version dependent:
339
+
340
+ - *MongoDB 4.2.2 and later* The operation takes an exclusive
341
+ (W) lock on the target database when renaming a collection
342
+ across databases and blocks other operations on that database
343
+ until it finishes.
344
+
345
+ - *MongoDB 4.2.1 and earlier* The operation takes a global
346
+ exclusive (W) lock when renaming a collection across
347
+ databases and blocks other operations until it finishes.
348
+
349
+ - the :dbcommand:`reIndex` command and corresponding
350
+ :method:`db.collection.reIndex()` shell method take the following
351
+ locks, depending on version:
352
+
353
+ - For MongoDB 4.2.2 and later, these operations obtain an exclusive
354
+ (W) lock on the collection and block other operations on the
355
+ collection until finished.
325
356
326
- - For MongoDB 4.0.0 through 4.2.1, these operations take a
327
- global exclusive (W) lock and block other operations until
328
- finished.
357
+ - For MongoDB 4.0.0 through 4.2.1, these operations take a
358
+ global exclusive (W) lock and block other operations until
359
+ finished.
329
360
330
- - :dbcommand:`replSetResizeOplog` command (see below)
361
+ - the :dbcommand:`replSetResizeOplog` command takes the following locks,
362
+ depending on version:
331
363
332
- .. versionchanged:: 4.2
333
-
334
- - For MongoDB 4.2.2 and later, this operation takes an exclusive
335
- (W) lock on the :data:`oplog <local.oplog.rs>` collection and
336
- blocks other operations on the collection until it finishes.
364
+ - For MongoDB 4.2.2 and later, this operation takes an exclusive
365
+ (W) lock on the :data:`oplog <local.oplog.rs>` collection and
366
+ blocks other operations on the collection until it finishes.
337
367
338
- - For MongoDB 4.2.1 and earlier, this operation takes a global
339
- exclusive (W) lock and blocks other operations until it
340
- finishes.
368
+ - For MongoDB 4.2.1 and earlier, this operation takes a global
369
+ exclusive (W) lock and blocks other operations until it
370
+ finishes.
341
371
342
372
Prior to MongoDB 4.2, these operations took an exclusive lock on the
343
373
database, blocking all operations on the database *and* its collections
0 commit comments