summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorPavi Vetriselvan <pavithra.vetriselvan@mongodb.com>2021-02-02 11:26:23 -0500
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-02-04 01:36:53 +0000
commit3a02c6d491ee701bcf6180285a260b5e1e9c9346 (patch)
tree883ef460b9f21ded6a611bfda4d6306fd0cbeac2 /src/mongo
parent2dabb75cad1228ab235ae4978e5dec6514ac03c5 (diff)
downloadmongo-3a02c6d491ee701bcf6180285a260b5e1e9c9346.tar.gz
SERVER-53319 move createRetryableWritesView into tenant_migration_util
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/SConscript1
-rw-r--r--src/mongo/db/repl/oplog.cpp3
-rw-r--r--src/mongo/db/repl/tenant_migration_access_blocker_util.cpp35
-rw-r--r--src/mongo/db/repl/tenant_migration_access_blocker_util.h7
-rw-r--r--src/mongo/db/repl/tenant_migration_util.cpp35
-rw-r--r--src/mongo/db/repl/tenant_migration_util.h7
6 files changed, 45 insertions, 43 deletions
diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript
index bd8f89532d9..de56a969f75 100644
--- a/src/mongo/db/repl/SConscript
+++ b/src/mongo/db/repl/SConscript
@@ -65,6 +65,7 @@ env.Library(
'repl_server_parameters',
'repl_settings',
'tenant_migration_access_blocker',
+ 'tenant_migration_utils',
'timestamp_block',
],
)
diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp
index c9c11309bca..126a51eae0c 100644
--- a/src/mongo/db/repl/oplog.cpp
+++ b/src/mongo/db/repl/oplog.cpp
@@ -82,6 +82,7 @@
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/repl/tenant_migration_access_blocker_util.h"
#include "mongo/db/repl/tenant_migration_decoration.h"
+#include "mongo/db/repl/tenant_migration_util.h"
#include "mongo/db/repl/timestamp_block.h"
#include "mongo/db/repl/transaction_oplog_application.h"
#include "mongo/db/s/resharding_util.h"
@@ -660,7 +661,7 @@ void createOplog(OperationContext* opCtx,
});
createSlimOplogView(opCtx, ctx.db());
- tenant_migration_access_blocker::createRetryableWritesView(opCtx, ctx.db());
+ tenant_migration_util::createRetryableWritesView(opCtx, ctx.db());
/* sync here so we don't get any surprising lag later when we try to sync */
service->getStorageEngine()->flushAllFiles(opCtx, /*callerHoldsReadLock*/ false);
diff --git a/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp b/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp
index 064695f67ef..fe1e4e2d73f 100644
--- a/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp
+++ b/src/mongo/db/repl/tenant_migration_access_blocker_util.cpp
@@ -276,41 +276,6 @@ void performNoopWrite(OperationContext* opCtx, StringData msg) {
});
}
-void createRetryableWritesView(OperationContext* opCtx, Database* db) {
- writeConflictRetry(
- opCtx, "createDonorOplogView", "local.system.tenantMigration.oplogView", [&] {
- {
- // Create 'system.views' in a separate WUOW if it does not exist.
- WriteUnitOfWork wuow(opCtx);
- CollectionPtr coll = CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(
- opCtx, NamespaceString(db->getSystemViewsName()));
- if (!coll) {
- coll = db->createCollection(opCtx, NamespaceString(db->getSystemViewsName()));
- }
- invariant(coll);
- wuow.commit();
- }
-
- // First match entries with a `stmtId` so that we're filtering for retryable writes
- // oplog entries. Pass the result into the next stage of the pipeline and only project
- // the fields that a tenant migration recipient needs to refetch retryable writes oplog
- // entries: `ts`, `prevOpTime`, `preImageOpTime`, and `postImageOpTime`.
- CollectionOptions options;
- options.viewOn = NamespaceString::kRsOplogNamespace.coll().toString();
- options.pipeline = BSON_ARRAY(
- BSON("$match" << BSON("stmtId" << BSON("$exists" << true)))
- << BSON("$project" << BSON("_id"
- << "$ts"
- << "ns" << 1 << "ts" << 1 << "prevOpTime" << 1
- << "preImageOpTime" << 1 << "postImageOpTime" << 1)));
-
- WriteUnitOfWork wuow(opCtx);
- uassertStatusOK(db->createView(
- opCtx, NamespaceString("local.system.tenantMigration.oplogView"), options));
- wuow.commit();
- });
-}
-
} // namespace tenant_migration_access_blocker
} // namespace mongo
diff --git a/src/mongo/db/repl/tenant_migration_access_blocker_util.h b/src/mongo/db/repl/tenant_migration_access_blocker_util.h
index 6cd7d7b9102..cf338366e5a 100644
--- a/src/mongo/db/repl/tenant_migration_access_blocker_util.h
+++ b/src/mongo/db/repl/tenant_migration_access_blocker_util.h
@@ -29,7 +29,6 @@
#pragma once
-#include "mongo/db/catalog/database.h"
#include "mongo/db/commands.h"
#include "mongo/db/commands/tenant_migration_donor_cmds_gen.h"
#include "mongo/db/operation_context.h"
@@ -100,12 +99,6 @@ void handleTenantMigrationConflict(OperationContext* opCtx, Status status);
*/
void performNoopWrite(OperationContext* opCtx, StringData msg);
-/**
- * Creates a view on the oplog that allows a tenant migration recipient to fetch retryable writes
- * from a tenant migration donor.
- */
-void createRetryableWritesView(OperationContext* opCtx, Database* db);
-
} // namespace tenant_migration_access_blocker
} // namespace mongo
diff --git a/src/mongo/db/repl/tenant_migration_util.cpp b/src/mongo/db/repl/tenant_migration_util.cpp
index 8b789a55ca5..66c39f1a897 100644
--- a/src/mongo/db/repl/tenant_migration_util.cpp
+++ b/src/mongo/db/repl/tenant_migration_util.cpp
@@ -107,6 +107,41 @@ ExecutorFuture<void> storeExternalClusterTimeKeyDocsAndRefreshCache(
});
}
+void createRetryableWritesView(OperationContext* opCtx, Database* db) {
+ writeConflictRetry(
+ opCtx, "createDonorOplogView", "local.system.tenantMigration.oplogView", [&] {
+ {
+ // Create 'system.views' in a separate WUOW if it does not exist.
+ WriteUnitOfWork wuow(opCtx);
+ CollectionPtr coll = CollectionCatalog::get(opCtx)->lookupCollectionByNamespace(
+ opCtx, NamespaceString(db->getSystemViewsName()));
+ if (!coll) {
+ coll = db->createCollection(opCtx, NamespaceString(db->getSystemViewsName()));
+ }
+ invariant(coll);
+ wuow.commit();
+ }
+
+ // First match entries with a `stmtId` so that we're filtering for retryable writes
+ // oplog entries. Pass the result into the next stage of the pipeline and only project
+ // the fields that a tenant migration recipient needs to refetch retryable writes oplog
+ // entries: `ts`, `prevOpTime`, `preImageOpTime`, and `postImageOpTime`.
+ CollectionOptions options;
+ options.viewOn = NamespaceString::kRsOplogNamespace.coll().toString();
+ options.pipeline = BSON_ARRAY(
+ BSON("$match" << BSON("stmtId" << BSON("$exists" << true)))
+ << BSON("$project" << BSON("_id"
+ << "$ts"
+ << "ns" << 1 << "ts" << 1 << "prevOpTime" << 1
+ << "preImageOpTime" << 1 << "postImageOpTime" << 1)));
+
+ WriteUnitOfWork wuow(opCtx);
+ uassertStatusOK(db->createView(
+ opCtx, NamespaceString("local.system.tenantMigration.oplogView"), options));
+ wuow.commit();
+ });
+}
+
} // namespace tenant_migration_util
} // namespace mongo
diff --git a/src/mongo/db/repl/tenant_migration_util.h b/src/mongo/db/repl/tenant_migration_util.h
index e7d253ed6fd..ddc26e5f7bf 100644
--- a/src/mongo/db/repl/tenant_migration_util.h
+++ b/src/mongo/db/repl/tenant_migration_util.h
@@ -35,6 +35,7 @@
#include "mongo/bson/timestamp.h"
#include "mongo/client/mongo_uri.h"
#include "mongo/config.h"
+#include "mongo/db/catalog/database.h"
#include "mongo/db/keys_collection_document_gen.h"
#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/executor/scoped_task_executor.h"
@@ -146,6 +147,12 @@ ExecutorFuture<void> storeExternalClusterTimeKeyDocsAndRefreshCache(
std::vector<ExternalKeysCollectionDocument> keyDocs,
const CancelationToken& token);
+/**
+ * Creates a view on the oplog that allows a tenant migration recipient to fetch retryable writes
+ * from a tenant migration donor.
+ */
+void createRetryableWritesView(OperationContext* opCtx, Database* db);
+
} // namespace tenant_migration_util
} // namespace mongo