diff options
author | Didier Nadeau <didier.nadeau@mongodb.com> | 2023-03-21 15:10:52 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-03-21 16:23:42 +0000 |
commit | 29a46a5b729493121e2c22313f293d32d67c4537 (patch) | |
tree | 482f53d5a0bfb5a6afdb6de28494769ee1e57780 /src/mongo/db/catalog | |
parent | b138e8951449fad26e9e1f8a6f39d269c64e53da (diff) | |
download | mongo-29a46a5b729493121e2c22313f293d32d67c4537.tar.gz |
SERVER-72218 Garbage collect tenant data when shard merge aborts
Diffstat (limited to 'src/mongo/db/catalog')
-rw-r--r-- | src/mongo/db/catalog/database_impl.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index 3a46c9d4376..b650ba2c7f6 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -59,6 +59,7 @@ #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/replication_consistency_markers_impl.h" #include "mongo/db/repl/replication_coordinator.h" +#include "mongo/db/repl/tenant_migration_decoration.h" #include "mongo/db/s/collection_sharding_state.h" #include "mongo/db/s/database_sharding_state.h" #include "mongo/db/server_options.h" @@ -494,8 +495,14 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, OpObserver::CollectionDropType::kOnePhase, markFromMigrate); // OpObserver::onDropCollection should not be writing to the oplog on the secondary. - invariant(opTime.isNull(), - str::stream() << "OpTime is not null. OpTime: " << opTime.toString()); + // The exception is shard merge where, we perform unreplicated timestamped drops of + // imported collection on observing the state document update to aborted state via op + // observer, both on primary and secondaries. In such cases, on primary, we expect + // `opTime` equal to dropOpTime (i.e, state document update opTime). + invariant(opTime.isNull() || repl::tenantMigrationInfo(opCtx), + str::stream() + << "OpTime is not null or equal to dropOptime. OpTime: " + << opTime.toString() << " dropOpTime: " << dropOpTime.toString()); } return _finishDropCollection(opCtx, nss, collection.getWritableCollection(opCtx)); |