-
-
Notifications
You must be signed in to change notification settings - Fork 537
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
reset auto increment counter on dolt_reset('--hard')
#8319
Conversation
@coffeegoddd DOLT
|
@coffeegoddd DOLT
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
// AcquireTableLock acquires the auto increment lock on a table, and returns a callback function to release the lock. | ||
// Depending on the value of the `innodb_autoinc_lock_mode` system variable, the engine may need to acquire and hold | ||
// the lock for the duration of an insert statement. | ||
AcquireTableLock(ctx *sql.Context, tableName string) (func(), error) | ||
// InitWithRoots fills the AutoIncrementTracker with values at the specified root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(minor) Might be helpful to explain the behavior when multiple roots are present – currently it sounds like it's only for one root. For example, telling the caller that auto_inc sequence values are pulled out of each root, in order, and initialized for every table in each root.
When calling
dolt_reset(--hard)
, we don't properly reload the auto increment value from the global tracker.The bug is a side effect from maintaining auto increment value between branches. We track the last greatest auto increment value across all branches in the session, and dropping a table sets the previous auto_increment value to 0.
The fix is to get the tracker to reload values when resetting.
Some notable behavior here is that a
dolt_reset
over insert will not reset the auto_increment tracker.fixes: #8272