|
There's a few parts to be able to retry an entire transaction in our jsCore passthroughs:
1. The auto_retry_on_network_error.js override file should be changed so that it sets a global variable (e.g. a new property called TestData.retryingOnNetworkError) that indicates a call to Mongo.prototype.runCommand() aka the clientFunction is being retried. This variable should be reset/unset when the retries are finished - either because the attempt succeeded or were exhausted.
2. The runCommandWithTransactions() function in jstests/libs/txns/txn_override.js should then check this TestData.retryingOnNetworkError flag.
- 2a. If TestData.retryingOnNetworkError=false, then the runCommandWithTransactions() function in jstests/libs/txns/txn_override.js should append the pair of commandObj and makeFuncArgs to a private, file-scoped array (i.e. declared as let ops = [] in the immediate-invoked function expression for the module). If the transaction commits successfully, then the array should be emptied.
- 2b. If TestData.retryingOnNetworkError=true, then the dbName, commandName, and commandObj arguments should be ignored because #2a would have ensured they were already added to the ops array. Instead, the runCommandWithTransactions() function should iterate over the commandObj and makeFuncArgs pairs and call func.apply(conn, makeFuncArgs(commandObj) on each of them. Some care will need to be taken to increment the txnNumber field in each of the stashed operations to ensure a new transaction is started on the server.
Note: The load(.../txn_override.js) call must occur before the load(.../auto_retry_on_network_error.js) call to make it so that the runWithRetriesOnNetworkErrors() function calls the runCommandWithTransactions() function. This is due to the order in which for the two override files to be able to work together must observe and redefine the Mongo.prototype.runCommand() function.
|