Skip to content

Commit 8b139ff

Browse files
committed
PSMDB-1078: fix TemporaryRecordStoreSimple test to handle ObjectIsBusy from dropIdent
The TemporaryRecordStoreSimple test can fail when dropIdent() returns ErrorCodes::ObjectIsBusy, which occurs when the ident is temporarily in use. This is a transient condition that should be retried. This change adds retry logic to the test, retrying dropIdent() until it succeeds when ObjectIsBusy is returned. This matches the pattern used in production code (e.g. WiredTigerKVEngine::dropIdentForImport).
1 parent 993af6f commit 8b139ff

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/mongo/db/storage/kv/kv_engine_test_harness.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,15 @@ TEST_F(KVEngineTestHarness, TemporaryRecordStoreSimple) {
389389
engine->checkpoint();
390390

391391
WriteUnitOfWork wuow(opCtx.get());
392-
ASSERT_OK(engine->dropIdent(shard_role_details::getRecoveryUnit(opCtx.get()), ident));
392+
393+
// Drop the temporary record store in a loop in case it returns ErrorCodes::ObjectIsBusy
394+
Status status = Status::OK();
395+
do {
396+
std::this_thread::yield();
397+
status = engine->dropIdent(shard_role_details::getRecoveryUnit(opCtx.get()), ident);
398+
ASSERT(status.isOK() || status == ErrorCodes::ObjectIsBusy);
399+
} while (status == ErrorCodes::ObjectIsBusy);
400+
393401
wuow.commit();
394402
}
395403
}
@@ -1250,8 +1258,7 @@ TEST_F(DurableCatalogTest, Idx1) {
12501258
md.nss = NamespaceString::createNamespaceString_forTest(boost::none, "a.b");
12511259

12521260
BSONCollectionCatalogEntry::IndexMetaData imd;
1253-
imd.spec = BSON("name"
1254-
<< "foo");
1261+
imd.spec = BSON("name" << "foo");
12551262
imd.ready = false;
12561263
imd.multikey = false;
12571264
imd.isBackgroundSecondaryBuild = false;
@@ -1285,8 +1292,7 @@ TEST_F(DurableCatalogTest, Idx1) {
12851292
putMetaData(opCtx, catalog.get(), catalogId, md); // remove index
12861293

12871294
BSONCollectionCatalogEntry::IndexMetaData imd;
1288-
imd.spec = BSON("name"
1289-
<< "foo");
1295+
imd.spec = BSON("name" << "foo");
12901296
imd.ready = false;
12911297
imd.multikey = false;
12921298
imd.isBackgroundSecondaryBuild = false;
@@ -1347,8 +1353,7 @@ TEST_F(DurableCatalogTest, DirectoryPerDb1) {
13471353
md.nss = NamespaceString::createNamespaceString_forTest(boost::none, "a.b");
13481354

13491355
BSONCollectionCatalogEntry::IndexMetaData imd;
1350-
imd.spec = BSON("name"
1351-
<< "foo");
1356+
imd.spec = BSON("name" << "foo");
13521357
imd.ready = false;
13531358
imd.multikey = false;
13541359
imd.isBackgroundSecondaryBuild = false;
@@ -1406,8 +1411,7 @@ TEST_F(DurableCatalogTest, Split1) {
14061411
md.nss = NamespaceString::createNamespaceString_forTest(boost::none, "a.b");
14071412

14081413
BSONCollectionCatalogEntry::IndexMetaData imd;
1409-
imd.spec = BSON("name"
1410-
<< "foo");
1414+
imd.spec = BSON("name" << "foo");
14111415
imd.ready = false;
14121416
imd.multikey = false;
14131417
imd.isBackgroundSecondaryBuild = false;
@@ -1465,8 +1469,7 @@ TEST_F(DurableCatalogTest, DirectoryPerAndSplit1) {
14651469
md.nss = NamespaceString::createNamespaceString_forTest(boost::none, "a.b");
14661470

14671471
BSONCollectionCatalogEntry::IndexMetaData imd;
1468-
imd.spec = BSON("name"
1469-
<< "foo");
1472+
imd.spec = BSON("name" << "foo");
14701473
imd.ready = false;
14711474
imd.multikey = false;
14721475
imd.isBackgroundSecondaryBuild = false;
@@ -1529,10 +1532,7 @@ DEATH_TEST_REGEX_F(DurableCatalogTest,
15291532
uow.commit();
15301533
}
15311534

1532-
IndexDescriptor desc("",
1533-
BSON("v"
1534-
<< "1"
1535-
<< "key" << BSON("a" << 1)));
1535+
IndexDescriptor desc("", BSON("v" << "1" << "key" << BSON("a" << 1)));
15361536
std::unique_ptr<SortedDataInterface> sorted;
15371537
{
15381538
auto clientAndCtx = makeClientAndCtx("opCtx");

0 commit comments

Comments
 (0)