summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordi Olivares Provencio <jordi.olivares-provencio@mongodb.com>2023-02-22 15:49:29 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-22 16:37:31 +0000
commit8bb4e5e52136dc7bc87086794d7f3f4b5d40250a (patch)
tree01eb1e4ed78f5a1e7339ee5a9c991559e11d3b7b
parente58010bf6a0b45346d630a6dc56b5009302cee93 (diff)
downloadmongo-8bb4e5e52136dc7bc87086794d7f3f4b5d40250a.tar.gz
SERVER-74033 Remove force option from ident drops
-rw-r--r--jstests/noPassthrough/directoryperdb.js2
-rw-r--r--src/mongo/db/storage/kv/kv_engine_test_harness.cpp3
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp15
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp7
4 files changed, 21 insertions, 6 deletions
diff --git a/jstests/noPassthrough/directoryperdb.js b/jstests/noPassthrough/directoryperdb.js
index 5c48fd79cd6..b4091df6616 100644
--- a/jstests/noPassthrough/directoryperdb.js
+++ b/jstests/noPassthrough/directoryperdb.js
@@ -17,7 +17,7 @@ const dbname = "foo";
const isDirectoryPerDBSupported =
jsTest.options().storageEngine == "wiredTiger" || !jsTest.options().storageEngine;
-const m = MongoRunner.runMongod({dbpath: dbpath, directoryperdb: ''});
+const m = MongoRunner.runMongod({dbpath: dbpath, directoryperdb: '', syncdelay: 1});
if (!isDirectoryPerDBSupported) {
assert.isnull(m, 'storage engine without directoryperdb support should fail to start up');
diff --git a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
index 33177d37424..14c3e18d92c 100644
--- a/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
+++ b/src/mongo/db/storage/kv/kv_engine_test_harness.cpp
@@ -324,6 +324,9 @@ TEST_F(KVEngineTestHarness, TemporaryRecordStoreSimple) {
ASSERT_EQUALS(1U, all.size());
ASSERT_EQUALS(ident, all[0]);
+ // Dropping a collection might fail if we haven't checkpointed the data
+ engine->checkpoint(opCtx.get());
+
WriteUnitOfWork wuow(opCtx.get());
ASSERT_OK(engine->dropIdent(opCtx->recoveryUnit(), ident));
wuow.commit();
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
index 257e755c928..108da46e6c9 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp
@@ -1879,14 +1879,14 @@ Status WiredTigerKVEngine::dropIdent(RecoveryUnit* ru,
WiredTigerSession session(_conn);
- int ret = session.getSession()->drop(
- session.getSession(), uri.c_str(), "force,checkpoint_wait=false");
+ int ret =
+ session.getSession()->drop(session.getSession(), uri.c_str(), "checkpoint_wait=false");
LOGV2_DEBUG(22338, 1, "WT drop", "uri"_attr = uri, "ret"_attr = ret);
if (ret == EBUSY || MONGO_unlikely(WTDropEBUSY.shouldFail())) {
// Drop requires exclusive access to the table. EBUSY will be returned if there's a
- // checkpoint running, if there are any open cursors on the ident, or the ident is otherwise
- // in use.
+ // checkpoint running, there's dirty data pending to be written to disk, there are any open
+ // cursors on the ident, or the ident is otherwise in use.
return {ErrorCodes::ObjectIsBusy,
str::stream() << "Failed to remove drop-pending ident " << ident};
}
@@ -1896,6 +1896,7 @@ Status WiredTigerKVEngine::dropIdent(RecoveryUnit* ru,
}
if (ret == ENOENT) {
+ // Ident doesn't exist, it is effectively dropped.
return Status::OK();
}
@@ -1915,7 +1916,7 @@ void WiredTigerKVEngine::dropIdentForImport(OperationContext* opCtx, StringData
// cursor is open. In short, using "checkpoint_wait=false" and "lock_wait=true" means that we
// can potentially be waiting for a short period of time for WT_SESSION::drop() to run, but
// would rather get EBUSY than wait a long time for a checkpoint to complete.
- const std::string config = "force=true,checkpoint_wait=false,lock_wait=true,remove_files=false";
+ const std::string config = "checkpoint_wait=false,lock_wait=true,remove_files=false";
int ret = 0;
size_t attempt = 0;
do {
@@ -1936,6 +1937,10 @@ void WiredTigerKVEngine::dropIdentForImport(OperationContext* opCtx, StringData
"config"_attr = config,
"ret"_attr = ret);
} while (ret == EBUSY);
+ if (ret == ENOENT) {
+ // If the ident doesn't exist then it has already been dropped.
+ return;
+ }
invariantWTOK(ret, session.getSession());
}
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
index c9cb597fede..bcd35ffc3d5 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine_test.cpp
@@ -174,6 +174,10 @@ TEST_F(WiredTigerKVEngineRepairTest, OrphanedDataFilesCanBeRecovered) {
_engine->recoverOrphanedIdent(opCtxPtr.get(), nss, ident, defaultCollectionOptions);
ASSERT_EQ(ErrorCodes::CommandNotSupported, status.code());
#else
+
+ // Dropping a collection might fail if we haven't checkpointed the data.
+ _engine->checkpoint(opCtxPtr.get());
+
// Move the data file out of the way so the ident can be dropped. This not permitted on Windows
// because the file cannot be moved while it is open. The implementation for orphan recovery is
// also not implemented on Windows for this reason.
@@ -223,6 +227,9 @@ TEST_F(WiredTigerKVEngineRepairTest, UnrecoverableOrphanedDataFilesAreRebuilt) {
ASSERT(boost::filesystem::exists(*dataFilePath));
+ // Dropping a collection might fail if we haven't checkpointed the data
+ _engine->checkpoint(opCtxPtr.get());
+
ASSERT_OK(_engine->dropIdent(opCtxPtr.get()->recoveryUnit(), ident));
#ifdef _WIN32