Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-54047

Resharding permits transactions to commit after minFetchTimestamp without having destined recipient filled in

    • Fully Compatible
    • ALL
    • Hide
      python buildscripts/resmoke.py run --suite=sharding repro_resharding_txn_missing_destined_recipient.js
      
      repro_resharding_txn_missing_destined_recipient.js
      (function() {
      "use strict";
      
      load("jstests/sharding/libs/resharding_test_fixture.js");
      
      const reshardingTest = new ReshardingTest({numDonors: 2, numRecipients: 2, reshardInPlace: true});
      reshardingTest.setup();
      
      const donorShardNames = reshardingTest.donorShardNames;
      const sourceCollection = reshardingTest.createShardedCollection({
          ns: "reshardingDb.coll",
          shardKeyPattern: {oldKey: 1},
          chunks: [
              {min: {oldKey: MinKey}, max: {oldKey: 10}, shard: donorShardNames[0]},
              {min: {oldKey: 10}, max: {oldKey: MaxKey}, shard: donorShardNames[1]},
          ],
      });
      
      const mongos = sourceCollection.getMongo();
      const session = mongos.startSession({causalConsistency: false, retryWrites: false});
      const sessionCollection = session.getDatabase(sourceCollection.getDB().getName())
                                    .getCollection(sourceCollection.getName());
      
      assert.commandWorked(sessionCollection.insert({_id: 0, oldKey: 5, newKey: 15, counter: 0}));
      
      session.startTransaction();
      assert.commandWorked(sessionCollection.update({_id: 0, oldKey: 5}, {$inc: {counter: 1}}));
      
      const recipientShardNames = reshardingTest.recipientShardNames;
      reshardingTest.withReshardingInBackground(  //
          {
              newShardKeyPattern: {newKey: 1},
              newChunks: [
                  {min: {newKey: MinKey}, max: {newKey: 10}, shard: recipientShardNames[0]},
                  {min: {newKey: 10}, max: {newKey: MaxKey}, shard: recipientShardNames[1]},
              ],
          },
          () => {
              assert.soon(() => {
                  const coordinatorDoc = mongos.getCollection("config.reshardingOperations").findOne({
                      nss: sourceCollection.getFullName()
                  });
      
                  return coordinatorDoc !== null && coordinatorDoc.fetchTimestamp !== undefined;
              });
      
              assert.commandWorked(session.commitTransaction_forTesting());
          });
      
      reshardingTest.teardown();
      })();
      
      Show
      python buildscripts/resmoke.py run --suite=sharding repro_resharding_txn_missing_destined_recipient.js repro_resharding_txn_missing_destined_recipient.js ( function () { "use strict" ; load( "jstests/sharding/libs/resharding_test_fixture.js" ); const reshardingTest = new ReshardingTest({numDonors: 2, numRecipients: 2, reshardInPlace: true }); reshardingTest.setup(); const donorShardNames = reshardingTest.donorShardNames; const sourceCollection = reshardingTest.createShardedCollection({ ns: "reshardingDb.coll" , shardKeyPattern: {oldKey: 1}, chunks: [ {min: {oldKey: MinKey}, max: {oldKey: 10}, shard: donorShardNames[0]}, {min: {oldKey: 10}, max: {oldKey: MaxKey}, shard: donorShardNames[1]}, ], }); const mongos = sourceCollection.getMongo(); const session = mongos.startSession({causalConsistency: false , retryWrites: false }); const sessionCollection = session.getDatabase(sourceCollection.getDB().getName()) .getCollection(sourceCollection.getName()); assert.commandWorked(sessionCollection.insert({_id: 0, oldKey: 5, newKey: 15, counter: 0})); session.startTransaction(); assert.commandWorked(sessionCollection.update({_id: 0, oldKey: 5}, {$inc: {counter: 1}})); const recipientShardNames = reshardingTest.recipientShardNames; reshardingTest.withReshardingInBackground( // { newShardKeyPattern: {newKey: 1}, newChunks: [ {min: {newKey: MinKey}, max: {newKey: 10}, shard: recipientShardNames[0]}, {min: {newKey: 10}, max: {newKey: MaxKey}, shard: recipientShardNames[1]}, ], }, () => { assert.soon(() => { const coordinatorDoc = mongos.getCollection( "config.reshardingOperations" ).findOne({ nss: sourceCollection.getFullName() }); return coordinatorDoc !== null && coordinatorDoc.fetchTimestamp !== undefined; }); assert.commandWorked(session.commitTransaction_forTesting()); }); reshardingTest.teardown(); })();
    • Sharding 2021-02-08
    • 1

      This leads the writes from the multi-document transaction to not be applied by the recipient shard(s).

      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000 Error: [{
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000  "docsWithDifferentContents" : [
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000          {
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                  "original" : {
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "_id" : 0,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "oldKey" : 5,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "newKey" : 15,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "counter" : 1
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                  },
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                  "resharded" : {
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "_id" : 0,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "oldKey" : 5,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "newKey" : 15,
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.584+0000                          "counter" : 0
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000                  }
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000          }
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  ],
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  "docsExtraAfterResharding" : [ ],
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  "docsMissingAfterResharding" : [ ]
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000 }] != [{
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  "docsWithDifferentContents" : [ ],
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  "docsExtraAfterResharding" : [ ],
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000  "docsMissingAfterResharding" : [ ]
      [js_test:repro_resharding_txn_missing_destined_recipient] 2021-01-26T12:22:44.585+0000 }] are not equal :
      

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: