[SERVER-32532] Two-phase dropDatabase may not replicate all collection drops before the database drop. Created: 03/Jan/18  Updated: 30/Oct/23  Resolved: 04/Jan/18

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: 3.6.0
Fix Version/s: 3.6.3, 3.7.1

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

Issue Links:
Backports
Related
related to SERVER-32251 dropCollection/dropDatabase must be t... Closed
is related to SERVER-29277 Two Phase Drops: implement dropDataba... Closed
is related to SERVER-32534 Have UnorderedFastKeyTable iterators ... Closed
Backwards Compatibility: Fully Compatible
Sprint: Repl 2018-01-15
Participants:

 Description   

The first phase of dropDatabase (for replicate sets) in 3.6 is to individually drop each collection (drop in this first phase is a misnomer for rename). When those "drops" are majority confirmed, the primary replicates a dropDatabase oplog entry.

However the loop uses an iterator over the _collections map and db->dropCollectionEvenIfSystem will perform a rename. This rename erases the entry followed by adding it back under a different name. The expectation of the for-each collection loop is that all collections will be observed. The erase/add of the underlying map breaks that requirement.

This can result in some collections not being dropped on the primary nor the secondary in the first part of dropping a database. I do believe the second phase of dropping a database that's associated with the dropDatabase oplog entry will be renamed and/or dropped on both the primary and secondary.

One possible fix is to copy the values from the map to iterate over instead.



 Comments   
Comment by Githook User [ 10/Jan/18 ]

Author:

{'email': 'benety@mongodb.com', 'name': 'Benety Goh', 'username': 'benety'}

Message: SERVER-32532 dropDatabase() drops collections in separate loop after gathering namespaces to drop

(cherry picked from commit a7cdfa8d4567bda72fd3475daacf9724d333bac4)
Branch: v3.6
https://github.com/mongodb/mongo/commit/a4ad1ebc507b95dc33ab3b538fd45bf2571936e3

Comment by Githook User [ 04/Jan/18 ]

Author:

{'name': 'Benety Goh', 'username': 'benety', 'email': 'benety@mongodb.com'}

Message: SERVER-32532 dropDatabase() drops collections in separate loop after gathering namespaces to drop
Branch: master
https://github.com/mongodb/mongo/commit/a7cdfa8d4567bda72fd3475daacf9724d333bac4

Generated at Thu Feb 08 04:30:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.