#At file:///home/marko/innobase/dev/mysql2a/5.1-innodb/ based on revid:marko.makela@strippedl6wzcjlld3rm
3705 Marko Mäkelä 2011-02-09
Bug#60049 Updates can leave garbage in unique secondary indexes
This is a preliminary patch. This should be fixed in the InnoDB plugin too.
The mysql-test script needs a better way of ensuring
that the shutdown was completed and the data files were flushed.
Also the server restart at end is unnecessary.
added:
mysql-test/suite/innodb/r/innodb_bug60049.result
mysql-test/suite/innodb/t/innodb_bug60049-master.opt
mysql-test/suite/innodb/t/innodb_bug60049.test
modified:
storage/innobase/row/row0ins.c
=== added file 'mysql-test/suite/innodb/r/innodb_bug60049.result'
--- a/mysql-test/suite/innodb/r/innodb_bug60049.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug60049.result revid:marko.makela@stripped209151520-2pxv3gzbmhra4cbq
@@ -0,0 +1,8 @@
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+@@innodb_fast_shutdown
+0
+Last record of ID_IND root page (9):
+1808000018050074000000000000000c5359535f464f524549474e5f434f4c53
=== added file 'mysql-test/suite/innodb/t/innodb_bug60049-master.opt'
--- a/mysql-test/suite/innodb/t/innodb_bug60049-master.opt 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug60049-master.opt revid:marko.makela@oracle.com-20110209151520-2pxv3gzbmhra4cbq
@@ -0,0 +1 @@
+--innodb_fast_shutdown=0
\ No newline at end of file
=== added file 'mysql-test/suite/innodb/t/innodb_bug60049.test'
--- a/mysql-test/suite/innodb/t/innodb_bug60049.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug60049.test revid:marko.makela@stripped10209151520-2pxv3gzbmhra4cbq
@@ -0,0 +1,37 @@
+# Bug #60049 Updates can leave garbage in unique secondary indexes
+# This test requires a fresh server start-up.
+
+-- source include/have_innodb.inc
+
+CREATE TABLE t(a INT)ENGINE=InnoDB;
+RENAME TABLE t TO u;
+DROP TABLE u;
+SELECT @@innodb_fast_shutdown;
+let $MYSQLD_DATADIR=`select @@datadir`;
+
+# Shut down the server
+-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- shutdown_server 10
+-- source include/wait_until_disconnected.inc
+
+# Check the tail of ID_IND (SYS_TABLES.ID)
+let IBDATA1=$MYSQLD_DATADIR/ibdata1;
+perl;
+my $file = $ENV{'IBDATA1'};
+open(FILE, "<$file") || die "Unable to open $file";
+# Read DICT_HDR_TABLE_IDS, the root page number of ID_IND (SYS_TABLES.ID).
+seek(FILE, 7*16384+38+36, 0) || die "Unable to seek $file";
+die unless read(FILE, $_, 4) == 4;
+my $sys_tables_id_root = unpack "N";
+print "Last record of ID_IND root page ($sys_tables_id_root):\n";
+# This should be the last record in ID_IND. Dump it in hexadecimal.
+seek(FILE, $sys_tables_id_root*16384 + 152, 0) || die "Unable to seek $file";
+read(FILE, $_, 32) || die "Unable to read $file";
+close(FILE);
+print unpack("H*"),"\n";
+EOF
+
+# Restart the server.
+-- exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+-- enable_reconnect
+-- source include/wait_until_connected_again.inc
=== modified file 'storage/innobase/row/row0ins.c'
--- a/storage/innobase/row/row0ins.c revid:marko.makela@stripped0208105623-qs8ol6wzcjlld3rm
+++ b/storage/innobase/row/row0ins.c revid:marko.makela@stripped3gzbmhra4cbq
@@ -1917,10 +1917,8 @@ ulint
row_ins_must_modify(
/*================*/
/* out: 0 if no update, ROW_INS_PREV if
- previous should be updated; currently we
- do the search so that only the low_match
- record can match enough to the search tuple,
- not the next record */
+ previous should be updated, ROW_INS_NEXT
+ if next should be updated */
btr_cur_t* cursor) /* in: B-tree cursor */
{
ulint enough_match;
@@ -1945,6 +1943,16 @@ row_ins_must_modify(
}
}
+ if (cursor->up_match >= enough_match) {
+
+ rec = page_rec_get_next(btr_cur_get_rec(cursor));
+
+ if (!page_rec_is_supremum(rec)) {
+
+ return(ROW_INS_NEXT);
+ }
+ }
+
return(0);
}
Attachment: [text/bzr-bundle] bzr/marko.makela@oracle.com-20110209151520-2pxv3gzbmhra4cbq.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-innodb branch (marko.makela:3705) Bug#60049 | marko.makela | 9 Feb |