[JUJU-4504] Implement timeout-based retry method for txns #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch is part of the set of patches aiming to fix https://bugs.launchpad.net/juju/+bug/2031631.
The idea here is to implement a transaction retry mechanism similar to the one being used in the official mongodb driver, i.e. a 120 seconds timeout for transactions to finish or waiting while being retried.
The context passed to the mgo Run method is necessary in order to cancel the actual request that's being executed by mgo either after timeout, either because the user (juju) cancels the passed context.
Tests have been fixed and some have been deleted since they are no longer relevant (we don't retry for a fixed number of times, instead we retry until timeout).
For some more context, here is the high-level picture of how we handle the retry (from
juju
tomgo
viatxn
) by @hpidcock :Note: The original PR on juju is juju/juju#16159 and on
juju/mgo
is juju/mgo#27.