diff options
Diffstat (limited to 'src/mongo/db/s/shard_server_op_observer.cpp')
| -rw-r--r-- | src/mongo/db/s/shard_server_op_observer.cpp | 57 |
1 files changed, 9 insertions, 48 deletions
diff --git a/src/mongo/db/s/shard_server_op_observer.cpp b/src/mongo/db/s/shard_server_op_observer.cpp index a374159bc87..228ef5ffbb9 100644 --- a/src/mongo/db/s/shard_server_op_observer.cpp +++ b/src/mongo/db/s/shard_server_op_observer.cpp @@ -80,10 +80,8 @@ bool isStandaloneOrPrimary(OperationContext* opCtx) { */ class CollectionVersionLogOpHandler final : public RecoveryUnit::Change { public: - CollectionVersionLogOpHandler(OperationContext* opCtx, - const NamespaceString& nss, - bool droppingCollection) - : _opCtx(opCtx), _nss(nss), _droppingCollection(droppingCollection) {} + CollectionVersionLogOpHandler(OperationContext* opCtx, const NamespaceString& nss) + : _opCtx(opCtx), _nss(nss) {} void commit(boost::optional<Timestamp>) override { invariant(_opCtx->lockState()->isCollectionLockedForMode(_nss, MODE_IX)); @@ -93,11 +91,7 @@ public: // Force subsequent uses of the namespace to refresh the filtering metadata so they can // synchronize with any work happening on the primary (e.g., migration critical section). UninterruptibleLockGuard noInterrupt(_opCtx->lockState()); - if (_droppingCollection) - CollectionShardingRuntime::get(_opCtx, _nss) - ->clearFilteringMetadataForDroppedCollection(_opCtx); - else - CollectionShardingRuntime::get(_opCtx, _nss)->clearFilteringMetadata(_opCtx); + CollectionShardingRuntime::get(_opCtx, _nss)->clearFilteringMetadata(_opCtx); } void rollback() override {} @@ -105,7 +99,6 @@ public: private: OperationContext* _opCtx; const NamespaceString _nss; - const bool _droppingCollection; }; /** @@ -157,8 +150,8 @@ void onConfigDeleteInvalidateCachedCollectionMetadataAndNotify(OperationContext* AllowLockAcquisitionOnTimestampedUnitOfWork allowLockAcquisition(opCtx->lockState()); AutoGetCollection autoColl(opCtx, deletedNss, MODE_IX); - opCtx->recoveryUnit()->registerChange(std::make_unique<CollectionVersionLogOpHandler>( - opCtx, deletedNss, /* droppingCollection */ true)); + opCtx->recoveryUnit()->registerChange( + std::make_unique<CollectionVersionLogOpHandler>(opCtx, deletedNss)); } /** @@ -196,9 +189,7 @@ void incrementChunkOnInsertOrUpdate(OperationContext* opCtx, return balancerConfig->getMaxChunkSizeBytes(); }(); - if (!feature_flags::gNoMoreAutoSplitter.isEnabled( - serverGlobalParams.featureCompatibility) && - balancerConfig->getShouldAutoSplit() && chunkManager.allowAutoSplit() && + if (balancerConfig->getShouldAutoSplit() && chunkManager.allowAutoSplit() && chunkWritesTracker->shouldSplit(maxChunkSizeBytes)) { auto chunkSplitStateDriver = ChunkSplitStateDriver::tryInitiateSplit(chunkWritesTracker); @@ -361,8 +352,8 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE AllowLockAcquisitionOnTimestampedUnitOfWork allowLockAcquisition(opCtx->lockState()); AutoGetCollection autoColl(opCtx, updatedNss, MODE_IX); if (refreshingFieldNewVal.isBoolean() && !refreshingFieldNewVal.boolean()) { - opCtx->recoveryUnit()->registerChange(std::make_unique<CollectionVersionLogOpHandler>( - opCtx, updatedNss, /* droppingCollection */ false)); + opCtx->recoveryUnit()->registerChange( + std::make_unique<CollectionVersionLogOpHandler>(opCtx, updatedNss)); } if (enterCriticalSectionFieldNewVal.ok()) { @@ -399,13 +390,9 @@ void ShardServerOpObserver::onUpdate(OperationContext* opCtx, const OplogUpdateE // TODO SERVER-58223: evaluate whether this is safe or whether acquiring the lock can // block. AllowLockAcquisitionOnTimestampedUnitOfWork allowLockAcquisition(opCtx->lockState()); - AutoGetDb autoDb(opCtx, db, MODE_X); auto dss = DatabaseShardingState::get(opCtx, db); dss->clearDatabaseInfo(opCtx); - - const auto dssLock = DatabaseShardingState::DSSLock::lockExclusive(opCtx, dss); - dss->cancelDbMetadataRefresh(dssLock); } } @@ -500,13 +487,9 @@ void ShardServerOpObserver::onDelete(OperationContext* opCtx, // TODO SERVER-58223: evaluate whether this is safe or whether acquiring the lock can block. AllowLockAcquisitionOnTimestampedUnitOfWork allowLockAcquisition(opCtx->lockState()); - AutoGetDb autoDb(opCtx, deletedDatabase, MODE_X); auto dss = DatabaseShardingState::get(opCtx, deletedDatabase); dss->clearDatabaseInfo(opCtx); - - const auto dssLock = DatabaseShardingState::DSSLock::lockExclusive(opCtx, dss); - dss->cancelDbMetadataRefresh(dssLock); } if (nss == NamespaceString::kServerConfigurationNamespace) { @@ -588,7 +571,6 @@ void ShardServerOpObserver::onCreateCollection(OperationContext* opCtx, const OplogSlot& createOpTime, bool fromMigrate) { // Only the shard primay nodes control the collection creation and secondaries just follow - // Secondaries CSR will be the defaulted one (UNKNOWN in most of the cases) if (!opCtx->writesAreReplicated()) { return; } @@ -615,9 +597,7 @@ void ShardServerOpObserver::onCreateCollection(OperationContext* opCtx, // If the check above passes, this means the collection doesn't exist and is being created and // that the caller will be responsible to eventially set the proper shard version auto* const csr = CollectionShardingRuntime::get(opCtx, collectionName); - if (oss._forceCSRAsUnknownAfterCollectionCreation) { - csr->clearFilteringMetadata(opCtx); - } else if (!csr->getCurrentMetadataIfKnown()) { + if (!csr->getCurrentMetadataIfKnown()) { csr->setFilteringMetadata(opCtx, CollectionMetadata()); } } @@ -644,14 +624,6 @@ repl::OpTime ShardServerOpObserver::onDropCollection(OperationContext* opCtx, return {}; } -void ShardServerOpObserver::onCreateIndex(OperationContext* opCtx, - const NamespaceString& nss, - const UUID& uuid, - BSONObj indexDoc, - bool fromMigrate) { - abortOngoingMigrationIfNeeded(opCtx, nss); -} - void ShardServerOpObserver::onStartIndexBuild(OperationContext* opCtx, const NamespaceString& nss, const UUID& collUUID, @@ -694,17 +666,6 @@ void ShardServerOpObserver::_onReplicationRollback(OperationContext* opCtx, rbInfo.rollbackNamespaces.end()) { RecoverableCriticalSectionService::get(opCtx)->recoverRecoverableCriticalSections(opCtx); } - - // If writes to config.cache.collections or config.cache.* have been rolled back, interrupt - // the SSCCL to ensure secondary waits for replication do not use incorrect opTimes. - if (std::any_of(rbInfo.rollbackNamespaces.begin(), - rbInfo.rollbackNamespaces.end(), - [](const NamespaceString& nss) { - return nss == NamespaceString::kShardConfigCollectionsNamespace || - nss.isConfigDotCacheDotChunks(); - })) { - CatalogCacheLoader::get(opCtx).onReplicationRollback(); - } } |
