Merge lp:~vkolesnikov/pbxt/pbxt-lock-tables-read-local into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-lock-tables-read-local
Merge into: lp:pbxt
Diff against target: 309 lines (+43/-177)
5 files modified
ChangeLog (+4/-0)
src/ha_pbxt.cc (+36/-0)
test/mysql-test/pbxt-test-run.pl (+3/-1)
test/mysql-test/r/myisam.result (+0/-85)
test/mysql-test/t/myisam.test (+0/-91)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-lock-tables-read-local
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+16500@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

all tests now pass!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ChangeLog'
--- ChangeLog 2009-12-18 11:12:37 +0000
+++ ChangeLog 2009-12-22 20:21:17 +0000
@@ -3,6 +3,10 @@
33
4------- 1.0.10 RC4 - 2009-12-184------- 1.0.10 RC4 - 2009-12-18
55
6RN296: Updated "LOCK TABLES ... READ LOCAL" behavior to be more restrictive and compatible with InnoDB
7
8RN296: Fixed bug #499026: START TRANSACTION WITH CONSISTENT SNAPSHOT does not work for PBXT
9
6RN295: PBXT tests now all run with MySQL 5.1.41.10RN295: PBXT tests now all run with MySQL 5.1.41.
711
8RN294: Fixed bug #483714: a broken table can prevent other tables from opening12RN294: Fixed bug #483714: a broken table can prevent other tables from opening
913
=== modified file 'src/ha_pbxt.cc'
--- src/ha_pbxt.cc 2009-12-07 11:15:02 +0000
+++ src/ha_pbxt.cc 2009-12-22 20:21:17 +0000
@@ -113,6 +113,7 @@
113static int pbxt_recover(handlerton *hton, XID *xid_list, uint len);113static int pbxt_recover(handlerton *hton, XID *xid_list, uint len);
114static int pbxt_commit_by_xid(handlerton *hton, XID *xid);114static int pbxt_commit_by_xid(handlerton *hton, XID *xid);
115static int pbxt_rollback_by_xid(handlerton *hton, XID *xid);115static int pbxt_rollback_by_xid(handlerton *hton, XID *xid);
116static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd);
116#endif117#endif
117static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine);118static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine);
118static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share);119static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share);
@@ -1146,6 +1147,7 @@
1146 pbxt_hton->show_status = pbxt_show_status;1147 pbxt_hton->show_status = pbxt_show_status;
1147 pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */1148 pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */
1148 pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */1149 pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */
1150 pbxt_hton->start_consistent_snapshot = pbxt_start_consistent_snapshot;
1149#if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)1151#if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)
1150 pbxt_hton->get_backup_engine = pbxt_backup_engine;1152 pbxt_hton->get_backup_engine = pbxt_backup_engine;
1151#endif1153#endif
@@ -1424,6 +1426,28 @@
1424 * internally.1426 * internally.
1425 */1427 */
14261428
1429static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd)
1430{
1431 int err = 0;
1432 XTThreadPtr self = ha_set_current_thread(thd, &err);
1433
1434 if (!self->st_database && pbxt_database) {
1435 xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL);
1436 }
1437
1438 if (xt_xn_begin(self)) {
1439 trans_register_ha(thd, TRUE, hton);
1440 } else {
1441 err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE);
1442 }
1443
1444 /*
1445 * As of MySQL 5.1.41 the return value is not checked, so the server might assume
1446 * everything is fine even it isn't. InnoDB returns 0 on success.
1447 */
1448 return err;
1449}
1450
1427/*1451/*
1428 * Commit the PBXT transaction of the given thread.1452 * Commit the PBXT transaction of the given thread.
1429 * thd is the MySQL thread structure.1453 * thd is the MySQL thread structure.
@@ -4910,6 +4934,18 @@
4910 */4934 */
4911THR_LOCK_DATA **ha_pbxt::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)4935THR_LOCK_DATA **ha_pbxt::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)
4912{4936{
4937 /*
4938 * TL_READ means concurrent INSERTs are allowed. This is a problem as in this mode
4939 * PBXT is not compatible with MyISAM which allows INSERTs but isolates them from
4940 * current "transaction" (started by LOCK TABLES, ended by UNLOCK TABLES). PBXT
4941 * used to allow INSERTs and made them visible to the locker (on commit).
4942 * While MySQL manual doesn't state anything regarding row visibility limitations
4943 * we choose to convert local locks into normal read locks for better compatibility
4944 * with MyISAM.
4945 */
4946 if (lock_type == TL_READ)
4947 lock_type = TL_READ_NO_INSERT;
4948
4913 if (lock_type != TL_IGNORE && pb_lock.type == TL_UNLOCK) {4949 if (lock_type != TL_IGNORE && pb_lock.type == TL_UNLOCK) {
4914 /* Set to TRUE for operations that require a table lock: */4950 /* Set to TRUE for operations that require a table lock: */
4915 switch (thd_sql_command(thd)) {4951 switch (thd_sql_command(thd)) {
49164952
=== modified file 'test/mysql-test/pbxt-test-run.pl'
--- test/mysql-test/pbxt-test-run.pl 2009-12-16 21:54:25 +0000
+++ test/mysql-test/pbxt-test-run.pl 2009-12-22 20:21:17 +0000
@@ -2482,7 +2482,9 @@
2482 # on windows, copy all files from std_data into var/std_data_ln2482 # on windows, copy all files from std_data into var/std_data_ln
2483 mkpath("$opt_vardir/std_data_ln");2483 mkpath("$opt_vardir/std_data_ln");
2484 mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");2484 mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
2485 }2485 mkpath("$opt_vardir/std_data");
2486 mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data");
2487}
24862488
2487 # Remove old log files2489 # Remove old log files
2488 foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))2490 foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
24892491
=== modified file 'test/mysql-test/r/myisam.result'
--- test/mysql-test/r/myisam.result 2009-04-03 19:39:12 +0000
+++ test/mysql-test/r/myisam.result 2009-12-22 20:21:17 +0000
@@ -525,34 +525,6 @@
525c1525c1
526a526a
527drop table t1;527drop table t1;
528create table t1 (a int not null, primary key(a));
529create table t2 (a int not null, b int not null, primary key(a,b));
530insert into t1 values (1),(2),(3),(4),(5),(6);
531insert into t2 values (1,1),(2,1);
532lock tables t1 read local, t2 read local;
533select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
534a a b
5351 1 1
5362 2 1
537insert into t2 values(2,0);
538select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
539a a b
5401 1 1
5412 2 1
542drop table t1,t2;
543CREATE TABLE t1 (c1 varchar(250) NOT NULL);
544CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
545INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
546INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
547LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
548SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
549WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
550t1c1 t2c1
551INSERT INTO t2 VALUES ('test000001'), ('test000005');
552SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
553WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
554t1c1 t2c1
555DROP TABLE t1,t2;
556CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=pbxt;528CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=pbxt;
557Got one of the listed errors529Got one of the listed errors
558create table t1 (a int, b varchar(200), c text not null) checksum=1;530create table t1 (a int, b varchar(200), c text not null) checksum=1;
@@ -1724,63 +1696,6 @@
1724create table t1 (v varchar(65535));1696create table t1 (v varchar(65535));
1725ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs1697ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
1726set storage_engine=PBXT;1698set storage_engine=PBXT;
1727set @save_concurrent_insert=@@concurrent_insert;
1728set global concurrent_insert=1;
1729create table t1 (a int);
1730insert into t1 values (1),(2),(3),(4),(5);
1731lock table t1 read local;
1732insert into t1 values(6),(7);
1733unlock tables;
1734delete from t1 where a>=3 and a<=4;
1735lock table t1 read local;
1736set global concurrent_insert=2;
1737insert into t1 values (8),(9);
1738unlock tables;
1739insert into t1 values (10),(11),(12);
1740select * from t1 order by a;
1741a
17421
17432
17445
17456
17467
17478
17489
174910
175011
175112
1752check table t1;
1753Table Op Msg_type Msg_text
1754test.t1 check status OK
1755drop table t1;
1756create table t1 (a int, b varchar(30) default "hello");
1757insert into t1 (a) values (1),(2),(3),(4),(5);
1758lock table t1 read local;
1759insert into t1 (a) values(6),(7);
1760unlock tables;
1761delete from t1 where a>=3 and a<=4;
1762lock table t1 read local;
1763set global concurrent_insert=2;
1764insert into t1 (a) values (8),(9);
1765unlock tables;
1766insert into t1 (a) values (10),(11),(12);
1767select a from t1 order by a;
1768a
17691
17702
17715
17726
17737
17748
17759
177610
177711
177812
1779check table t1;
1780Table Op Msg_type Msg_text
1781test.t1 check status OK
1782drop table t1;
1783set global concurrent_insert=@save_concurrent_insert;
1784create table t1 (a int, key(a));1699create table t1 (a int, key(a));
1785insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);1700insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
1786analyze table t1;1701analyze table t1;
17871702
=== modified file 'test/mysql-test/t/myisam.test'
--- test/mysql-test/t/myisam.test 2009-06-02 17:55:55 +0000
+++ test/mysql-test/t/myisam.test 2009-12-22 20:21:17 +0000
@@ -490,40 +490,6 @@
490select c1 from t1 order by c1 limit 1;490select c1 from t1 order by c1 limit 1;
491drop table t1;491drop table t1;
492492
493#
494# Bug #14400 Join could miss concurrently inserted row
495#
496# Partial key.
497create table t1 (a int not null, primary key(a));
498create table t2 (a int not null, b int not null, primary key(a,b));
499insert into t1 values (1),(2),(3),(4),(5),(6);
500insert into t2 values (1,1),(2,1);
501lock tables t1 read local, t2 read local;
502select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
503connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
504insert into t2 values(2,0);
505disconnect root;
506connection default;
507select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
508drop table t1,t2;
509#
510# Full key.
511CREATE TABLE t1 (c1 varchar(250) NOT NULL);
512CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
513INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
514INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
515LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
516SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
517 WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
518connect (con1,localhost,root,,);
519connection con1;
520INSERT INTO t2 VALUES ('test000001'), ('test000005');
521disconnect con1;
522connection default;
523SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
524 WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
525DROP TABLE t1,t2;
526
527# End of 4.0 tests493# End of 4.0 tests
528494
529#495#
@@ -1053,63 +1019,6 @@
10531019
1054eval set storage_engine=$default;1020eval set storage_engine=$default;
10551021
1056#
1057# Test concurrent insert
1058# First with static record length
1059#
1060set @save_concurrent_insert=@@concurrent_insert;
1061set global concurrent_insert=1;
1062create table t1 (a int);
1063insert into t1 values (1),(2),(3),(4),(5);
1064lock table t1 read local;
1065connect (con1,localhost,root,,);
1066connection con1;
1067# Insert in table without hole
1068insert into t1 values(6),(7);
1069connection default;
1070unlock tables;
1071delete from t1 where a>=3 and a<=4;
1072lock table t1 read local;
1073connection con1;
1074set global concurrent_insert=2;
1075# Insert in table with hole -> Should insert at end
1076insert into t1 values (8),(9);
1077connection default;
1078unlock tables;
1079# Insert into hole
1080insert into t1 values (10),(11),(12);
1081select * from t1 order by a; # PBXT requires order
1082check table t1;
1083drop table t1;
1084disconnect con1;
1085
1086# Same test with dynamic record length
1087create table t1 (a int, b varchar(30) default "hello");
1088insert into t1 (a) values (1),(2),(3),(4),(5);
1089lock table t1 read local;
1090connect (con1,localhost,root,,);
1091connection con1;
1092# Insert in table without hole
1093insert into t1 (a) values(6),(7);
1094connection default;
1095unlock tables;
1096delete from t1 where a>=3 and a<=4;
1097lock table t1 read local;
1098connection con1;
1099set global concurrent_insert=2;
1100# Insert in table with hole -> Should insert at end
1101insert into t1 (a) values (8),(9);
1102connection default;
1103unlock tables;
1104# Insert into hole
1105insert into t1 (a) values (10),(11),(12);
1106select a from t1 order by a; # PBXT requires order
1107check table t1;
1108drop table t1;
1109disconnect con1;
1110set global concurrent_insert=@save_concurrent_insert;
1111
1112
1113# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce1022# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
1114# different statistics on the same table with NULL values.1023# different statistics on the same table with NULL values.
1115create table t1 (a int, key(a));1024create table t1 (a int, key(a));

Subscribers

People subscribed via source and target branches