-
Notifications
You must be signed in to change notification settings - Fork 102
fix restore auto increment ID overflow #458
base: master
Are you sure you want to change the base?
Conversation
pkg/restore/db.go
Outdated
// auto inc id overflow | ||
autoIncID := table.Info.AutoIncID | ||
if table.Info.AutoIncID < 0 { | ||
autoIncID = math.MaxInt64 |
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.
what about bigint unsigned
columns?
create table a (id bigint unsigned primary key auto_increment);
insert into a values (12345678901234567890);
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.
I was wondering that the allocator can work well 🤔️,it set the allocator with unsigned=false https://github.com/pingcap/br/blob/master/pkg/backup/client.go#L261
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.
How about add globalAutoID -= 1
after https://github.com/pingcap/br/blob/master/pkg/backup/client.go#L277?
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.
I'm not sure what's the purpose of subtracting 1 😅
Any update? |
da989b0
to
d3e2067
Compare
/run-integration-tests |
37ba16c
to
36e8045
Compare
…into fix_restore_overflow
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.
rest LGTM
autoIncID = uint64(table.Info.AutoIncID) | ||
} else { | ||
setValSQL = fmt.Sprintf(setValFormat, table.Info.Sequence.MaxValue) | ||
autoIncID = uint64(table.Info.AutoIncID) | ||
} |
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.
the two branches are the same? so this is simply
}
autoIncID = uint64(table.Info.AutoIncID)
?
What problem does this PR solve?
when auto_increment id reached max.Int64, it can backs up success. but failed when restore. we should handle this situation.
What is changed and how it works?
if autoIncID overflowed. change is to max.Int64, to keep consistency with backup cluster.
Check List
Tests
Code changes
Side effects
Related changes
Release Note