diff options
author | Benety Goh <benety@mongodb.com> | 2022-08-25 06:39:31 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-25 11:12:58 +0000 |
commit | ec8694abf458ceb1494ed97a29b199afc3e73708 (patch) | |
tree | 9873a0bc8326a3d2dad6ca4410c695cc36abf335 /src/mongo/db/transaction | |
parent | b887165489cd44f581946b341a8941d2d27ddfec (diff) | |
download | mongo-ec8694abf458ceb1494ed97a29b199afc3e73708.tar.gz |
SERVER-68215 MongoDSessionCatalog constructor accepts MongoDSessionCatalogTransactionInterface
Diffstat (limited to 'src/mongo/db/transaction')
6 files changed, 99 insertions, 3 deletions
diff --git a/src/mongo/db/transaction/SConscript b/src/mongo/db/transaction/SConscript index c4f2b197f96..8a9ed044aa1 100644 --- a/src/mongo/db/transaction/SConscript +++ b/src/mongo/db/transaction/SConscript @@ -12,6 +12,7 @@ env.Library( 'internal_transactions_reap_service.cpp', 'retryable_writes_stats.cpp', 'server_transactions_metrics.cpp', + 'session_catalog_mongod_transaction_interface_impl.cpp', 'transaction_history_iterator.cpp', 'transaction_metrics_observer.cpp', 'transaction_participant.cpp', diff --git a/src/mongo/db/transaction/internal_transactions_reap_service_test.cpp b/src/mongo/db/transaction/internal_transactions_reap_service_test.cpp index 36fb76333b9..46a1c1fbc26 100644 --- a/src/mongo/db/transaction/internal_transactions_reap_service_test.cpp +++ b/src/mongo/db/transaction/internal_transactions_reap_service_test.cpp @@ -37,6 +37,7 @@ #include "mongo/db/session/session_txn_record_gen.h" #include "mongo/db/transaction/internal_transactions_reap_service.h" #include "mongo/db/transaction/internal_transactions_reap_service_gen.h" +#include "mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h" namespace mongo { namespace { @@ -61,7 +62,10 @@ protected: auto replCoord = repl::ReplicationCoordinator::get(opCtx); ASSERT_OK(replCoord->setFollowerMode(repl::MemberState::RS_PRIMARY)); - MongoDSessionCatalog::set(service, std::make_unique<MongoDSessionCatalog>()); + MongoDSessionCatalog::set( + service, + std::make_unique<MongoDSessionCatalog>( + std::make_unique<MongoDSessionCatalogTransactionInterfaceImpl>())); auto mongoDSessionCatalog = MongoDSessionCatalog::get(opCtx); mongoDSessionCatalog->onStepUp(opCtx); diff --git a/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.cpp b/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.cpp new file mode 100644 index 00000000000..a1f9ef06b89 --- /dev/null +++ b/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.cpp @@ -0,0 +1,32 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h" + +namespace mongo {} // namespace mongo diff --git a/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h b/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h new file mode 100644 index 00000000000..b29427ba5c5 --- /dev/null +++ b/src/mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/session/session_catalog_mongod_transaction_interface.h" + +namespace mongo { + +/** + * Facade around the TransactionParticipant class in the db/transaction library. + */ +class MongoDSessionCatalogTransactionInterfaceImpl + : public MongoDSessionCatalogTransactionInterface { + MongoDSessionCatalogTransactionInterfaceImpl( + const MongoDSessionCatalogTransactionInterfaceImpl&) = delete; + MongoDSessionCatalogTransactionInterfaceImpl& operator=( + const MongoDSessionCatalogTransactionInterfaceImpl&) = delete; + +public: + MongoDSessionCatalogTransactionInterfaceImpl() = default; + virtual ~MongoDSessionCatalogTransactionInterfaceImpl() = default; +}; + +} // namespace mongo diff --git a/src/mongo/db/transaction/transaction_participant_retryable_writes_test.cpp b/src/mongo/db/transaction/transaction_participant_retryable_writes_test.cpp index 1b5fff8ede6..6b438d9642e 100644 --- a/src/mongo/db/transaction/transaction_participant_retryable_writes_test.cpp +++ b/src/mongo/db/transaction/transaction_participant_retryable_writes_test.cpp @@ -46,6 +46,7 @@ #include "mongo/db/service_context.h" #include "mongo/db/session/session_catalog_mongod.h" #include "mongo/db/transaction/server_transactions_metrics.h" +#include "mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h" #include "mongo/db/transaction/transaction_participant.h" #include "mongo/idl/server_parameter_test_util.h" #include "mongo/stdx/future.h" @@ -186,7 +187,10 @@ protected: MockReplCoordServerFixture::setUp(); const auto service = opCtx()->getServiceContext(); repl::StorageInterface::set(service, std::make_unique<repl::StorageInterfaceImpl>()); - MongoDSessionCatalog::set(service, std::make_unique<MongoDSessionCatalog>()); + MongoDSessionCatalog::set( + service, + std::make_unique<MongoDSessionCatalog>( + std::make_unique<MongoDSessionCatalogTransactionInterfaceImpl>())); auto mongoDSessionCatalog = MongoDSessionCatalog::get(opCtx()); mongoDSessionCatalog->onStepUp(opCtx()); diff --git a/src/mongo/db/transaction/transaction_participant_test.cpp b/src/mongo/db/transaction/transaction_participant_test.cpp index e2d601b7228..d0900be4cbb 100644 --- a/src/mongo/db/transaction/transaction_participant_test.cpp +++ b/src/mongo/db/transaction/transaction_participant_test.cpp @@ -46,6 +46,7 @@ #include "mongo/db/session/session_catalog_mongod.h" #include "mongo/db/stats/fill_locker_info.h" #include "mongo/db/transaction/server_transactions_metrics.h" +#include "mongo/db/transaction/session_catalog_mongod_transaction_interface_impl.h" #include "mongo/db/transaction/transaction_participant.h" #include "mongo/db/transaction/transaction_participant_gen.h" #include "mongo/db/txn_retry_counter_too_old_info.h" @@ -271,7 +272,10 @@ protected: // Register a temporary storage interface for MongoDSessionCatalog::onStepUp() create the // config.transactions table. repl::StorageInterface::set(service, std::make_unique<repl::StorageInterfaceImpl>()); - MongoDSessionCatalog::set(service, std::make_unique<MongoDSessionCatalog>()); + MongoDSessionCatalog::set( + service, + std::make_unique<MongoDSessionCatalog>( + std::make_unique<MongoDSessionCatalogTransactionInterfaceImpl>())); auto mongoDSessionCatalog = MongoDSessionCatalog::get(opCtx()); mongoDSessionCatalog->onStepUp(opCtx()); |