Merge lp:~vkolesnikov/pbxt/pbxt-bug-499026 into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-bug-499026
Merge into: lp:pbxt
Diff against target: 273 lines (+211/-1)
6 files modified
ChangeLog (+2/-0)
src/ha_pbxt.cc (+24/-0)
test/mysql-test/pbxt-test-run.pl (+3/-1)
test/mysql-test/r/pbxt_snapshot.result (+76/-0)
test/mysql-test/t/pbxt_snapshot-master.opt (+2/-0)
test/mysql-test/t/pbxt_snapshot.test (+104/-0)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-bug-499026
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+16448@code.launchpad.net
To post a comment you must log in.

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-21 21:17:12 +0000
4@@ -3,6 +3,8 @@
5
6 ------- 1.0.10 RC4 - 2009-12-18
7
8+RN296: Fixed bug #499026: START TRANSACTION WITH CONSISTENT SNAPSHOT does not work for PBXT
9+
10 RN295: PBXT tests now all run with MySQL 5.1.41.
11
12 RN294: Fixed bug #483714: a broken table can prevent other tables from opening
13
14=== modified file 'src/ha_pbxt.cc'
15--- src/ha_pbxt.cc 2009-12-07 11:15:02 +0000
16+++ src/ha_pbxt.cc 2009-12-21 21:17:12 +0000
17@@ -113,6 +113,7 @@
18 static int pbxt_recover(handlerton *hton, XID *xid_list, uint len);
19 static int pbxt_commit_by_xid(handlerton *hton, XID *xid);
20 static int pbxt_rollback_by_xid(handlerton *hton, XID *xid);
21+static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd);
22 #endif
23 static void ha_aquire_exclusive_use(XTThreadPtr self, XTSharePtr share, ha_pbxt *mine);
24 static void ha_release_exclusive_use(XTThreadPtr self, XTSharePtr share);
25@@ -1146,6 +1147,7 @@
26 pbxt_hton->show_status = pbxt_show_status;
27 pbxt_hton->flags = HTON_NO_FLAGS; /* HTON_CAN_RECREATE - Without this flags TRUNCATE uses delete_all_rows() */
28 pbxt_hton->slot = (uint)-1; /* assign invald value, so we know when it's inited later */
29+ pbxt_hton->start_consistent_snapshot = pbxt_start_consistent_snapshot;
30 #if defined(MYSQL_SUPPORTS_BACKUP) && defined(XT_ENABLE_ONLINE_BACKUP)
31 pbxt_hton->get_backup_engine = pbxt_backup_engine;
32 #endif
33@@ -1424,6 +1426,28 @@
34 * internally.
35 */
36
37+static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd)
38+{
39+ int err = 0;
40+ XTThreadPtr self = ha_set_current_thread(thd, &err);
41+
42+ if (!self->st_database && pbxt_database) {
43+ xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL);
44+ }
45+
46+ if (xt_xn_begin(self)) {
47+ trans_register_ha(thd, TRUE, hton);
48+ } else {
49+ err = xt_ha_pbxt_thread_error_for_mysql(thd, self, FALSE);
50+ }
51+
52+ /*
53+ * As of MySQL 5.1.41 the return value is not checked, so the server might assume
54+ * everything is fine even it isn't. InnoDB returns 0 on success.
55+ */
56+ return err;
57+}
58+
59 /*
60 * Commit the PBXT transaction of the given thread.
61 * thd is the MySQL thread structure.
62
63=== modified file 'test/mysql-test/pbxt-test-run.pl'
64--- test/mysql-test/pbxt-test-run.pl 2009-12-16 21:54:25 +0000
65+++ test/mysql-test/pbxt-test-run.pl 2009-12-21 21:17:12 +0000
66@@ -2482,7 +2482,9 @@
67 # on windows, copy all files from std_data into var/std_data_ln
68 mkpath("$opt_vardir/std_data_ln");
69 mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln");
70- }
71+ mkpath("$opt_vardir/std_data");
72+ mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data");
73+}
74
75 # Remove old log files
76 foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
77
78=== added file 'test/mysql-test/r/pbxt_snapshot.result'
79--- test/mysql-test/r/pbxt_snapshot.result 1970-01-01 00:00:00 +0000
80+++ test/mysql-test/r/pbxt_snapshot.result 2009-12-21 21:17:12 +0000
81@@ -0,0 +1,76 @@
82+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
83+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=pbxt;
84+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
85+BEGIN;
86+SELECT * FROM t1;
87+a
88+BEGIN;
89+INSERT INTO t1 VALUES (1);
90+COMMIT;
91+BEGIN;
92+INSERT INTO t2 VALUES (1);
93+COMMIT;
94+SELECT * FROM t1;
95+a
96+SELECT * FROM t2;
97+a
98+1
99+COMMIT;
100+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
101+START TRANSACTION WITH CONSISTENT SNAPSHOT;
102+SELECT * FROM t1;
103+a
104+1
105+BEGIN;
106+INSERT INTO t1 VALUES (2);
107+COMMIT;
108+BEGIN;
109+INSERT INTO t2 VALUES (2);
110+COMMIT;
111+SELECT * FROM t1;
112+a
113+1
114+SELECT * FROM t2;
115+a
116+1
117+COMMIT;
118+DROP TABLE t1;
119+DROP TABLE t2;
120+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=pbxt;
121+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=innodb;
122+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
123+BEGIN;
124+SELECT * FROM t1;
125+a
126+BEGIN;
127+INSERT INTO t1 VALUES (1);
128+COMMIT;
129+BEGIN;
130+INSERT INTO t2 VALUES (1);
131+COMMIT;
132+SELECT * FROM t1;
133+a
134+SELECT * FROM t2;
135+a
136+1
137+COMMIT;
138+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
139+START TRANSACTION WITH CONSISTENT SNAPSHOT;
140+SELECT * FROM t1;
141+a
142+1
143+BEGIN;
144+INSERT INTO t1 VALUES (2);
145+COMMIT;
146+BEGIN;
147+INSERT INTO t2 VALUES (2);
148+COMMIT;
149+SELECT * FROM t1;
150+a
151+1
152+SELECT * FROM t2;
153+a
154+1
155+COMMIT;
156+DROP TABLE t1;
157+DROP TABLE t2;
158
159=== added file 'test/mysql-test/t/pbxt_snapshot-master.opt'
160--- test/mysql-test/t/pbxt_snapshot-master.opt 1970-01-01 00:00:00 +0000
161+++ test/mysql-test/t/pbxt_snapshot-master.opt 2009-12-21 21:17:12 +0000
162@@ -0,0 +1,2 @@
163+--loose-innodb
164+--pbxt-support-xa=0
165
166=== added file 'test/mysql-test/t/pbxt_snapshot.test'
167--- test/mysql-test/t/pbxt_snapshot.test 1970-01-01 00:00:00 +0000
168+++ test/mysql-test/t/pbxt_snapshot.test 2009-12-21 21:17:12 +0000
169@@ -0,0 +1,104 @@
170+# --source include/have_pbxt.inc
171+# --source include/have_innodb.inc
172+
173+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=innodb;
174+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=pbxt;
175+
176+connect(con1,localhost,root,,);
177+connect(con2,localhost,root,,);
178+
179+connection default;
180+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
181+BEGIN;
182+SELECT * FROM t1;
183+
184+connection con1;
185+BEGIN;
186+INSERT INTO t1 VALUES (1);
187+COMMIT;
188+
189+connection con2;
190+BEGIN;
191+INSERT INTO t2 VALUES (1);
192+COMMIT;
193+
194+connection default;
195+SELECT * FROM t1;
196+SELECT * FROM t2;
197+COMMIT;
198+
199+# Now try again with START TRANSACTION WITH CONSISTENT SNAPSHOT.
200+connection default;
201+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
202+START TRANSACTION WITH CONSISTENT SNAPSHOT;
203+SELECT * FROM t1;
204+
205+connection con1;
206+BEGIN;
207+INSERT INTO t1 VALUES (2);
208+COMMIT;
209+
210+connection con2;
211+BEGIN;
212+INSERT INTO t2 VALUES (2);
213+COMMIT;
214+
215+connection default;
216+SELECT * FROM t1;
217+SELECT * FROM t2;
218+COMMIT;
219+
220+DROP TABLE t1;
221+DROP TABLE t2;
222+
223+# Try again with table types reversed.
224+CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=pbxt;
225+CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=innodb;
226+
227+connection default;
228+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
229+BEGIN;
230+SELECT * FROM t1;
231+
232+connection con1;
233+BEGIN;
234+INSERT INTO t1 VALUES (1);
235+COMMIT;
236+
237+connection con2;
238+BEGIN;
239+INSERT INTO t2 VALUES (1);
240+COMMIT;
241+
242+connection default;
243+SELECT * FROM t1;
244+SELECT * FROM t2;
245+COMMIT;
246+
247+# Now try again with START TRANSACTION WITH CONSISTENT SNAPSHOT.
248+connection default;
249+SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
250+START TRANSACTION WITH CONSISTENT SNAPSHOT;
251+SELECT * FROM t1;
252+
253+connection con1;
254+BEGIN;
255+INSERT INTO t1 VALUES (2);
256+COMMIT;
257+
258+connection con2;
259+BEGIN;
260+INSERT INTO t2 VALUES (2);
261+COMMIT;
262+
263+connection default;
264+SELECT * FROM t1;
265+SELECT * FROM t2;
266+COMMIT;
267+
268+DROP TABLE t1;
269+DROP TABLE t2;
270+
271+--disable_query_log
272+drop database pbxt;
273+--enable_query_log

Subscribers

People subscribed via source and target branches