[SERVER-60268] Reintroduce ComparableDatabaseVersion::_uuidDisambiguatingSequenceNum Created: 28/Sep/21  Updated: 29/Oct/23  Resolved: 04/Oct/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.1.0
Fix Version/s: 5.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Pierlauro Sciarelli Assignee: Sergi Mateo Bellido
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Sprint: Sharding EMEA 2021-10-04
Participants:
Linked BF Score: 127

 Description   

As result of the removal of ComparableDatabaseVersion::_uuidDisambiguatingSequenceNum under SERVER-59177, it is currently possible for the catalog cache to end up in an infinite loop since the timeInStore of a cached entry is considered greater than the time in store associated with a non-existing db.

Unit test to reproduce the issue (by sergi.mateo-bellido):

TEST_F(CatalogCacheTest, GetDatabaseDropLoop) {
    const auto dbName = "testDB";
    const auto dbVersion = DatabaseVersion(UUID::gen(), Timestamp());
 
    _catalogCacheLoader->setDatabaseRefreshReturnValue(
        DatabaseType(dbName, kShards[0], true, dbVersion));
 
    // The CatalogCache doesn't have any valid info about this DB and finds a new DatabaseType
    auto swDatabase = _catalogCache->getDatabase(operationContext(), dbName);
 
    ASSERT_OK(swDatabase.getStatus());
    const auto cachedDb = swDatabase.getValue();
    ASSERT_TRUE(cachedDb.shardingEnabled());
    ASSERT_EQ(cachedDb.databaseVersion().getUuid(), dbVersion.getUuid());
    ASSERT_EQ(cachedDb.databaseVersion().getLastMod(), dbVersion.getLastMod());
 
    // Advancing the timeInStore, e.g. because of a movePrimary
    _catalogCache->onStaleDatabaseVersion(dbName, dbVersion.makeUpdated());
 
    // However, when this CatalogCache asks to the loader for the new info associated to dbName it
    // didn't find any (i.e. the database was dropped)
    _catalogCacheLoader->setDatabaseRefreshReturnValue(
        Status(ErrorCodes::NamespaceNotFound, "dummy errmsg"));
 
    // At the end of this refresh we compute a new time of (boost::none, 1), which is going to be
    // less than the time in store we associated with this refresh (i.e. the DB version after the
    // movePrimary). Because of this bug, we will never be able to fulfill any promise, hanging in
    // the refresh loop forever.
    swDatabase = _catalogCache->getDatabase(operationContext(), dbName);
}

 



 Comments   
Comment by Vivian Ge (Inactive) [ 06/Oct/21 ]

Updating the fixversion since branching activities occurred yesterday. This ticket will be in rc0 when it’s been triggered. For more active release information, please keep an eye on #server-release. Thank you!

Comment by Githook User [ 04/Oct/21 ]

Author:

{'name': 'Sergi Mateo Bellido', 'email': 'sergi.mateo-bellido@mongodb.com', 'username': 'smateo'}

Message: SERVER-60268 Reintroduce disambiguationg sequence number
Branch: master
https://github.com/mongodb/mongo/commit/3008af2319af2098f4691612f31a431c52ccc52c

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