Make resharding_update_shard_key_in_retryable_write.js not depend on JavaScript exceptions for flow control

XMLWordPrintableJSON

    • Fully Compatible
    • Sharding 2022-08-08
    • 9
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      The resharding_update_shard_key_in_retryable_write.js test uses assert.commandWorked() to throw an exception only to catch it again and ignore certain error responses. This is problematic in the context of SERVER-47764 because a LockTimeout error response which is sometimes expected here will immediately trigger the hang analyzer and almost surely cause the assert.soon() to time out and fail.

      The runCommandRetryOnTransientErrors() function should probably be changed to check res.code explicitly.

      assert.soon(() => {
          res = db.runCommand(cmdObj);
          try {
              assert.commandWorked(res);
              return true;
          } catch (error) {
              assert.commandFailedWithCode(res, [
                  ErrorCodes.StaleConfig,
                  ErrorCodes.NoSuchTransaction,
                  ErrorCodes.ShardCannotRefreshDueToLocksHeld,
                  ErrorCodes.LockTimeout,
                  ErrorCodes.IncompleteTransactionHistory
              ]);
              cmdObj.txnNumber = NumberLong(cmdObj.txnNumber + 1);
              return false;
          }
      });
      

            Assignee:
            Cheahuychou Mao
            Reporter:
            Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: