diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/db/commands/fsync.cpp | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/db/commands/fsync.cpp')
| -rw-r--r-- | src/mongo/db/commands/fsync.cpp | 83 |
1 files changed, 8 insertions, 75 deletions
diff --git a/src/mongo/db/commands/fsync.cpp b/src/mongo/db/commands/fsync.cpp index 35ae6323188..f1d92aa636a 100644 --- a/src/mongo/db/commands/fsync.cpp +++ b/src/mongo/db/commands/fsync.cpp @@ -47,13 +47,11 @@ #include "mongo/db/commands.h" #include "mongo/db/commands/fsync_locked.h" #include "mongo/db/concurrency/d_concurrency.h" -#include "mongo/db/concurrency/exception_util.h" -#include "mongo/db/dbdirectclient.h" +#include "mongo/db/concurrency/write_conflict_exception.h" #include "mongo/db/service_context.h" #include "mongo/db/storage/backup_cursor_hooks.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/logv2/log.h" -#include "mongo/s/sharding_feature_flags_gen.h" #include "mongo/stdx/condition_variable.h" #include "mongo/util/assert_util.h" #include "mongo/util/background.h" @@ -71,13 +69,10 @@ Lock::ResourceMutex commandMutex("fsyncCommandMutex"); */ class FSyncLockThread : public BackgroundJob { public: - FSyncLockThread(ServiceContext* serviceContext, - bool allowFsyncFailure, - const Milliseconds deadline) + FSyncLockThread(ServiceContext* serviceContext, bool allowFsyncFailure) : BackgroundJob(false), _serviceContext(serviceContext), - _allowFsyncFailure(allowFsyncFailure), - _deadline(deadline) {} + _allowFsyncFailure(allowFsyncFailure) {} std::string name() const override { return "FSyncLockThread"; @@ -89,7 +84,6 @@ private: ServiceContext* const _serviceContext; bool _allowFsyncFailure; static bool _shutdownTaskRegistered; - const Milliseconds _deadline; }; class FSyncCommand : public ErrmsgCommandDeprecated { @@ -131,20 +125,6 @@ public: actions.addAction(ActionType::fsync); out->push_back(Privilege(ResourcePattern::forClusterResource(), actions)); } - - virtual void checkForInProgressDDLOperations(OperationContext* opCtx) { - DBDirectClient client(opCtx); - const auto numDDLDocuments = - client.count(NamespaceString::kShardingDDLCoordinatorsNamespace); - - if (numDDLDocuments != 0) { - LOGV2_WARNING(781541, "Cannot take lock while DDL operations is in progress"); - releaseLock(); - uasserted(ErrorCodes::IllegalOperation, - "Cannot take lock while DDL operation is in progress"); - } - } - virtual bool errmsgRun(OperationContext* opCtx, const std::string& dbname, const BSONObj& cmdObj, @@ -156,12 +136,7 @@ public: } const bool lock = cmdObj["lock"].trueValue(); - const bool forBackup = cmdObj["forBackup"].trueValue(); - LOGV2(20461, - "CMD fsync: lock:{lock}", - "CMD fsync", - "lock"_attr = lock, - "forBackup"_attr = forBackup); + LOGV2(20461, "CMD fsync: lock:{lock}", "CMD fsync", "lock"_attr = lock); // fsync + lock is sometimes used to block writes out of the system and does not care if // the `BackupCursorService::fsyncLock` call succeeds. @@ -193,23 +168,8 @@ public: stdx::unique_lock<Latch> lk(lockStateMutex); threadStatus = Status::OK(); threadStarted = false; - - Milliseconds deadline = Milliseconds::max(); - if (forBackup) { - // Set a default deadline of 90s for the fsyncLock to be acquired. - deadline = Milliseconds(90000); - // Parse the cmdObj and update the deadline if - // "fsyncLockAcquisitionTimeoutMillis" exists. - for (const auto& elem : cmdObj) { - if (elem.fieldNameStringData() == "fsyncLockAcquisitionTimeoutMillis") { - deadline = Milliseconds{uassertStatusOK(parseMaxTimeMS(elem))}; - } - } - } - - _lockThread = std::make_unique<FSyncLockThread>( - opCtx->getServiceContext(), allowFsyncFailure, deadline); - + _lockThread = std::make_unique<FSyncLockThread>(opCtx->getServiceContext(), + allowFsyncFailure); _lockThread->go(); while (!threadStarted && threadStatus.isOK()) { @@ -229,13 +189,6 @@ public: } } - if (forBackup) { - // The check must be performed only if the fsync+lock command has been issued for backup - // purposes (through monogs). There are valid cases where fsync+lock can be invoked on - // the mongod while DDLs are in progress. - checkForInProgressDDLOperations(opCtx); - } - LOGV2(20462, "mongod is locked and no writes are allowed. db.fsyncUnlock() to unlock, " "lock count is {lockCount}, for more info see {seeAlso}", @@ -396,18 +349,7 @@ void FSyncLockThread::run() { try { const ServiceContext::UniqueOperationContext opCtxPtr = cc().makeOperationContext(); OperationContext& opCtx = *opCtxPtr; - - // If the deadline exists, set it on the opCtx and GlobalRead lock. - Date_t lockDeadline = Date_t::max(); - if (_deadline < Milliseconds::max()) { - lockDeadline = Date_t::now() + _deadline; - } - - opCtx.setDeadlineAfterNowBy(Milliseconds(_deadline), ErrorCodes::ExceededTimeLimit); - Lock::GlobalRead global( - &opCtx, - lockDeadline, - Lock::InterruptBehavior::kThrow); // Block any writes in order to flush the files. + Lock::GlobalRead global(&opCtx); // Block any writes in order to flush the files. StorageEngine* storageEngine = _serviceContext->getStorageEngine(); @@ -497,16 +439,7 @@ void FSyncLockThread::run() { storageEngine->endBackup(&opCtx); } } - } catch (const ExceptionForCat<ErrorCategory::ExceededTimeLimitError>&) { - LOGV2_ERROR(204739, "Fsync timed out with ExceededTimeLimitError"); - fsyncCmd.threadStatus = Status(ErrorCodes::Error::LockTimeout, "Fsync lock timed out"); - fsyncCmd.acquireFsyncLockSyncCV.notify_one(); - return; - } catch (const ExceptionFor<ErrorCodes::LockTimeout>&) { - LOGV2_ERROR(204740, "Fsync timed out with LockTimeout"); - fsyncCmd.threadStatus = Status(ErrorCodes::Error::LockTimeout, "Fsync lock timed out"); - fsyncCmd.acquireFsyncLockSyncCV.notify_one(); - return; + } catch (const std::exception& e) { LOGV2_FATAL(40350, "FSyncLockThread exception: {error}", |
