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
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
6 ------- 1.0.10 RC4 - 2009-12-18
7
8+RN296: Updated "LOCK TABLES ... READ LOCAL" behavior to be more restrictive and compatible with InnoDB
9+
10+RN296: Fixed bug #499026: START TRANSACTION WITH CONSISTENT SNAPSHOT does not work for PBXT
11+
12 RN295: PBXT tests now all run with MySQL 5.1.41.
13
14 RN294: Fixed bug #483714: a broken table can prevent other tables from opening
15
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 static int pbxt_recover(handlerton *hton, XID *xid_list, uint len);
21 static int pbxt_commit_by_xid(handlerton *hton, XID *xid);
22 static int pbxt_rollback_by_xid(handlerton *hton, XID *xid);
23+static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd);
24 #endif
25 static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine);
26 static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share);
27@@ -1146,6 +1147,7 @@
28 pbxt_hton->show_status = pbxt_show_status;
29 pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */
30 pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */
31+ pbxt_hton->start_consistent_snapshot = pbxt_start_consistent_snapshot;
32 #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)
33 pbxt_hton->get_backup_engine = pbxt_backup_engine;
34 #endif
35@@ -1424,6 +1426,28 @@
36 * internally.
37 */
38
39+static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd)
40+{
41+ int err = 0;
42+ XTThreadPtr self = ha_set_current_thread(thd, &err);
43+
44+ if (!self->st_database && pbxt_database) {
45+ xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL);
46+ }
47+
48+ if (xt_xn_begin(self)) {
49+ trans_register_ha(thd, TRUE, hton);
50+ } else {
51+ err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE);
52+ }
53+
54+ /*
55+ * As of MySQL 5.1.41 the return value is not checked, so the server might assume
56+ * everything is fine even it isn't. InnoDB returns 0 on success.
57+ */
58+ return err;
59+}
60+
61 /*
62 * Commit the PBXT transaction of the given thread.
63 * thd is the MySQL thread structure.
64@@ -4910,6 +4934,18 @@
65 */
66 THR_LOCK_DATA **ha_pbxt::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type)
67 {
68+ /*
69+ * TL_READ means concurrent INSERTs are allowed. This is a problem as in this mode
70+ * PBXT is not compatible with MyISAM which allows INSERTs but isolates them from
71+ * current "transaction" (started by LOCK TABLES, ended by UNLOCK TABLES). PBXT
72+ * used to allow INSERTs and made them visible to the locker (on commit).
73+ * While MySQL manual doesn't state anything regarding row visibility limitations
74+ * we choose to convert local locks into normal read locks for better compatibility
75+ * with MyISAM.
76+ */
77+ if (lock_type == TL_READ)
78+ lock_type = TL_READ_NO_INSERT;
79+
80 if (lock_type != TL_IGNORE && pb_lock.type == TL_UNLOCK) {
81 /* Set to TRUE for operations that require a table lock: */
82 switch (thd_sql_command(thd)) {
83
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 # on windows, copy all files from std_data into var/std_data_ln
89 mkpath("$opt_vardir/std_data_ln");
90 mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
91- }
92+ mkpath("$opt_vardir/std_data");
93+ mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data");
94+}
95
96 # Remove old log files
97 foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
98
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 c1
104 a
105 drop table t1;
106-create table t1 (a int not null, primary key(a));
107-create table t2 (a int not null, b int not null, primary key(a,b));
108-insert into t1 values (1),(2),(3),(4),(5),(6);
109-insert into t2 values (1,1),(2,1);
110-lock tables t1 read local, t2 read local;
111-select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
112-a a b
113-1 1 1
114-2 2 1
115-insert into t2 values(2,0);
116-select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
117-a a b
118-1 1 1
119-2 2 1
120-drop table t1,t2;
121-CREATE TABLE t1 (c1 varchar(250) NOT NULL);
122-CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
123-INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
124-INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
125-LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
126-SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
127-WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
128-t1c1 t2c1
129-INSERT INTO t2 VALUES ('test000001'), ('test000005');
130-SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
131-WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
132-t1c1 t2c1
133-DROP TABLE t1,t2;
134 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 Got one of the listed errors
136 create table t1 (a int, b varchar(200), c text not null) checksum=1;
137@@ -1724,63 +1696,6 @@
138 create table t1 (v varchar(65535));
139 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 set storage_engine=PBXT;
141-set @save_concurrent_insert=@@concurrent_insert;
142-set global concurrent_insert=1;
143-create table t1 (a int);
144-insert into t1 values (1),(2),(3),(4),(5);
145-lock table t1 read local;
146-insert into t1 values(6),(7);
147-unlock tables;
148-delete from t1 where a>=3 and a<=4;
149-lock table t1 read local;
150-set global concurrent_insert=2;
151-insert into t1 values (8),(9);
152-unlock tables;
153-insert into t1 values (10),(11),(12);
154-select * from t1 order by a;
155-a
156-1
157-2
158-5
159-6
160-7
161-8
162-9
163-10
164-11
165-12
166-check table t1;
167-Table Op Msg_type Msg_text
168-test.t1 check status OK
169-drop table t1;
170-create table t1 (a int, b varchar(30) default "hello");
171-insert into t1 (a) values (1),(2),(3),(4),(5);
172-lock table t1 read local;
173-insert into t1 (a) values(6),(7);
174-unlock tables;
175-delete from t1 where a>=3 and a<=4;
176-lock table t1 read local;
177-set global concurrent_insert=2;
178-insert into t1 (a) values (8),(9);
179-unlock tables;
180-insert into t1 (a) values (10),(11),(12);
181-select a from t1 order by a;
182-a
183-1
184-2
185-5
186-6
187-7
188-8
189-9
190-10
191-11
192-12
193-check table t1;
194-Table Op Msg_type Msg_text
195-test.t1 check status OK
196-drop table t1;
197-set global concurrent_insert=@save_concurrent_insert;
198 create table t1 (a int, key(a));
199 insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
200 analyze table t1;
201
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 select c1 from t1 order by c1 limit 1;
207 drop table t1;
208
209-#
210-# Bug #14400 Join could miss concurrently inserted row
211-#
212-# Partial key.
213-create table t1 (a int not null, primary key(a));
214-create table t2 (a int not null, b int not null, primary key(a,b));
215-insert into t1 values (1),(2),(3),(4),(5),(6);
216-insert into t2 values (1,1),(2,1);
217-lock tables t1 read local, t2 read local;
218-select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
219-connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
220-insert into t2 values(2,0);
221-disconnect root;
222-connection default;
223-select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
224-drop table t1,t2;
225-#
226-# Full key.
227-CREATE TABLE t1 (c1 varchar(250) NOT NULL);
228-CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1));
229-INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
230-INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
231-LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
232-SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
233- WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
234-connect (con1,localhost,root,,);
235-connection con1;
236-INSERT INTO t2 VALUES ('test000001'), ('test000005');
237-disconnect con1;
238-connection default;
239-SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
240- WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
241-DROP TABLE t1,t2;
242-
243 # End of 4.0 tests
244
245 #
246@@ -1053,63 +1019,6 @@
247
248 eval set storage_engine=$default;
249
250-#
251-# Test concurrent insert
252-# First with static record length
253-#
254-set @save_concurrent_insert=@@concurrent_insert;
255-set global concurrent_insert=1;
256-create table t1 (a int);
257-insert into t1 values (1),(2),(3),(4),(5);
258-lock table t1 read local;
259-connect (con1,localhost,root,,);
260-connection con1;
261-# Insert in table without hole
262-insert into t1 values(6),(7);
263-connection default;
264-unlock tables;
265-delete from t1 where a>=3 and a<=4;
266-lock table t1 read local;
267-connection con1;
268-set global concurrent_insert=2;
269-# Insert in table with hole -> Should insert at end
270-insert into t1 values (8),(9);
271-connection default;
272-unlock tables;
273-# Insert into hole
274-insert into t1 values (10),(11),(12);
275-select * from t1 order by a; # PBXT requires order
276-check table t1;
277-drop table t1;
278-disconnect con1;
279-
280-# Same test with dynamic record length
281-create table t1 (a int, b varchar(30) default "hello");
282-insert into t1 (a) values (1),(2),(3),(4),(5);
283-lock table t1 read local;
284-connect (con1,localhost,root,,);
285-connection con1;
286-# Insert in table without hole
287-insert into t1 (a) values(6),(7);
288-connection default;
289-unlock tables;
290-delete from t1 where a>=3 and a<=4;
291-lock table t1 read local;
292-connection con1;
293-set global concurrent_insert=2;
294-# Insert in table with hole -> Should insert at end
295-insert into t1 (a) values (8),(9);
296-connection default;
297-unlock tables;
298-# Insert into hole
299-insert into t1 (a) values (10),(11),(12);
300-select a from t1 order by a; # PBXT requires order
301-check table t1;
302-drop table t1;
303-disconnect con1;
304-set global concurrent_insert=@save_concurrent_insert;
305-
306-
307 # BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
308 # different statistics on the same table with NULL values.
309 create table t1 (a int, key(a));

Subscribers

People subscribed via source and target branches