diff options
author | Jason Chan <jason.chan@mongodb.com> | 2021-03-19 17:29:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-07 15:17:31 +0000 |
commit | 09644d5d2104b54e5c38b73518fdf37becbb6eb4 (patch) | |
tree | 41f719b973777791473986f41c941c27934a15de /src/mongo/db/repl | |
parent | d74202328ec4394fa9bfba22749c9f5a188e110f (diff) | |
download | mongo-09644d5d2104b54e5c38b73518fdf37becbb6eb4.tar.gz |
SERVER-55360 Fix race in creating TenantMigrationRecipient namespace collection in TenantMigrationRecipientServiceTest
(cherry picked from commit a742fad3f4a9376a665fb359971f0457e5dcc101)
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/tenant_migration_recipient_service_test.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp index 3ead92bb258..019467c5b49 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp @@ -3473,8 +3473,13 @@ TEST_F(TenantMigrationRecipientServiceTest, IncrementNumRestartsDueToRecipientFa CollectionOptions collectionOptions; collectionOptions.uuid = UUID::gen(); auto storage = StorageInterface::get(opCtx->getServiceContext()); - ASSERT_OK(storage->createCollection( - opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, collectionOptions)); + const auto status = storage->createCollection( + opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, collectionOptions); + if (!status.isOK()) { + // It's possible to race with the test fixture setup in creating the tenant recipient + // collection. + ASSERT_EQ(ErrorCodes::NamespaceExists, status.code()); + } ASSERT_OK(storage->insertDocument(opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, {initialStateDocument.toBSON()}, @@ -3520,8 +3525,13 @@ TEST_F(TenantMigrationRecipientServiceTest, CollectionOptions collectionOptions; collectionOptions.uuid = UUID::gen(); auto storage = StorageInterface::get(opCtx->getServiceContext()); - ASSERT_OK(storage->createCollection( - opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, collectionOptions)); + const auto status = storage->createCollection( + opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, collectionOptions); + if (!status.isOK()) { + // It's possible to race with the test fixture setup in creating the tenant recipient + // collection. + ASSERT_EQ(ErrorCodes::NamespaceExists, status.code()); + } ASSERT_OK(storage->insertDocument(opCtx.get(), NamespaceString::kTenantMigrationRecipientsNamespace, {initialStateDocument.toBSON()}, |