Fix retry for UniqueConstraintViolation in RouteCreate (v3) #3697
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.
The creation of internal routes depends on finding the next
vip_offset
. When creating multiple routes in parallel, they find the samevip_offset
and only the very first write operation succeeds. All the others fail with aUniqueConstraintViolation
error. For this error a retry is triggered in theVCAP::CloudController::RouteCreate
action (v3).This retry did not work due to a bug (
undefined local variable or method 'user_audit_info'
). Besides fixing this bug a test has been added to ensure that the parallel creation of internal routes is working.When running 5 parallel threads and each thread is creating an internal route, the following logs are produced:
This indicates that all the write operations are being executed at the same point in time and only one of them succeeds whereas the others are failing, i.e. 4 out of 5. For each retry there is one conflicting route less, so the number of errors goes down from 4 to 3 to 2 to 1 until the last route could be saved (after 4 retries).
I have reviewed the contributing guide
I have viewed, signed, and submitted the Contributor License Agreement
I have made this pull request to the
main
branchI have run all the unit tests using
bundle exec rake
I have run CF Acceptance Tests