summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@mongodb.com>2019-10-07 13:17:41 +0000
committerevergreen <evergreen@mongodb.com>2019-10-07 13:17:41 +0000
commit715b58332fb92273af1e0ec2c3e7b3ae1f59b119 (patch)
tree1eba098e581d9c2289a93130bb824d4642725197 /src
parent21d8699ed6c517b45e1613e20231cd8eba894985 (diff)
downloadmongo-715b58332fb92273af1e0ec2c3e7b3ae1f59b119.tar.gz
SERVER-43828 We must hold the CheckpointLock around calls to WT compact() because WT does checkpoint'ing during compact operations
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp4
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp3
2 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
index e8b74cb5193..549475c368e 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_index.cpp
@@ -481,6 +481,10 @@ Status WiredTigerIndex::compact(OperationContext* opCtx) {
if (!cache->isEphemeral()) {
WT_SESSION* s = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession();
opCtx->recoveryUnit()->abandonSnapshot();
+ // WT compact prompts WT to take checkpoints, so we need to take the checkpoint lock around
+ // WT compact calls.
+ auto checkpointLock =
+ opCtx->getServiceContext()->getStorageEngine()->getCheckpointLock(opCtx);
int ret = s->compact(s, uri().c_str(), "timeout=0");
invariantWTOK(ret);
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
index 45abc3f224d..6defe16f35e 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_record_store.cpp
@@ -1506,6 +1506,9 @@ Status WiredTigerRecordStore::compact(OperationContext* opCtx) {
if (!cache->isEphemeral()) {
WT_SESSION* s = WiredTigerRecoveryUnit::get(opCtx)->getSession()->getSession();
opCtx->recoveryUnit()->abandonSnapshot();
+ // WT compact prompts WT to take checkpoints, so we need to take the checkpoint lock around
+ // WT compact calls.
+ auto checkpointLock = _kvEngine->getCheckpointLock(opCtx);
int ret = s->compact(s, getURI().c_str(), "timeout=0");
invariantWTOK(ret);
}