Info
Since SERVER-29277, the dropDatabase waits for all collection drops to complete before removing the entry for the database from the catalog. To do this, the free function mongo::dropDatabase() needs to call either ReplicationCoordinator::awaitReplicationOfLastOpForClient() or ReplicationCoordinator::awaitReplication(). However, these functions fail when dropDatabase() is called from within an applyOps operation because applyOps executes all its given operations while holding the global lock.
To reproduce:
db.adminCommand({applyOps: [{op: 'c', ns: 'test.$cmd', o: {create: 't'}}, {op: 'c', ns: 'test.$cmd', o: {drop: 't'}}, {op: 'c', ns: 'test.$cmd', o: {dropDatabase: 1}}]})
Top User Comments
xgen-internal-githook commented on Thu, 29 Jun 2017 19:12:28 +0000:
Author:
{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}
Message: SERVER-29874 dropDatabase() releases locks when awaiting replication
This allows dropDatabase() to work with applyOps when we have to wait for
collection drops to replicate
Branch: master
https://github.com/mongodb/mongo/commit/57e3704f443df1fb071e0af81421ce2999fad767