-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Fully Compatible
-
ALL
-
Query 2018-04-09
-
0
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
// Change streams can only be run against collections; // AutoGetCollectionForReadCommand will raise an error if the given namespace is a // view. A change stream may be opened on a namespace before the associated // collection is created, but only if the database already exists. If the // $changeStream was sent from mongoS then the database exists at the cluster level // even if not yet present on this shard, so we allow the $changeStream to run. AutoGetCollectionForReadCommand origNssCtx(opCtx, origNss); // Resolve the collator to either the user-specified collation or the default // collation of the collection on which $changeStream was invoked, so that we do not // end up resolving the collation on the oplog. invariant(!collatorToUse); if (!origNssCtx.getDb() && !request.isFromMongos()) { AutoGetOrCreateDb dbLock(opCtx, origNss.db(), MODE_X); invariant(dbLock.getDb()); } Collection* origColl = origNssCtx.getCollection(); collatorToUse.emplace(resolveCollator(opCtx, request, origColl));