Details
-
Bug
-
Resolution: Fixed
-
Major - P3
-
None
-
None
-
Fully Compatible
-
ALL
-
Query 2018-04-09
-
0
Description
We use the wrong lock mode for AutoGetOrCreateDB, which conflicts with the earlier lock we acquired:
We can see that this code is attempting to implicitly create the database using MODE_X, after already acquiring a lock above:
|
run_aggregate.cpp |
|
349
|
// Change streams can only be run against collections; |
350
|
// AutoGetCollectionForReadCommand will raise an error if the given namespace is a |
351
|
// view. A change stream may be opened on a namespace before the associated |
352
|
// collection is created, but only if the database already exists. If the |
353
|
// $changeStream was sent from mongoS then the database exists at the cluster level |
354
|
// even if not yet present on this shard, so we allow the $changeStream to run. |
355
|
AutoGetCollectionForReadCommand origNssCtx(opCtx, origNss);
|
356
|
|
357
|
// Resolve the collator to either the user-specified collation or the default |
358
|
// collation of the collection on which $changeStream was invoked, so that we do not |
359
|
// end up resolving the collation on the oplog. |
360
|
invariant(!collatorToUse);
|
361
|
if (!origNssCtx.getDb() && !request.isFromMongos()) { |
362
|
AutoGetOrCreateDb dbLock(opCtx, origNss.db(), MODE_X);
|
363
|
invariant(dbLock.getDb());
|
364
|
}
|
365
|
Collection* origColl = origNssCtx.getCollection();
|
366
|
collatorToUse.emplace(resolveCollator(opCtx, request, origColl));
|