diff options
Diffstat (limited to 'src/mongo/db/commands/dbcheck.cpp')
-rw-r--r-- | src/mongo/db/commands/dbcheck.cpp | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/src/mongo/db/commands/dbcheck.cpp b/src/mongo/db/commands/dbcheck.cpp index f53d8b77ce7..70940c0e5ff 100644 --- a/src/mongo/db/commands/dbcheck.cpp +++ b/src/mongo/db/commands/dbcheck.cpp @@ -46,6 +46,7 @@ #include "mongo/db/repl/dbcheck.h" #include "mongo/db/repl/oplog.h" #include "mongo/db/repl/optime.h" +#include "mongo/db/write_concern_options.h" #include "mongo/util/background.h" #include "mongo/logv2/log.h" @@ -141,6 +142,7 @@ struct DbCheckCollectionInfo { int64_t maxBytesPerBatch; int64_t maxBatchTimeMillis; bool snapshotRead; + WriteConcernOptions writeConcern; }; /** @@ -179,7 +181,8 @@ std::unique_ptr<DbCheckRun> singleCollectionRun(OperationContext* opCtx, maxDocsPerBatch, maxBytesPerBatch, maxBatchTimeMillis, - invocation.getSnapshotRead()}; + invocation.getSnapshotRead(), + invocation.getBatchWriteConcern()}; auto result = std::make_unique<DbCheckRun>(); result->push_back(info); return result; @@ -213,7 +216,8 @@ std::unique_ptr<DbCheckRun> fullDatabaseRun(OperationContext* opCtx, maxDocsPerBatch, maxBytesPerBatch, maxBatchTimeMillis, - invocation.getSnapshotRead()}; + invocation.getSnapshotRead(), + invocation.getBatchWriteConcern()}; result->push_back(info); return true; }; @@ -394,32 +398,43 @@ private: OplogEntriesEnum::Batch, result.getStatus()); } - HealthLog::get(Client::getCurrent()->getServiceContext()).log(*entry); + HealthLog::get(opCtx).log(*entry); if (retryable) { continue; } return; - } else { - _batchesProcessed++; - auto stats = result.getValue(); - auto entry = dbCheckBatchEntry(info.nss, - stats.nDocs, - stats.nBytes, - stats.md5, - stats.md5, - start, - stats.lastKey, - stats.readTimestamp, - stats.time); - if (kDebugBuild || entry->getSeverity() != SeverityEnum::Info || - (_batchesProcessed % gDbCheckHealthLogEveryNBatches.load() == 0)) { - // On debug builds, health-log every batch result; on release builds, health-log - // every N batches. - HealthLog::get(Client::getCurrent()->getServiceContext()).log(*entry); - } } - auto stats = result.getValue(); + + _batchesProcessed++; + + const auto stats = result.getValue(); + auto entry = dbCheckBatchEntry(info.nss, + stats.nDocs, + stats.nBytes, + stats.md5, + stats.md5, + start, + stats.lastKey, + stats.readTimestamp, + stats.time); + if (kDebugBuild || entry->getSeverity() != SeverityEnum::Info || + (_batchesProcessed % gDbCheckHealthLogEveryNBatches.load() == 0)) { + // On debug builds, health-log every batch result; on release builds, health-log + // every N batches. + HealthLog::get(opCtx).log(*entry); + } + + WriteConcernResult unused; + auto status = waitForWriteConcern(opCtx, stats.time, info.writeConcern, &unused); + if (!status.isOK()) { + auto entry = dbCheckWarningHealthLogEntry(info.nss, + "dbCheck failed waiting for writeConcern", + OplogEntriesEnum::Batch, + status); + HealthLog::get(opCtx).log(*entry); + } + start = stats.lastKey; // Update our running totals. |