diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2021-01-11 14:18:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-14 18:16:50 +0000 |
commit | cdc4375148c283672faf4364fe2a73e0cfeebc37 (patch) | |
tree | 0c9e42a58ddab5832c6e9126f157dc3ccff0850d /src/mongo/db | |
parent | fa5792bdc5408340489475b1f3bf5b8d709ebc20 (diff) | |
download | mongo-cdc4375148c283672faf4364fe2a73e0cfeebc37.tar.gz |
SERVER-46876 Compaction interrupts on EBUSY
(cherry picked from commit 0ce2fa7273aa7f4c7170c1bba3944efe46b4f043)
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp | 10 | ||||
-rw-r--r-- | src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp | 10 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp index b1021a7dd43..c7acddc84e8 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp @@ -75,6 +75,7 @@ namespace mongo { namespace { +MONGO_FAIL_POINT_DEFINE(WTCompactIndexEBUSY); MONGO_FAIL_POINT_DEFINE(WTEmulateOutOfOrderNextIndexKey); using std::string; @@ -537,6 +538,15 @@ Status WiredTigerIndex::compact(OperationContext* opCtx) { WT_SESSION* s = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession(); opCtx->recoveryUnit()->abandonSnapshot(); int ret = s->compact(s, uri().c_str(), "timeout=0"); + if (MONGO_unlikely(WTCompactIndexEBUSY.shouldFail())) { + ret = EBUSY; + } + + if (ret == EBUSY) { + return Status(ErrorCodes::Interrupted, + str::stream() << "Compaction interrupted on " << uri().c_str() + << " due to cache eviction pressure"); + } invariantWTOK(ret); } return Status::OK(); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp index aadd47ce543..f5873ff5249 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp @@ -91,6 +91,7 @@ void checkOplogFormatVersion(OperationContext* opCtx, const std::string& uri) { } } // namespace +MONGO_FAIL_POINT_DEFINE(WTCompactRecordStoreEBUSY); MONGO_FAIL_POINT_DEFINE(WTWriteConflictException); MONGO_FAIL_POINT_DEFINE(WTWriteConflictExceptionForReads); @@ -1554,6 +1555,15 @@ Status WiredTigerRecordStore::compact(OperationContext* opCtx) { WT_SESSION* s = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession(); opCtx->recoveryUnit()->abandonSnapshot(); int ret = s->compact(s, getURI().c_str(), "timeout=0"); + if (MONGO_unlikely(WTCompactRecordStoreEBUSY.shouldFail())) { + ret = EBUSY; + } + + if (ret == EBUSY) { + return Status(ErrorCodes::Interrupted, + str::stream() << "Compaction interrupted on " << getURI().c_str() + << " due to cache eviction pressure"); + } invariantWTOK(ret); } return Status::OK(); |