Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retry for UniqueConstraintViolation in RouteCreate (v3) #3697

Merged

Conversation

philippthun
Copy link
Member

@philippthun philippthun commented Mar 25, 2024

The creation of internal routes depends on finding the next vip_offset. When creating multiple routes in parallel, they find the same vip_offset and only the very first write operation succeeds. All the others fail with a UniqueConstraintViolation error. For this error a retry is triggered in the VCAP::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:

Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '3' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '3' for key 'routes.routes_vip_offset_index', retrying
Duplicate entry '4' for key 'routes.routes_vip_offset_index', retrying

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 branch

  • I have run all the unit tests using bundle exec rake

  • I have run CF Acceptance Tests

The creation of internal routes depends on finding the next vip_offset.
When creating multiple routes in parallel, they find the same vip_offset
and only the very first write operation succeeds. All the others fail
with a UniqueConstraintViolation error. For this error a retry is
triggered in the VCAP::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:

  Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '1' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '2' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '3' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '3' for key 'routes.routes_vip_offset_index', retrying
  Duplicate entry '4' for key 'routes.routes_vip_offset_index', retrying

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).
Copy link
Member

@tcdowney tcdowney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

My question is, why are we even assigning VIPs to internal routes anymore? I thought that was something for Istio Copilot.
🤔 https://www.pivotaltracker.com/story/show/161849240

Update: Created #3712 to track that.

@philippthun philippthun linked an issue Apr 2, 2024 that may be closed by this pull request
@philippthun philippthun merged commit 1455319 into cloudfoundry:main Apr 11, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create route "routes_vip_offset_index" duplicate errors
2 participants