diff options
author | Haley Connelly <haley.connelly@mongodb.com> | 2021-06-15 19:51:38 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-17 17:50:30 +0000 |
commit | c865688f1993bba72cbffc39d5e80f21313ba4ee (patch) | |
tree | 1158aadcf8212a30f1c3791e0918dd744640f6ca | |
parent | 9b3de8ee95340dedf91e47d1e81e327c2875cc7b (diff) | |
download | mongo-c865688f1993bba72cbffc39d5e80f21313ba4ee.tar.gz |
SERVER-57478 Remove code related to local.system.resharding.slimOplogForGraphLookup view
-rw-r--r-- | jstests/multiVersion/oplog_views_for_tenant_migration.js (renamed from jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js) | 9 | ||||
-rw-r--r-- | jstests/noPassthrough/slim_oplog_test.js | 90 | ||||
-rw-r--r-- | src/mongo/db/mongod_main.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/namespace_string.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/namespace_string.h | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/SConscript | 1 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_agg_test.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp | 6 | ||||
-rw-r--r-- | src/mongo/db/s/resharding_util.cpp | 52 | ||||
-rw-r--r-- | src/mongo/db/s/resharding_util.h | 8 |
11 files changed, 1 insertions, 179 deletions
diff --git a/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js b/jstests/multiVersion/oplog_views_for_tenant_migration.js index 5ec13841a8e..0c7e5dad8b7 100644 --- a/jstests/multiVersion/oplog_views_for_resharding_and_tenant_migration.js +++ b/jstests/multiVersion/oplog_views_for_tenant_migration.js @@ -6,14 +6,10 @@ "use strict"; load("jstests/multiVersion/libs/multi_rs.js"); // For 'upgradeSet()' -const kReshardingOplogViewName = "system.resharding.slimOplogForGraphLookup"; const kTenantMigrationOplogViewName = "system.tenantMigration.oplogView"; function assertOplogViewsNotExist(node) { const localDb = node.getDB("local"); - const reshardingViewRes = localDb.runCommand( - {listCollections: 1, filter: {type: "view", name: kReshardingOplogViewName}}); - assert.eq(0, reshardingViewRes.cursor.firstBatch.length); const tenantMigrationRes = localDb.runCommand( {listCollections: 1, filter: {type: "view", name: kTenantMigrationOplogViewName}}); assert.eq(0, tenantMigrationRes.cursor.firstBatch.length); @@ -21,9 +17,6 @@ function assertOplogViewsNotExist(node) { function assertOplogViewsExist(node) { const localDb = node.getDB("local"); - const reshardingViewRes = localDb.runCommand( - {listCollections: 1, filter: {type: "view", name: kReshardingOplogViewName}}); - assert.eq(1, reshardingViewRes.cursor.firstBatch.length); const tenantMigrationRes = localDb.runCommand( {listCollections: 1, filter: {type: "view", name: kTenantMigrationOplogViewName}}); assert.eq(1, tenantMigrationRes.cursor.firstBatch.length); @@ -40,4 +33,4 @@ rst.upgradeSet({binVersion: "latest"}); rst.nodes.forEach(node => assertOplogViewsExist(node)); rst.stopSet(); -})();
\ No newline at end of file +})(); diff --git a/jstests/noPassthrough/slim_oplog_test.js b/jstests/noPassthrough/slim_oplog_test.js deleted file mode 100644 index 4b453e4f580..00000000000 --- a/jstests/noPassthrough/slim_oplog_test.js +++ /dev/null @@ -1,90 +0,0 @@ -/** - * The slim oplog is a view on the oplog to support efficient lookup queries for resharding. - * - * @tags: [ - * requires_majority_read_concern, - * requires_replication, - * uses_prepare_transaction, - * uses_transactions, - * ] - */ -(function() { -"use strict"; - -load("jstests/libs/retryable_writes_util.js"); - -if (!RetryableWritesUtil.storageEngineSupportsRetryableWrites(jsTest.options().storageEngine)) { - jsTestLog("Retryable writes are not supported, skipping test"); - return; -} - -load("jstests/core/txns/libs/prepare_helpers.js"); - -const rst = new ReplSetTest({nodes: 2}); -rst.startSet(); -rst.initiate(); - -const rsConn = new Mongo(rst.getURL()); -const oplog = rst.getPrimary().getDB("local")["oplog.rs"]; -const slimOplog = rst.getPrimary().getDB("local")["system.resharding.slimOplogForGraphLookup"]; -const session = rsConn.startSession({retryWrites: true}); -const collection = session.getDatabase("test")["collection"]; - -{ - // Assert an oplog entry representing a retryable write projects a `prevOpTime.ts` of the null - // timestamp. - assert.commandWorked(collection.insert({_id: "slim"})); - - const oplogEntry = oplog.find({"o._id": "slim"}).next(); - jsTestLog({"slim entry": oplogEntry, "slim": slimOplog.exists()}); - assert(oplogEntry.hasOwnProperty("txnNumber")); - assert(oplogEntry.hasOwnProperty("stmtId")); - assert.eq(Timestamp(0, 0), slimOplog.find({ts: oplogEntry["ts"]}).next()["prevOpTime"]["ts"]); -} - -{ - // Assert an oplog entry that commits a prepared transaction projects a `prevOpTime.ts` equal to - // the timestamp of the preparing oplog entry. - session.startTransaction(); - assert.commandWorked(collection.insert({_id: "slim_1"})); - assert.commandWorked(collection.insert({_id: "slim_2"})); - let prepTs = PrepareHelpers.prepareTransaction(session); - assert.commandWorked(PrepareHelpers.commitTransaction(session, prepTs)); - - const commitEntry = oplog.find({"prevOpTime.ts": prepTs}).next(); - assert.eq(prepTs, commitEntry["prevOpTime"]["ts"]); - jsTestLog({ - PrepEntry: oplog.find({ts: prepTs}).next(), - CommitEntry: commitEntry, - SlimEntry: slimOplog.find({ts: commitEntry["ts"]}).next() - }); - - // Perform a $graphLookup connecting non-trivial slim oplog entries to the associated applyOps - // operations. Assert the history is as expected. - let oplogDocsWithHistory = oplog.aggregate([ - {$match: {ts: commitEntry["ts"]}}, - {$graphLookup: {from: "system.resharding.slimOplogForGraphLookup", - startWith: "$ts", - connectFromField: "prevOpTime.ts", - connectToField: "ts", - depthField: "depthForResharding", - as: "history"}}, - // For the purposes of this test, unwind the history to give a predictable order of items - // that graphLookup accumulates. - {$unwind: "$history"}, - {$sort: {"history.ts": 1}} - ]).toArray(); - - jsTestLog({"Unwound history": oplogDocsWithHistory}); - assert.eq(2, oplogDocsWithHistory.length); - assert.eq(1, oplogDocsWithHistory[0]["history"]["depthForResharding"]); - assert.eq(Timestamp(0, 0), oplogDocsWithHistory[0]["history"]["prevOpTime"]["ts"]); - assert.eq(2, oplogDocsWithHistory[0]["history"]["o"]["applyOps"].length); - - assert.eq(0, oplogDocsWithHistory[1]["history"].depthForResharding); - assert.eq(prepTs, oplogDocsWithHistory[1]["history"]["prevOpTime"]["ts"]); - assert.eq({}, oplogDocsWithHistory[1]["history"]["o"]); -} - -rst.stopSet(); -})(); diff --git a/src/mongo/db/mongod_main.cpp b/src/mongo/db/mongod_main.cpp index c14577624c5..2fd444f818a 100644 --- a/src/mongo/db/mongod_main.cpp +++ b/src/mongo/db/mongod_main.cpp @@ -714,7 +714,6 @@ ExitCode _initAndListen(ServiceContext* serviceContext, int listenPort) { if (replSettings.usingReplSets()) { Lock::GlobalWrite lk(startupOpCtx.get()); OldClientContext ctx(startupOpCtx.get(), NamespaceString::kRsOplogNamespace.ns()); - createSlimOplogView(startupOpCtx.get(), ctx.db()); tenant_migration_util::createOplogViewForTenantMigrations(startupOpCtx.get(), ctx.db()); } } diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp index 1ad9bdb94c3..6e0868f31c4 100644 --- a/src/mongo/db/namespace_string.cpp +++ b/src/mongo/db/namespace_string.cpp @@ -121,9 +121,6 @@ const NamespaceString NamespaceString::kReshardingApplierProgressNamespace( const NamespaceString NamespaceString::kReshardingTxnClonerProgressNamespace( NamespaceString::kConfigDb, "localReshardingOperations.recipient.progress_txn_cloner"); -const NamespaceString NamespaceString::kReshardingOplogView( - NamespaceString::kLocalDb, "system.resharding.slimOplogForGraphLookup"); - const NamespaceString NamespaceString::kCollectionCriticalSectionsNamespace( NamespaceString::kConfigDb, "collection_critical_sections"); diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h index c4748a3be11..b5420e4c6a6 100644 --- a/src/mongo/db/namespace_string.h +++ b/src/mongo/db/namespace_string.h @@ -172,9 +172,6 @@ public: // Namespace for storing config.transactions cloner progress for resharding. static const NamespaceString kReshardingTxnClonerProgressNamespace; - // Namespace for view on local.oplog.rs for resharding. - static const NamespaceString kReshardingOplogView; - // Namespace for storing config.collectionCriticalSections documents static const NamespaceString kCollectionCriticalSectionsNamespace; diff --git a/src/mongo/db/repl/SConscript b/src/mongo/db/repl/SConscript index eb8ce074e9e..5d29cb4e258 100644 --- a/src/mongo/db/repl/SConscript +++ b/src/mongo/db/repl/SConscript @@ -49,7 +49,6 @@ env.Library( '$BUILD_DIR/mongo/db/dbdirectclient', '$BUILD_DIR/mongo/db/dbhelpers', '$BUILD_DIR/mongo/db/op_observer', - '$BUILD_DIR/mongo/db/s/resharding_util', '$BUILD_DIR/mongo/db/stats/counters', '$BUILD_DIR/mongo/db/stats/server_read_concern_write_concern_metrics', '$BUILD_DIR/mongo/db/transaction', diff --git a/src/mongo/db/s/resharding/resharding_agg_test.cpp b/src/mongo/db/s/resharding/resharding_agg_test.cpp index b4f62996041..58fb77a7cb6 100644 --- a/src/mongo/db/s/resharding/resharding_agg_test.cpp +++ b/src/mongo/db/s/resharding/resharding_agg_test.cpp @@ -187,15 +187,10 @@ protected: } boost::intrusive_ptr<ExpressionContextForTest> createExpressionContext() { - NamespaceString slimNss = - NamespaceString("local.system.resharding.slimOplogForGraphLookup"); - boost::intrusive_ptr<ExpressionContextForTest> expCtx( new ExpressionContextForTest(getOpCtx(), _localOplogBufferNss)); expCtx->setResolvedNamespace(_localOplogBufferNss, {_localOplogBufferNss, {}}); expCtx->setResolvedNamespace(_remoteOplogNss, {_remoteOplogNss, {}}); - expCtx->setResolvedNamespace(slimNss, - {slimNss, std::vector<BSONObj>{getSlimOplogPipeline()}}); return expCtx; } diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp index 9f3f6d7a3a6..434e5c9d0a0 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher.cpp @@ -57,8 +57,6 @@ namespace mongo { namespace { boost::intrusive_ptr<ExpressionContext> _makeExpressionContext(OperationContext* opCtx) { StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces; - const NamespaceString slimOplogNs("local.system.resharding.slimOplogForGraphLookup"); - resolvedNamespaces[slimOplogNs.coll()] = {slimOplogNs, std::vector<BSONObj>()}; resolvedNamespaces[NamespaceString::kRsOplogNamespace.coll()] = { NamespaceString::kRsOplogNamespace, std::vector<BSONObj>()}; return make_intrusive<ExpressionContext>(opCtx, diff --git a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp index 958ac588789..40ce2dcf21e 100644 --- a/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp +++ b/src/mongo/db/s/resharding/resharding_oplog_fetcher_test.cpp @@ -93,7 +93,6 @@ public: { Lock::GlobalWrite lk(_opCtx); OldClientContext ctx(_opCtx, NamespaceString::kRsOplogNamespace.ns()); - createSlimOplogView(_opCtx, ctx.db()); } // Initialize ReshardingMetrics to a recipient state compatible with fetching. @@ -189,15 +188,10 @@ public: } boost::intrusive_ptr<ExpressionContextForTest> createExpressionContext() { - NamespaceString slimNss = - NamespaceString("local.system.resharding.slimOplogForGraphLookup"); - boost::intrusive_ptr<ExpressionContextForTest> expCtx( new ExpressionContextForTest(_opCtx, NamespaceString::kRsOplogNamespace)); expCtx->setResolvedNamespace(NamespaceString::kRsOplogNamespace, {NamespaceString::kRsOplogNamespace, {}}); - expCtx->setResolvedNamespace(slimNss, - {slimNss, std::vector<BSONObj>{getSlimOplogPipeline()}}); return expCtx; } diff --git a/src/mongo/db/s/resharding_util.cpp b/src/mongo/db/s/resharding_util.cpp index 03c6a96dd35..5856e4c1f0f 100644 --- a/src/mongo/db/s/resharding_util.cpp +++ b/src/mongo/db/s/resharding_util.cpp @@ -250,58 +250,6 @@ std::vector<BSONObj> buildTagsDocsFromZones(const NamespaceString& tempNss, return tags; } -void createSlimOplogView(OperationContext* opCtx, Database* db) { - writeConflictRetry( - opCtx, "createReshardingSlimOplog", NamespaceString::kReshardingOplogView.ns(), [&] { - { - // 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(); - } - - // Resharding uses the `prevOpTime` to link oplog related entries via a - // $graphLookup. Large transactions and prepared transaction use prevOpTime to identify - // earlier oplog entries from the same transaction. Retryable writes (identified via the - // presence of `stmtId`) use prevOpTime to identify earlier run statements from the same - // retryable write. This view will unlink oplog entries from the same retryable write - // by zeroing out their `prevOpTime`. - CollectionOptions options; - options.viewOn = NamespaceString::kRsOplogNamespace.coll().toString(); - options.pipeline = BSON_ARRAY(getSlimOplogPipeline()); - WriteUnitOfWork wuow(opCtx); - auto status = db->createView(opCtx, NamespaceString::kReshardingOplogView, options); - if (status == ErrorCodes::NamespaceExists) { - return; - } - uassertStatusOK(status); - wuow.commit(); - }); -} - -BSONObj getSlimOplogPipeline() { - return fromjson( - "{$project: {\ - _id: '$ts',\ - op: 1,\ - o: {\ - applyOps: {ui: 1, destinedRecipient: 1},\ - abortTransaction: 1\ - },\ - ts: 1,\ - 'prevOpTime.ts': {$cond: {\ - if: {$eq: [{$type: '$stmtId'}, 'missing']},\ - then: '$prevOpTime.ts',\ - else: Timestamp(0, 0)\ - }}\ - }}"); -} - std::unique_ptr<Pipeline, PipelineDeleter> createOplogFetchingPipelineForResharding( const boost::intrusive_ptr<ExpressionContext>& expCtx, const ReshardingDonorOplogId& startAfter, diff --git a/src/mongo/db/s/resharding_util.h b/src/mongo/db/s/resharding_util.h index c01888ddee6..48a626272b4 100644 --- a/src/mongo/db/s/resharding_util.h +++ b/src/mongo/db/s/resharding_util.h @@ -270,14 +270,6 @@ std::vector<BSONObj> buildTagsDocsFromZones(const NamespaceString& tempNss, const std::vector<ReshardingZoneType>& zones); /** - * Creates a view on the oplog that facilitates the specialized oplog tailing a resharding - * recipient performs on a donor. - */ -void createSlimOplogView(OperationContext* opCtx, Database* db); - -BSONObj getSlimOplogPipeline(); - -/** * Creates a pipeline that can be serialized into a query for fetching oplog entries. `startAfter` * may be `Timestamp::isNull()` to fetch from the beginning of the oplog. */ |