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

In retryable write that changes shard key value and owning shard, write concern failure results in non-WC error code

    • Type: Icon: Bug Bug
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • 4.3 Desired
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • ALL
    • Sharding 2019-12-16, Sharding 2019-12-30, Sharding 2020-01-13

      Presumably this error is returned because WC timeout is considered a retryable error?

      assert: write failed with error: {
          "nMatched" : 0,
          "nUpserted" : 0,
          "nModified" : 0,
          "writeError" : {
                  "code" : 217,
                  "errmsg" : "Cannot retry a retryable write that has been converted into a transaction"
          }
      }
      
      (function() {
      'use strict';
      
      load("jstests/libs/write_concern_util.js");
      load("jstests/sharding/libs/update_shard_key_helpers.js");
      
      const st = new ShardingTest({mongos: 1, shards: {
          rs0: {
              nodes: [{}, {}, {rsConfig: {tags: {tag1: "value1"}}}],
              settings: {getLastErrorModes: {tagged: {tag1: 1}}}
          },
          rs1: {nodes: 3}
      }});
      const wc = {w: "tagged", wtimeout: 6000};
      const kDbName = 'db';
      const mongos = st.s0;
      const shard0 = st.shard0.shardName;
      const shard1 = st.shard1.shardName;
      const ns = kDbName + '.foo';
      
      assert.commandWorked(mongos.adminCommand({enableSharding: kDbName}));
      st.ensurePrimaryShard(kDbName, shard0);
      
      let session = st.s.startSession({retryWrites: true});
      let sessionDB = session.getDatabase(kDbName);
      
      let docsToInsert =
          [{"x": 4, "a": 3}, {"x": 78}, {"x": 100}, {"x": 300, "a": 3}, {"x": 500, "a": 6}];
      
      shardCollectionMoveChunks(st, kDbName, ns, {"x": 1}, docsToInsert, {"x": 100}, {"x": 300});
      cleanupOrphanedDocs(st, ns);
      
      // Pause replication on the tagged secondary.
      stopServerReplication(st.rs0.nodes[2]);
      
      let res = sessionDB.foo.update({x: 4}, {$set: {x: 1000}}, {writeConcern: wc});
      // Actually fails with 217 (IncompleteTransactionHistory)
      assert.commandWorkedIgnoringWriteConcernErrors(res);
      checkWriteConcernTimedOut(res);
      
      res = sessionDB.runCommand({
          findAndModify: 'foo',
          query: {x: 78},
          update: {$set: {x: 250}},
          lsid: {id: UUID()},
          txnNumber: NumberLong(1),
          writeConcern: wc,
      });
      // Actually fails with 217 (IncompleteTransactionHistory)
      assert.commandWorkedIgnoringWriteConcernErrors(res);
      checkWriteConcernTimedOut(res);
      
      restartServerReplication(st.rs0.nodes[2]);
      
      mongos.getDB(kDbName).foo.drop();
      
      st.stop();
      })();
      

            Assignee:
            blake.oler@mongodb.com Blake Oler
            Reporter:
            kevin.pulo@mongodb.com Kevin Pulo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: