Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Major
-
Resolution: Unresolved
-
10.2.4
-
None
Description
--source include/have_innodb.inc
|
|
create table t1 (pk int auto_increment primary key, i int, unique (i)) engine=InnoDB; |
insert into t1 (i) values (1),(2),(3); |
insert ignore into t1 (pk, i) values (100,1); |
--echo #
|
--echo # Table before restart
|
show create table t1; |
--source include/restart_mysqld.inc
|
--echo #
|
--echo # Table after restart
|
show create table t1; |
|
drop table t1; |
# Table before restart |
show create table t1; |
Table Create Table |
t1 CREATE TABLE `t1` ( |
`pk` int(11) NOT NULL AUTO_INCREMENT, |
`i` int(11) DEFAULT NULL, |
PRIMARY KEY (`pk`), |
UNIQUE KEY `i` (`i`) |
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 |
#
|
# Table after restart |
show create table t1; |
Table Create Table |
t1 CREATE TABLE `t1` ( |
`pk` int(11) NOT NULL AUTO_INCREMENT, |
`i` int(11) DEFAULT NULL, |
PRIMARY KEY (`pk`), |
UNIQUE KEY `i` (`i`) |
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=latin1 |
Attachments
Issue Links
- relates to
-
MDEV-6076 Persistent AUTO_INCREMENT for InnoDB
-
- Closed
-
-
MDEV-20892 AUTO_INCREMENT is set lower than the max value of the primary_key
-
- Closed
-
greenman, your interpretation sounds correct to me.
It could be useful in debugging to view the current persistent auto_increment value. But generally, too many rarely used interfaces and parameters tend to be a bad idea.
The regression would be that after a failed INSERT IGNORE and a restart, there would be a "gap" in the AUTO_INCREMENT value. Another case where you can get such a "gap" is a user-initiated ROLLBACK or ROLLBACK TO SAVEPOINT. But also that requires a server restart.
Before
MDEV-6076introduced the persistent AUTO_INCREMENT in 10.2.4, we had the opposite problem that the server would not leave the "gap", but would instead perform the equivalent of SELECT MAX(auto_inc_column) when the table is first accessed. I can imagine that in a distributed system, you would definitely not want to reuse AUTO_INCREMENT values that may have been previously used somewhere else.So, this regression (gap after restart) would seem to be a desired property of
MDEV-6076; in fact, I could claim that it is the main reason to implementMDEV-6076. (The other reason would be to avoid a potentially expensive index scan to determine MAX(autoinc_col), in case there are many NULL values or delete-marked records.)