Merge lp:~vkolesnikov/pbxt/pbxt-lock-tables-read-local into lp:pbxt
- pbxt-lock-tables-read-local
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PBXT Core | Pending | ||
Review via email: mp+16500@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'ChangeLog' | |||
2 | --- ChangeLog 2009-12-18 11:12:37 +0000 | |||
3 | +++ ChangeLog 2009-12-22 20:21:17 +0000 | |||
4 | @@ -3,6 +3,10 @@ | |||
5 | 3 | 3 | ||
6 | 4 | ------- 1.0.10 RC4 - 2009-12-18 | 4 | ------- 1.0.10 RC4 - 2009-12-18 |
7 | 5 | 5 | ||
8 | 6 | RN296: Updated "LOCK TABLES ... READ LOCAL" behavior to be more restrictive and compatible with InnoDB | ||
9 | 7 | |||
10 | 8 | RN296: Fixed bug #499026: START TRANSACTION WITH CONSISTENT SNAPSHOT does not work for PBXT | ||
11 | 9 | |||
12 | 6 | RN295: PBXT tests now all run with MySQL 5.1.41. | 10 | RN295: PBXT tests now all run with MySQL 5.1.41. |
13 | 7 | 11 | ||
14 | 8 | RN294: Fixed bug #483714: a broken table can prevent other tables from opening | 12 | RN294: Fixed bug #483714: a broken table can prevent other tables from opening |
15 | 9 | 13 | ||
16 | === modified file 'src/ha_pbxt.cc' | |||
17 | --- src/ha_pbxt.cc 2009-12-07 11:15:02 +0000 | |||
18 | +++ src/ha_pbxt.cc 2009-12-22 20:21:17 +0000 | |||
19 | @@ -113,6 +113,7 @@ | |||
20 | 113 | static int pbxt_recover(handlerton *hton, XID *xid_list, uint len); | 113 | static int pbxt_recover(handlerton *hton, XID *xid_list, uint len); |
21 | 114 | static int pbxt_commit_by_xid(handlerton *hton, XID *xid); | 114 | static int pbxt_commit_by_xid(handlerton *hton, XID *xid); |
22 | 115 | static int pbxt_rollback_by_xid(handlerton *hton, XID *xid); | 115 | static int pbxt_rollback_by_xid(handlerton *hton, XID *xid); |
23 | 116 | static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd); | ||
24 | 116 | #endif | 117 | #endif |
25 | 117 | static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine); | 118 | static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine); |
26 | 118 | static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share); | 119 | static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share); |
27 | @@ -1146,6 +1147,7 @@ | |||
28 | 1146 | pbxt_hton->show_status = pbxt_show_status; | 1147 | pbxt_hton->show_status = pbxt_show_status; |
29 | 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() */ |
30 | 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 */ |
31 | 1150 | pbxt_hton->start_consistent_snapshot = pbxt_start_consistent_snapshot; | ||
32 | 1149 | #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP) | 1151 | #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP) |
33 | 1150 | pbxt_hton->get_backup_engine = pbxt_backup_engine; | 1152 | pbxt_hton->get_backup_engine = pbxt_backup_engine; |
34 | 1151 | #endif | 1153 | #endif |
35 | @@ -1424,6 +1426,28 @@ | |||
36 | 1424 | * internally. | 1426 | * internally. |
37 | 1425 | */ | 1427 | */ |
38 | 1426 | 1428 | ||
39 | 1429 | static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd) | ||
40 | 1430 | { | ||
41 | 1431 | int err = 0; | ||
42 | 1432 | XTThreadPtr self = ha_set_current_thread(thd, &err); | ||
43 | 1433 | |||
44 | 1434 | if (!self->st_database && pbxt_database) { | ||
45 | 1435 | xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL); | ||
46 | 1436 | } | ||
47 | 1437 | |||
48 | 1438 | if (xt_xn_begin(self)) { | ||
49 | 1439 | trans_register_ha(thd, TRUE, hton); | ||
50 | 1440 | } else { | ||
51 | 1441 | err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE); | ||
52 | 1442 | } | ||
53 | 1443 | |||
54 | 1444 | /* | ||
55 | 1445 | * As of MySQL 5.1.41 the return value is not checked, so the server might assume | ||
56 | 1446 | * everything is fine even it isn't. InnoDB returns 0 on success. | ||
57 | 1447 | */ | ||
58 | 1448 | return err; | ||
59 | 1449 | } | ||
60 | 1450 | |||
61 | 1427 | /* | 1451 | /* |
62 | 1428 | * Commit the PBXT transaction of the given thread. | 1452 | * Commit the PBXT transaction of the given thread. |
63 | 1429 | * thd is the MySQL thread structure. | 1453 | * thd is the MySQL thread structure. |
64 | @@ -4910,6 +4934,18 @@ | |||
65 | 4910 | */ | 4934 | */ |
66 | 4911 | THR_LOCK_DATA **ha_pbxt::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) | 4935 | THR_LOCK_DATA **ha_pbxt::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) |
67 | 4912 | { | 4936 | { |
68 | 4937 | /* | ||
69 | 4938 | * TL_READ means concurrent INSERTs are allowed. This is a problem as in this mode | ||
70 | 4939 | * PBXT is not compatible with MyISAM which allows INSERTs but isolates them from | ||
71 | 4940 | * current "transaction" (started by LOCK TABLES, ended by UNLOCK TABLES). PBXT | ||
72 | 4941 | * used to allow INSERTs and made them visible to the locker (on commit). | ||
73 | 4942 | * While MySQL manual doesn't state anything regarding row visibility limitations | ||
74 | 4943 | * we choose to convert local locks into normal read locks for better compatibility | ||
75 | 4944 | * with MyISAM. | ||
76 | 4945 | */ | ||
77 | 4946 | if (lock_type == TL_READ) | ||
78 | 4947 | lock_type = TL_READ_NO_INSERT; | ||
79 | 4948 | |||
80 | 4913 | if (lock_type != TL_IGNORE && pb_lock.type == TL_UNLOCK) { | 4949 | if (lock_type != TL_IGNORE && pb_lock.type == TL_UNLOCK) { |
81 | 4914 | /* Set to TRUE for operations that require a table lock: */ | 4950 | /* Set to TRUE for operations that require a table lock: */ |
82 | 4915 | switch (thd_sql_command(thd)) { | 4951 | switch (thd_sql_command(thd)) { |
83 | 4916 | 4952 | ||
84 | === modified file 'test/mysql-test/pbxt-test-run.pl' | |||
85 | --- test/mysql-test/pbxt-test-run.pl 2009-12-16 21:54:25 +0000 | |||
86 | +++ test/mysql-test/pbxt-test-run.pl 2009-12-22 20:21:17 +0000 | |||
87 | @@ -2482,7 +2482,9 @@ | |||
88 | 2482 | # on windows, copy all files from std_data into var/std_data_ln | 2482 | # on windows, copy all files from std_data into var/std_data_ln |
89 | 2483 | mkpath("$opt_vardir/std_data_ln"); | 2483 | mkpath("$opt_vardir/std_data_ln"); |
90 | 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"); |
92 | 2485 | } | 2485 | mkpath("$opt_vardir/std_data"); |
93 | 2486 | mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data"); | ||
94 | 2487 | } | ||
95 | 2486 | 2488 | ||
96 | 2487 | # Remove old log files | 2489 | # Remove old log files |
97 | 2488 | foreach my $name (glob("r/*.progress r/*.log r/*.warnings")) | 2490 | foreach my $name (glob("r/*.progress r/*.log r/*.warnings")) |
98 | 2489 | 2491 | ||
99 | === modified file 'test/mysql-test/r/myisam.result' | |||
100 | --- test/mysql-test/r/myisam.result 2009-04-03 19:39:12 +0000 | |||
101 | +++ test/mysql-test/r/myisam.result 2009-12-22 20:21:17 +0000 | |||
102 | @@ -525,34 +525,6 @@ | |||
103 | 525 | c1 | 525 | c1 |
104 | 526 | a | 526 | a |
105 | 527 | drop table t1; | 527 | drop table t1; |
106 | 528 | create table t1 (a int not null, primary key(a)); | ||
107 | 529 | create table t2 (a int not null, b int not null, primary key(a,b)); | ||
108 | 530 | insert into t1 values (1),(2),(3),(4),(5),(6); | ||
109 | 531 | insert into t2 values (1,1),(2,1); | ||
110 | 532 | lock tables t1 read local, t2 read local; | ||
111 | 533 | select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; | ||
112 | 534 | a a b | ||
113 | 535 | 1 1 1 | ||
114 | 536 | 2 2 1 | ||
115 | 537 | insert into t2 values(2,0); | ||
116 | 538 | select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; | ||
117 | 539 | a a b | ||
118 | 540 | 1 1 1 | ||
119 | 541 | 2 2 1 | ||
120 | 542 | drop table t1,t2; | ||
121 | 543 | CREATE TABLE t1 (c1 varchar(250) NOT NULL); | ||
122 | 544 | CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1)); | ||
123 | 545 | INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003'); | ||
124 | 546 | INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004'); | ||
125 | 547 | LOCK TABLES t1 READ LOCAL, t2 READ LOCAL; | ||
126 | 548 | SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 | ||
127 | 549 | WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; | ||
128 | 550 | t1c1 t2c1 | ||
129 | 551 | INSERT INTO t2 VALUES ('test000001'), ('test000005'); | ||
130 | 552 | SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 | ||
131 | 553 | WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; | ||
132 | 554 | t1c1 t2c1 | ||
133 | 555 | DROP TABLE t1,t2; | ||
134 | 556 | CREATE 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; | 528 | CREATE 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; |
135 | 557 | Got one of the listed errors | 529 | Got one of the listed errors |
136 | 558 | create table t1 (a int, b varchar(200), c text not null) checksum=1; | 530 | create table t1 (a int, b varchar(200), c text not null) checksum=1; |
137 | @@ -1724,63 +1696,6 @@ | |||
138 | 1724 | create table t1 (v varchar(65535)); | 1696 | create table t1 (v varchar(65535)); |
139 | 1725 | ERROR 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 | 1697 | ERROR 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 |
140 | 1726 | set storage_engine=PBXT; | 1698 | set storage_engine=PBXT; |
141 | 1727 | set @save_concurrent_insert=@@concurrent_insert; | ||
142 | 1728 | set global concurrent_insert=1; | ||
143 | 1729 | create table t1 (a int); | ||
144 | 1730 | insert into t1 values (1),(2),(3),(4),(5); | ||
145 | 1731 | lock table t1 read local; | ||
146 | 1732 | insert into t1 values(6),(7); | ||
147 | 1733 | unlock tables; | ||
148 | 1734 | delete from t1 where a>=3 and a<=4; | ||
149 | 1735 | lock table t1 read local; | ||
150 | 1736 | set global concurrent_insert=2; | ||
151 | 1737 | insert into t1 values (8),(9); | ||
152 | 1738 | unlock tables; | ||
153 | 1739 | insert into t1 values (10),(11),(12); | ||
154 | 1740 | select * from t1 order by a; | ||
155 | 1741 | a | ||
156 | 1742 | 1 | ||
157 | 1743 | 2 | ||
158 | 1744 | 5 | ||
159 | 1745 | 6 | ||
160 | 1746 | 7 | ||
161 | 1747 | 8 | ||
162 | 1748 | 9 | ||
163 | 1749 | 10 | ||
164 | 1750 | 11 | ||
165 | 1751 | 12 | ||
166 | 1752 | check table t1; | ||
167 | 1753 | Table Op Msg_type Msg_text | ||
168 | 1754 | test.t1 check status OK | ||
169 | 1755 | drop table t1; | ||
170 | 1756 | create table t1 (a int, b varchar(30) default "hello"); | ||
171 | 1757 | insert into t1 (a) values (1),(2),(3),(4),(5); | ||
172 | 1758 | lock table t1 read local; | ||
173 | 1759 | insert into t1 (a) values(6),(7); | ||
174 | 1760 | unlock tables; | ||
175 | 1761 | delete from t1 where a>=3 and a<=4; | ||
176 | 1762 | lock table t1 read local; | ||
177 | 1763 | set global concurrent_insert=2; | ||
178 | 1764 | insert into t1 (a) values (8),(9); | ||
179 | 1765 | unlock tables; | ||
180 | 1766 | insert into t1 (a) values (10),(11),(12); | ||
181 | 1767 | select a from t1 order by a; | ||
182 | 1768 | a | ||
183 | 1769 | 1 | ||
184 | 1770 | 2 | ||
185 | 1771 | 5 | ||
186 | 1772 | 6 | ||
187 | 1773 | 7 | ||
188 | 1774 | 8 | ||
189 | 1775 | 9 | ||
190 | 1776 | 10 | ||
191 | 1777 | 11 | ||
192 | 1778 | 12 | ||
193 | 1779 | check table t1; | ||
194 | 1780 | Table Op Msg_type Msg_text | ||
195 | 1781 | test.t1 check status OK | ||
196 | 1782 | drop table t1; | ||
197 | 1783 | set global concurrent_insert=@save_concurrent_insert; | ||
198 | 1784 | create table t1 (a int, key(a)); | 1699 | create table t1 (a int, key(a)); |
199 | 1785 | insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL); | 1700 | insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL); |
200 | 1786 | analyze table t1; | 1701 | analyze table t1; |
201 | 1787 | 1702 | ||
202 | === modified file 'test/mysql-test/t/myisam.test' | |||
203 | --- test/mysql-test/t/myisam.test 2009-06-02 17:55:55 +0000 | |||
204 | +++ test/mysql-test/t/myisam.test 2009-12-22 20:21:17 +0000 | |||
205 | @@ -490,40 +490,6 @@ | |||
206 | 490 | select c1 from t1 order by c1 limit 1; | 490 | select c1 from t1 order by c1 limit 1; |
207 | 491 | drop table t1; | 491 | drop table t1; |
208 | 492 | 492 | ||
209 | 493 | # | ||
210 | 494 | # Bug #14400 Join could miss concurrently inserted row | ||
211 | 495 | # | ||
212 | 496 | # Partial key. | ||
213 | 497 | create table t1 (a int not null, primary key(a)); | ||
214 | 498 | create table t2 (a int not null, b int not null, primary key(a,b)); | ||
215 | 499 | insert into t1 values (1),(2),(3),(4),(5),(6); | ||
216 | 500 | insert into t2 values (1,1),(2,1); | ||
217 | 501 | lock tables t1 read local, t2 read local; | ||
218 | 502 | select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; | ||
219 | 503 | connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); | ||
220 | 504 | insert into t2 values(2,0); | ||
221 | 505 | disconnect root; | ||
222 | 506 | connection default; | ||
223 | 507 | select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; | ||
224 | 508 | drop table t1,t2; | ||
225 | 509 | # | ||
226 | 510 | # Full key. | ||
227 | 511 | CREATE TABLE t1 (c1 varchar(250) NOT NULL); | ||
228 | 512 | CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1)); | ||
229 | 513 | INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003'); | ||
230 | 514 | INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004'); | ||
231 | 515 | LOCK TABLES t1 READ LOCAL, t2 READ LOCAL; | ||
232 | 516 | SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 | ||
233 | 517 | WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; | ||
234 | 518 | connect (con1,localhost,root,,); | ||
235 | 519 | connection con1; | ||
236 | 520 | INSERT INTO t2 VALUES ('test000001'), ('test000005'); | ||
237 | 521 | disconnect con1; | ||
238 | 522 | connection default; | ||
239 | 523 | SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 | ||
240 | 524 | WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; | ||
241 | 525 | DROP TABLE t1,t2; | ||
242 | 526 | |||
243 | 527 | # End of 4.0 tests | 493 | # End of 4.0 tests |
244 | 528 | 494 | ||
245 | 529 | # | 495 | # |
246 | @@ -1053,63 +1019,6 @@ | |||
247 | 1053 | 1019 | ||
248 | 1054 | eval set storage_engine=$default; | 1020 | eval set storage_engine=$default; |
249 | 1055 | 1021 | ||
250 | 1056 | # | ||
251 | 1057 | # Test concurrent insert | ||
252 | 1058 | # First with static record length | ||
253 | 1059 | # | ||
254 | 1060 | set @save_concurrent_insert=@@concurrent_insert; | ||
255 | 1061 | set global concurrent_insert=1; | ||
256 | 1062 | create table t1 (a int); | ||
257 | 1063 | insert into t1 values (1),(2),(3),(4),(5); | ||
258 | 1064 | lock table t1 read local; | ||
259 | 1065 | connect (con1,localhost,root,,); | ||
260 | 1066 | connection con1; | ||
261 | 1067 | # Insert in table without hole | ||
262 | 1068 | insert into t1 values(6),(7); | ||
263 | 1069 | connection default; | ||
264 | 1070 | unlock tables; | ||
265 | 1071 | delete from t1 where a>=3 and a<=4; | ||
266 | 1072 | lock table t1 read local; | ||
267 | 1073 | connection con1; | ||
268 | 1074 | set global concurrent_insert=2; | ||
269 | 1075 | # Insert in table with hole -> Should insert at end | ||
270 | 1076 | insert into t1 values (8),(9); | ||
271 | 1077 | connection default; | ||
272 | 1078 | unlock tables; | ||
273 | 1079 | # Insert into hole | ||
274 | 1080 | insert into t1 values (10),(11),(12); | ||
275 | 1081 | select * from t1 order by a; # PBXT requires order | ||
276 | 1082 | check table t1; | ||
277 | 1083 | drop table t1; | ||
278 | 1084 | disconnect con1; | ||
279 | 1085 | |||
280 | 1086 | # Same test with dynamic record length | ||
281 | 1087 | create table t1 (a int, b varchar(30) default "hello"); | ||
282 | 1088 | insert into t1 (a) values (1),(2),(3),(4),(5); | ||
283 | 1089 | lock table t1 read local; | ||
284 | 1090 | connect (con1,localhost,root,,); | ||
285 | 1091 | connection con1; | ||
286 | 1092 | # Insert in table without hole | ||
287 | 1093 | insert into t1 (a) values(6),(7); | ||
288 | 1094 | connection default; | ||
289 | 1095 | unlock tables; | ||
290 | 1096 | delete from t1 where a>=3 and a<=4; | ||
291 | 1097 | lock table t1 read local; | ||
292 | 1098 | connection con1; | ||
293 | 1099 | set global concurrent_insert=2; | ||
294 | 1100 | # Insert in table with hole -> Should insert at end | ||
295 | 1101 | insert into t1 (a) values (8),(9); | ||
296 | 1102 | connection default; | ||
297 | 1103 | unlock tables; | ||
298 | 1104 | # Insert into hole | ||
299 | 1105 | insert into t1 (a) values (10),(11),(12); | ||
300 | 1106 | select a from t1 order by a; # PBXT requires order | ||
301 | 1107 | check table t1; | ||
302 | 1108 | drop table t1; | ||
303 | 1109 | disconnect con1; | ||
304 | 1110 | set global concurrent_insert=@save_concurrent_insert; | ||
305 | 1111 | |||
306 | 1112 | |||
307 | 1113 | # BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce | 1022 | # BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce |
308 | 1114 | # different statistics on the same table with NULL values. | 1023 | # different statistics on the same table with NULL values. |
309 | 1115 | create table t1 (a int, key(a)); | 1024 | create table t1 (a int, key(a)); |
all tests now pass!