Operational Defect Database

BugZero found this defect 18 days ago.

MongoDB | 2658852

Dropping collection via direct connection can cause uuid inconsistencies

Last update date:

5/1/2024

Affected products:

MongoDB Server

Affected releases:

8.0.0-rc0

8.1.0-rc0

Fixed releases:

No fixed releases provided.

Description:

Info

Given a replica set with a direct connection on it, once the replica-set is added to the cluster the collections in it will be registered to the CSRS. However, if the direct connection is not dropped, dropping the collection via direct connection and re-creating it via mongos will cause a uuid inconsistency The createCollectionCoordinator relies that the collection is always present both on the local catalog of the primary and on the sharding catalog. In this case, the coordinator believes the collection does not exists because it's not present locally. It will proceed to create locally a new collection with a different uuid.  During the commit phase, it will fail to upsert the previous collection as the new uuid is used to find the existing document

Top User Comments


Steps to Reproduce

const st = new ShardingTest({shards: 0}); const replShard = new ReplSetTest({name: "shard1", nodes: 3}); const dbName = "test" replShard.startSet({verbose: 1}); replShard.initiate(); jsTestLog("Creating a collection via direct connection."); replShard.getPrimary().getDB(dbName).createCollection("x"); jsTestLog("Adding replica set as shard."); // Restarting secondaries with --shardsvr const secondaries = replShard.getSecondaries(); secondaries.forEach(secondary => { replShard.restart(secondary, \{shardsvr: ''} ); }); // Restarting primary with --shardsvr and waiting for new primary let primary = replShard.getPrimary(); replShard.restart(primary, {shardsvr: ''}); replShard.awaitNodesAgreeOnPrimary(); assert.commandWorked(st.s.adminCommand({addShard: replShard.getURL()})); jsTestLog("Dropping the collection via direct connection.") replShard.getPrimary().getDB(dbName).x.drop() jsTestLog("Re-creating the collection via mongos will now cause an inconsistency.") st.s.getDB(dbName).createCollection("x") jsTestLog("Run rename via mongos which provides some consistency checks.") assert.commandWorked(st.s.getDB(dbName).x.renameCollection({to: "y", dropTarget: false})) st.stop(); replShard.stopSet();

Additional Resources / Links

Share:

BugZero® Risk Score

What's this?

Coming soon

Status

Needs Scheduling

Learn More

Search:

...