[SERVER-43402] Secondary oplog can have entry to create a same name but different capitalized database before dropping the old one Created: 20/Sep/19  Updated: 29/Oct/23  Resolved: 01/Oct/19

Status: Closed
Project: Core Server
Component/s: Catalog
Affects Version/s: None
Fix Version/s: 4.3.1, 4.2.2

Type: Bug Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Gregory Wlodarek
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.2
Steps To Reproduce:

resmoke --suites=replica_sets test.js

(function() {
    'use strict';
 
    load("jstests/libs/check_log.js");
 
    const rst = new ReplSetTest({nodes: [{}, {rsConfig: {priority: 0}}]});
    rst.startSet();
    rst.initiate();
 
    const dbNameUpper = "A";
    const dbNameLower = "a";
 
    const primary = rst.getPrimary();
 
    let upperDB = primary.getDB(dbNameUpper);
    assert.commandWorked(upperDB.createCollection("test"));
 
    assert.commandWorked(
        upperDB.adminCommand({configureFailPoint: 'dropDatabaseHangBeforeLog', mode: "alwaysOn"}));
    let awaitDropUpper = startParallelShell(() => {
        db.getSiblingDB("A").dropDatabase();
    }, primary.port);
 
    checkLog.contains(primary, "dropDatabase - fail point dropDatabaseHangBeforeLog enabled.");
 
    let lowerDB = primary.getDB(dbNameLower);
    assert.commandWorked(lowerDB.createCollection("test"));
 
    rst.awaitReplication();
 
 
    assert.commandWorked(
        lowerDB.adminCommand({configureFailPoint: 'dropDatabaseHangBeforeLog', mode: "alwaysOn"}));
    awaitDropUpper();
 
    rst.stopSet();
})();

Sprint: Execution Team 2019-10-07
Participants:
Linked BF Score: 10

 Description   

This started occurring in our testing when the exclusive global locks were removed in dropDatabase() here.

The secondaries oplog can have oplog entries to create the same name but differently capitalized database name prior to running the oplog entry to drop the older database.

In this code, there's a small window between the dropDb() call and creating the oplog entry for secondaries where a create database command on the same name but different capitalization can occur causing the createDb oplog entry to get sent to secondaries before the dropDb oplog entry. The secondary will try to create the database, but will fassert because another database with the same name but different capitalization still exists.



 Comments   
Comment by Githook User [ 16/Oct/19 ]

Author:

{'name': 'Gregory Wlodarek', 'username': 'GWlodarek', 'email': 'gregory.wlodarek@mongodb.com'}

Message: SERVER-43402 dropDatabase should send drop database oplog entry prior to dropping in memory state of database

(cherry picked from commit 15c6c085126f5d459f30191ef736c10607bea3f6)
Branch: v4.2
https://github.com/mongodb/mongo/commit/70493f051ac24c15a2fdc88e51b0625c471d6893

Comment by Githook User [ 01/Oct/19 ]

Author:

{'username': 'GWlodarek', 'email': 'gregory.wlodarek@mongodb.com', 'name': 'Gregory Wlodarek'}

Message: SERVER-43402 dropDatabase should send drop database oplog entry prior to dropping in memory state of database
Branch: master
https://github.com/mongodb/mongo/commit/15c6c085126f5d459f30191ef736c10607bea3f6

Comment by Gregory Wlodarek [ 27/Sep/19 ]

After discussing with daniel.gottlieb and geert.bosch, we've decided that we're going to call dropDb() in an onCommit() hook once the onDropDatabase() runs and gets committed.

Comment by Gregory Wlodarek [ 27/Sep/19 ]

Verified with daniel.gottlieb that the ticket xiangyu.yao has (SERVER-43352) will not fix this issue.

Comment by Dianna Hohensee (Inactive) [ 27/Sep/19 ]

Xiangyu has a ticket that might fix this problem: should be explored, or wait.

Generated at Thu Feb 08 05:03:06 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.