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

vttablet sequence: next N values can return overlapping values under certain circumstances #5590

Closed
sougou opened this issue Dec 18, 2019 · 0 comments · Fixed by #5591
Closed

Comments

@sougou
Copy link
Contributor

sougou commented Dec 18, 2019

In this use case, MySQL is externally managed, like RDS, which does not support fast failovers. In this case, one can use a second vttablet of type REPLICA pointed at the master. During software rollout, one can use a "failover" mechanism to update the vttablets without incurring downtime.

In the above situation, if there is a network partition, two vttablets can end up thinking that they are masters. If so, they can race on generating sequences and step over each other.

This bug can also be trigerred by someone directly updating next_id. It's also possible that someone could update next_id to a lower value that can mess things up even further.

The current implementation assumes that next_id cannot change underneath. So, vttablet continues to iterate from current NextVal. Instead, all we have to do is validate the current LastVal against next_id, and correct the system accordingly.

sougou added a commit to planetscale/vitess that referenced this issue Jan 3, 2020
Fixes vitessio#5590

Previously the nextval code assumed that next_id will be changed
externally. As explained in the bug, this can now happen with the
new use cases.

This change ensures that vttablet will work correctly even if
next_id was changed.

Signed-off-by: Sugu Sougoumarane <[email protected]>
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 a pull request may close this issue.

1 participant