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

Expose transaction-retry-helper as session object function

    • Sharding

      We should have an easy and standard way of dealing with transient transaction errors in our integration tests.

      The ideal solution would be something on the line of with_transaction that is provided by the official python driver. A helper function exposed through the session object that takes a function and execute it inside a transaction and is capable of transparently retrying the transaction in the case of transient errors. Taking a quick look at our use-cases, it seems important to provide also the following functionality through this helper:

      1. Add an array parameter `ignoreErrors` to the function that allows to specify a list of error codes, for which we don't want to retry the transaction. This is useful for instance when we want to be sure that a transient errors is happening
      2. Add a boolean parameter `commit` to the function that allows to specify if the helper should also commit the transaction. This is helpful in those cases in which we want to perform some actions before committing the transaction.
      3. The helper function should also allow to assert on the commit transaction status. This can be implemented by making the helper function return the commit status to allow any caller to assert on that.
      4. As maria.vankeulen suggested we should limit the number of retries attempts. This will allow to catch infinite retries scenarios in our tests.

      At the moment we provide a similar helper function that has the following limitations:

      • It is not exposed as a function of the session object. This makes it difficult to find and also requires to always import `auto_retry_transaction.js` in order to use it.
      • It doesn't provide 1. It only allows to specify if the transaction should be retried on killed session.
      • It doesn't provide 2
      • It doesn't provide 3

      We recently introduced another helper function that provides 2 but is very specific and has the same problems as the more general one above.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: