summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@users.noreply.github.com>2023-02-13 16:11:20 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-13 21:31:08 +0000
commitdab81ced807fb71bfe5afc9d3281b9946c6f027b (patch)
treed871d00350b83400493008ffb29ed15968615fe9
parentdbf910360b98dd3c61fa6b19c33945f46588eff1 (diff)
downloadmongo-dab81ced807fb71bfe5afc9d3281b9946c6f027b.tar.gz
SERVER-71018 remove dbhelper dependency from StorageRepairObserver
-rw-r--r--src/mongo/db/storage/SConscript2
-rw-r--r--src/mongo/db/storage/storage_engine_test_fixture.h7
-rw-r--r--src/mongo/db/storage/storage_repair_observer.cpp10
-rw-r--r--src/mongo/db/storage/storage_repair_observer_test.cpp4
4 files changed, 17 insertions, 6 deletions
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index 8fdcafbcb9b..a776d99a50c 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -453,8 +453,8 @@ env.Library(
],
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/base',
- '$BUILD_DIR/mongo/db/dbhelpers',
'$BUILD_DIR/mongo/db/repl/replica_set_messages',
+ '$BUILD_DIR/mongo/db/repl/storage_interface',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/storage/journal_flusher',
'storage_file_util',
diff --git a/src/mongo/db/storage/storage_engine_test_fixture.h b/src/mongo/db/storage/storage_engine_test_fixture.h
index c573ba3fa99..89d8425fb3f 100644
--- a/src/mongo/db/storage/storage_engine_test_fixture.h
+++ b/src/mongo/db/storage/storage_engine_test_fixture.h
@@ -34,6 +34,8 @@
#include "mongo/db/catalog_raii.h"
#include "mongo/db/multitenancy.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
+#include "mongo/db/repl/storage_interface.h"
+#include "mongo/db/repl/storage_interface_impl.h"
#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/db/storage/durable_catalog.h"
#include "mongo/db/storage/durable_catalog_impl.h"
@@ -206,7 +208,10 @@ public:
class StorageEngineRepairTest : public StorageEngineTest {
public:
StorageEngineRepairTest()
- : StorageEngineTest(Options{}.repair(RepairAction::kRepair).ephemeral(false)) {}
+ : StorageEngineTest(Options{}.repair(RepairAction::kRepair).ephemeral(false)) {
+ repl::StorageInterface::set(getServiceContext(),
+ std::make_unique<repl::StorageInterfaceImpl>());
+ }
void tearDown() {
auto repairObserver = StorageRepairObserver::get(getGlobalServiceContext());
diff --git a/src/mongo/db/storage/storage_repair_observer.cpp b/src/mongo/db/storage/storage_repair_observer.cpp
index 1921b0ee42e..0a92cf5eff4 100644
--- a/src/mongo/db/storage/storage_repair_observer.cpp
+++ b/src/mongo/db/storage/storage_repair_observer.cpp
@@ -43,9 +43,9 @@
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>
-#include "mongo/db/dbhelpers.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/repl/repl_set_config.h"
+#include "mongo/db/repl/storage_interface.h"
#include "mongo/db/service_context.h"
#include "mongo/db/storage/control/journal_flusher.h"
#include "mongo/db/storage/storage_file_util.h"
@@ -157,16 +157,18 @@ void StorageRepairObserver::_invalidateReplConfigIfNeeded(OperationContext* opCt
// a replica set but lost its config due to a repair, it would automatically perform a resync.
// If this node is a standalone, this would lead to a confusing error message if it were
// added to a replica set later on.
- BSONObj config;
- if (!Helpers::getSingleton(opCtx, kConfigNss, config)) {
+ auto storage = repl::StorageInterface::get(opCtx);
+ auto swConfig = storage->findSingleton(opCtx, kConfigNss);
+ if (!swConfig.isOK()) {
return;
}
+ auto config = swConfig.getValue();
if (config.hasField(repl::ReplSetConfig::kRepairedFieldName)) {
return;
}
BSONObjBuilder configBuilder(config);
configBuilder.append(repl::ReplSetConfig::kRepairedFieldName, true);
- Helpers::putSingleton(opCtx, kConfigNss, configBuilder.obj());
+ fassert(7101800, storage->putSingleton(opCtx, kConfigNss, {configBuilder.obj(), Timestamp{}}));
JournalFlusher::get(opCtx)->waitForJournalFlush();
}
diff --git a/src/mongo/db/storage/storage_repair_observer_test.cpp b/src/mongo/db/storage/storage_repair_observer_test.cpp
index 614d7ee2e87..780a3518b9a 100644
--- a/src/mongo/db/storage/storage_repair_observer_test.cpp
+++ b/src/mongo/db/storage/storage_repair_observer_test.cpp
@@ -36,6 +36,8 @@
#include "mongo/db/dbhelpers.h"
#include "mongo/db/operation_context_noop.h"
#include "mongo/db/repl/replication_coordinator_mock.h"
+#include "mongo/db/repl/storage_interface.h"
+#include "mongo/db/repl/storage_interface_impl.h"
#include "mongo/db/service_context_d_test_fixture.h"
#include "mongo/db/storage/storage_repair_observer.h"
#include "mongo/logv2/log.h"
@@ -60,6 +62,8 @@ public:
repl::ReplicationCoordinator::set(
getServiceContext(),
std::make_unique<repl::ReplicationCoordinatorMock>(getServiceContext()));
+ repl::StorageInterface::set(getServiceContext(),
+ std::make_unique<repl::StorageInterfaceImpl>());
}
void assertRepairIncompleteOnTearDown() {