Bug #20195 INSERT DELAYED with auto_increment is assigned wrong values
| Submitted: | 1 Jun 2006 11:55 | Modified: | 22 Jun 2006 14:31 |
|---|---|---|---|
| Reporter: | Peter Olsen | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | 5.0.22 | OS: | Any (All) |
| Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
[1 Jun 2006 11:55]
Peter Olsen
[1 Jun 2006 12:33]
Peter Olsen
The Binary Log for this test case
Attachment: bin-log.txt (text/plain), 2.82 KiB.
[1 Jun 2006 17:35]
Jorge del Conde
Hi!
Thanks for your bug report. I was able to reproduce this bug under FC5 using 5.0.23bk:
mysql> CREATE TABLE IF NOT EXISTS mytable (
-> id int(10) unsigned NOT NULL auto_increment,
-> info varchar(255) ,
-> PRIMARY KEY (id)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql>
mysql> # Make one delayed insert to start the separate thread
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Do some normal inserts
mysql> insert into mytable (id,info) values(null,'normal');
Query OK, 1 row affected (0.00 sec)
mysql> insert into mytable (id,info) values(null,'normal');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Check what we have so far
mysql> select * from mytable order by id;
+----+---------+
| id | info |
+----+---------+
| 1 | delayed |
| 2 | normal |
| 3 | normal |
+----+---------+
3 rows in set (0.00 sec)
mysql>
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Discarded, since the delayed-counter is 3, which is already used
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Works, since the delayed-counter is 4, which is unused
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Check what we have now
mysql> select * from mytable order by id;
+----+---------+
| id | info |
+----+---------+
| 1 | delayed |
| 2 | normal |
| 3 | normal |
| 4 | delayed |
+----+---------+
4 rows in set (0.00 sec)
mysql> insert into mytable (id,info) values(null,'normal');
Query OK, 1 row affected (0.00 sec)
mysql> insert into mytable (id,info) values(null,'normal');
Query OK, 1 row affected (0.01 sec)
mysql> insert into mytable (id,info) values(null,'normal');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Delete one of the above to make a hole
mysql> delete from mytable where id=6;
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Discarded, since the delayed-counter is 5, which is already used
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Works, since the delayed-counter is 6, which is unused (the row we deleted)
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Discarded, since the delayed-counter is 7, which is already used
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Works, since the delayed-counter is 8, which is unused
mysql> insert delayed into mytable (id,info) values(null,'delayed');
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> # Check what we have now
mysql> select * from mytable order by id;
+----+---------+
| id | info |
+----+---------+
| 1 | delayed |
| 2 | normal |
| 3 | normal |
| 4 | delayed |
| 5 | normal |
| 6 | delayed |
| 7 | normal |
| 8 | delayed |
+----+---------+
8 rows in set (0.00 sec)
mysql>
[1 Jun 2006 20:17]
Guilhem Bichot
As pointed by Mr Olsen, BUG#20043 has large connections with this one (the "delayed has its own counter" observation explains the absence of one row from the table in BUG#20043; however the absence of another row from the binlog remains a specificity of BUG#20043 so far).
[9 Jun 2006 15:42]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/7446
[13 Jun 2006 15:14]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/7573
[19 Jun 2006 0:17]
Evgeny Potemkin
Fixed in 5.0.23, 5.1.12
[20 Jun 2006 11:01]
Evgeny Potemkin
The INSERT DELAYED should not maintain its own private auto-increment counter, because this is assuming that other threads cannot insert into the table while the INSERT DELAYED thread is inserting, which is a wrong assumption.
[22 Jun 2006 14:31]
Paul DuBois
Noted in 5.0.23, 5.1.12 changelogs.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.046 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.