summaryrefslogtreecommitdiff
path: root/src/mongo/db/storage/kv
diff options
context:
space:
mode:
authorGregory Noma <gregory.noma@gmail.com>2020-06-09 10:05:41 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-09 14:32:47 +0000
commit514a8301fbe6919ced991942519459854c6cc570 (patch)
tree5c21a7ee2bfb9bc1af52f7e2147c08d2e62c3eda /src/mongo/db/storage/kv
parent9c270b00716f910d683cbdfd38b0ccec4db90af1 (diff)
downloadmongo-514a8301fbe6919ced991942519459854c6cc570.tar.gz
SERVER-48415 Write placeholder document to internal table on clean shutdown for resumable index builds
Diffstat (limited to 'src/mongo/db/storage/kv')
-rw-r--r--src/mongo/db/storage/kv/temporary_kv_record_store.cpp22
-rw-r--r--src/mongo/db/storage/kv/temporary_kv_record_store.h10
2 files changed, 24 insertions, 8 deletions
diff --git a/src/mongo/db/storage/kv/temporary_kv_record_store.cpp b/src/mongo/db/storage/kv/temporary_kv_record_store.cpp
index e92f24bf7bc..e1932356163 100644
--- a/src/mongo/db/storage/kv/temporary_kv_record_store.cpp
+++ b/src/mongo/db/storage/kv/temporary_kv_record_store.cpp
@@ -35,25 +35,37 @@
#include "mongo/db/operation_context.h"
#include "mongo/db/storage/kv/kv_engine.h"
+#include "mongo/logv2/log.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/str.h"
namespace mongo {
TemporaryKVRecordStore::~TemporaryKVRecordStore() {
- invariant(_recordStoreHasBeenDeleted);
+ invariant(_recordStoreHasBeenDeletedOrKept);
}
void TemporaryKVRecordStore::deleteTemporaryTable(OperationContext* opCtx) {
+ invariant(!_recordStoreHasBeenDeletedOrKept);
+
// Need at least Global IS before calling into the storage engine, to protect against it being
// destructed while we're using it.
invariant(opCtx->lockState()->isReadLocked());
auto status = _kvEngine->dropIdent(opCtx, opCtx->recoveryUnit(), _rs->getIdent());
- fassert(
- 51032,
- status.withContext(str::stream() << "failed to drop temporary ident: " << _rs->getIdent()));
- _recordStoreHasBeenDeleted = true;
+
+ if (!status.isOK()) {
+ LOGV2_ERROR(4841503, "Failed to drop temporary table", "ident"_attr = _rs->getIdent());
+ }
+ dassert(status, str::stream() << "Failed to drop temporary table. Ident: " << _rs->getIdent());
+
+ _recordStoreHasBeenDeletedOrKept = true;
+}
+
+void TemporaryKVRecordStore::keepTemporaryTable() {
+ invariant(!_recordStoreHasBeenDeletedOrKept);
+
+ _recordStoreHasBeenDeletedOrKept = true;
}
} // namespace mongo
diff --git a/src/mongo/db/storage/kv/temporary_kv_record_store.h b/src/mongo/db/storage/kv/temporary_kv_record_store.h
index f4b7c6033bd..27a2844b95d 100644
--- a/src/mongo/db/storage/kv/temporary_kv_record_store.h
+++ b/src/mongo/db/storage/kv/temporary_kv_record_store.h
@@ -39,8 +39,6 @@ class OperationContext;
/**
* Implementation of TemporaryRecordStore that manages a temporary RecordStore on a KVEngine.
- *
- * deleteTemporaryTable() must be called before destruction to delete the underlying RecordStore.
*/
class TemporaryKVRecordStore : public TemporaryRecordStore {
public:
@@ -62,9 +60,15 @@ public:
*/
void deleteTemporaryTable(OperationContext* opCtx);
+ /**
+ * Keeps the persisted record store. This should be used for temporary tables that need to be
+ * be kept across shutdown.
+ */
+ void keepTemporaryTable();
+
private:
KVEngine* _kvEngine;
- bool _recordStoreHasBeenDeleted = false;
+ bool _recordStoreHasBeenDeletedOrKept = false;
};
} // namespace mongo