-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
executor: only rebase auto increment ID when needed #7515
Changes from 5 commits
1a3841a
455b37b
4a9a6ae
908193d
c9e10da
220689c
61c7e11
ff9d03a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2031,3 +2031,28 @@ func (s *testSuite) TestReplaceLog(c *C) { | |
|
||
tk.MustQuery(`admin cleanup index testLog b;`).Check(testkit.Rows("1")) | ||
} | ||
|
||
// For issue 7422. | ||
// There is no need to do the rebase when updating a record if the auto-increment ID not changed. | ||
// This could make the auto ID increasing speed slower. | ||
func (s *testSuite) TestRebaseIfNeeded(c *C) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe need add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already have the cases at line 595 to 627. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I means rebase auto_increment in |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
tk.MustExec(`create table t (a int not null primary key auto_increment, b int unique key);`) | ||
tk.MustExec(`insert into t (b) values (1);`) | ||
|
||
s.ctx = mock.NewContext() | ||
s.ctx.Store = s.store | ||
tbl, err := s.domain.InfoSchema().TableByName(model.NewCIStr("test"), model.NewCIStr("t")) | ||
c.Assert(err, IsNil) | ||
c.Assert(s.ctx.NewTxn(), IsNil) | ||
// AddRecord directly here will skip to rebase the auto ID in the insert statement, | ||
// which could simulate another TiDB adds a large auto ID. | ||
_, err = tbl.AddRecord(s.ctx, types.MakeDatums(30001, 2), false) | ||
c.Assert(err, IsNil) | ||
c.Assert(s.ctx.Txn().Commit(context.Background()), IsNil) | ||
|
||
tk.MustExec(`update t set b = 3 where a = 30001;`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments to this case, |
||
tk.MustExec(`insert into t (b) values (4);`) | ||
tk.MustQuery(`select a from t where b = 4;`).Check(testkit.Rows("2")) | ||
} |
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
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.
If cmp == 0, we still need to set the last_insert_id. Actually, we already have the cases at line 595 to 627.
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.
if
cmp != 0
still can not change last_insert_id when underon duplicate key update
.tidb:
mysql:
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.
Oh, you're right. I think we need another pr to fix it.