Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

fix restore auto increment ID overflow #458

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

3pointer
Copy link
Collaborator

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

  • Integration test

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch

Release Note

  • No release note

// auto inc id overflow
autoIncID := table.Info.AutoIncID
if table.Info.AutoIncID < 0 {
autoIncID = math.MaxInt64
Copy link
Collaborator

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);

Copy link
Collaborator Author

@3pointer 3pointer Aug 14, 2020

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@kennytm kennytm Aug 16, 2020

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 😅

pkg/restore/db.go Outdated Show resolved Hide resolved
pkg/restore/db.go Outdated Show resolved Hide resolved
@overvenus
Copy link
Member

Any update?

@overvenus overvenus added type/bug-fix component/restore and removed type/bug Something isn't working labels Jan 6, 2021
@3pointer
Copy link
Collaborator Author

/run-integration-tests

Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

rest LGTM

Comment on lines +178 to 181
autoIncID = uint64(table.Info.AutoIncID)
} else {
setValSQL = fmt.Sprintf(setValFormat, table.Info.Sequence.MaxValue)
autoIncID = uint64(table.Info.AutoIncID)
}
Copy link
Collaborator

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)

?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants