summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2023-04-13 08:05:56 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-04-13 13:44:45 +0000
commit266a6db6201d3e05c7d91f56c7a7b005c692177d (patch)
tree8d57674f49fea445bf22dea2cd5730fb2aa01e1a /src/mongo/db
parentd3835e8e2fa6c66d558adfe562e902d24b2edd62 (diff)
downloadmongo-266a6db6201d3e05c7d91f56c7a7b005c692177d.tar.gz
SERVER-75787 repl::logInsertOps() accepts ShardingWriteRouter instead of wrapper function
This removes the indirection from the wrapper function and clarifies the dependency on shard_role_api.
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/op_observer/SConscript1
-rw-r--r--src/mongo/db/op_observer/oplog_writer_impl.cpp8
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/oplog.cpp18
-rw-r--r--src/mongo/db/repl/oplog.h16
5 files changed, 19 insertions, 25 deletions
diff --git a/src/mongo/db/op_observer/SConscript b/src/mongo/db/op_observer/SConscript
index 708ee03379a..cd35f4fead5 100644
--- a/src/mongo/db/op_observer/SConscript
+++ b/src/mongo/db/op_observer/SConscript
@@ -35,7 +35,6 @@ env.Library(
LIBDEPS_PRIVATE=[
'$BUILD_DIR/mongo/base',
'$BUILD_DIR/mongo/db/repl/oplog',
- '$BUILD_DIR/mongo/db/shard_role_api',
],
)
diff --git a/src/mongo/db/op_observer/oplog_writer_impl.cpp b/src/mongo/db/op_observer/oplog_writer_impl.cpp
index 6c272491f5b..23615bf9722 100644
--- a/src/mongo/db/op_observer/oplog_writer_impl.cpp
+++ b/src/mongo/db/op_observer/oplog_writer_impl.cpp
@@ -48,14 +48,8 @@ std::vector<repl::OpTime> OplogWriterImpl::logInsertOps(
std::vector<bool> fromMigrate,
const ShardingWriteRouter& shardingWriteRouter,
const CollectionPtr& collectionPtr) {
-
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn =
- [&shardingWriteRouter](const BSONObj& doc) {
- return shardingWriteRouter.getReshardingDestinedRecipient(doc);
- };
-
return repl::logInsertOps(
- opCtx, oplogEntryTemplate, begin, end, fromMigrate, getDestinedRecipientFn, collectionPtr);
+ opCtx, oplogEntryTemplate, begin, end, fromMigrate, shardingWriteRouter, collectionPtr);
}
repl::OpTime OplogWriterImpl::logOp(OperationContext* opCtx, repl::MutableOplogEntry* oplogEntry) {
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index 66ac2d01078..798e9e3a0e1 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -101,6 +101,7 @@ env.Library(
'$BUILD_DIR/mongo/db/server_base',
'$BUILD_DIR/mongo/db/session/session_catalog_mongod',
'$BUILD_DIR/mongo/db/shard_role',
+ '$BUILD_DIR/mongo/db/shard_role_api',
'$BUILD_DIR/mongo/db/stats/counters',
'$BUILD_DIR/mongo/db/stats/server_read_concern_write_concern_metrics',
'$BUILD_DIR/mongo/db/transaction/transaction',
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index 6e5cab6702e..1c8b7204fe9 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -564,14 +564,13 @@ OpTime logOp(OperationContext* opCtx, MutableOplogEntry* oplogEntry) {
return slot;
}
-std::vector<OpTime> logInsertOps(
- OperationContext* opCtx,
- MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- const std::vector<bool>& fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr) {
+std::vector<OpTime> logInsertOps(OperationContext* opCtx,
+ MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ const std::vector<bool>& fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr) {
invariant(begin != end);
auto nss = oplogEntryTemplate->getNss();
@@ -623,7 +622,8 @@ std::vector<OpTime> logInsertOps(
oplogEntry.setObject(begin[i].doc);
oplogEntry.setObject2(docKey);
oplogEntry.setOpTime(insertStatementOplogSlot);
- oplogEntry.setDestinedRecipient(getDestinedRecipientFn(begin[i].doc));
+ oplogEntry.setDestinedRecipient(
+ shardingWriteRouter.getReshardingDestinedRecipient(begin[i].doc));
addDestinedRecipient.execute([&](const BSONObj& data) {
auto recipient = data["destinedRecipient"].String();
oplogEntry.setDestinedRecipient(boost::make_optional<ShardId>({recipient}));
diff --git a/src/mongo/db/repl/oplog.h b/src/mongo/db/repl/oplog.h
index aadd004b6f3..c94c562f1b0 100644
--- a/src/mongo/db/repl/oplog.h
+++ b/src/mongo/db/repl/oplog.h
@@ -42,6 +42,7 @@
#include "mongo/db/repl/oplog_entry_or_grouped_inserts.h"
#include "mongo/db/repl/optime.h"
#include "mongo/db/repl/replication_coordinator.h"
+#include "mongo/db/s/sharding_write_router.h"
#include "mongo/db/session/logical_session_id.h"
namespace mongo {
@@ -131,14 +132,13 @@ void createOplog(OperationContext* opCtx);
* @param fromMigrate: a list of 'fromMigrate' values for the inserts.
*
*/
-std::vector<OpTime> logInsertOps(
- OperationContext* opCtx,
- MutableOplogEntry* oplogEntryTemplate,
- std::vector<InsertStatement>::const_iterator begin,
- std::vector<InsertStatement>::const_iterator end,
- const std::vector<bool>& fromMigrate,
- std::function<boost::optional<ShardId>(const BSONObj& doc)> getDestinedRecipientFn,
- const CollectionPtr& collectionPtr);
+std::vector<OpTime> logInsertOps(OperationContext* opCtx,
+ MutableOplogEntry* oplogEntryTemplate,
+ std::vector<InsertStatement>::const_iterator begin,
+ std::vector<InsertStatement>::const_iterator end,
+ const std::vector<bool>& fromMigrate,
+ const ShardingWriteRouter& shardingWriteRouter,
+ const CollectionPtr& collectionPtr);
/**
* Returns the optime of the oplog entry written to the oplog.