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

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-bug-509968
Merge into: lp:pbxt
Diff against target: 150 lines (+60/-22)
4 files modified
ChangeLog (+2/-0)
src/ha_pbxt.cc (+37/-22)
test/mysql-test/r/pbxt_snapshot.result (+9/-0)
test/mysql-test/t/pbxt_snapshot.test (+12/-0)
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-bug-509968
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+17809@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 2010-01-20 15:18:02 +0000
3+++ ChangeLog 2010-01-21 11:41:12 +0000
4@@ -3,6 +3,8 @@
5
6 ------- 1.0.10e RC4 - Not yet released
7
8+RN300: Fixed bug #509968: START TRANSACTION WITH CONSISTENT SNAPSHOT breaks transactional flow.
9+
10 RN299: Fixed bug #509218: Server asserts with Assertion `mutex->__data.__owner == 0' failed on high concurrency OLTP test.
11
12 ------- 1.0.10d RC4 - 2010-01-11
13
14=== modified file 'src/ha_pbxt.cc'
15--- src/ha_pbxt.cc 2010-01-11 12:55:59 +0000
16+++ src/ha_pbxt.cc 2010-01-21 11:41:12 +0000
17@@ -477,6 +477,25 @@
18 return removed;
19 }
20
21+static inline void thd_init_xact(THD *thd, XTThreadPtr self, bool set_table_trans)
22+{
23+ self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;
24+ self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;
25+ self->st_auto_commit = (thd_test_options(thd,(OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
26+ if (set_table_trans) {
27+#ifdef DRIZZLED
28+ self->st_table_trans = FALSE;
29+#else
30+ self->st_table_trans = thd_sql_command(thd) == SQLCOM_LOCK_TABLES;
31+#endif
32+ }
33+ self->st_abort_trans = FALSE;
34+ self->st_stat_ended = FALSE;
35+ self->st_stat_trans = FALSE;
36+ XT_PRINT0(self, "xt_xn_begin\n");
37+ xt_xres_wait_for_recovery(self, XT_RECOVER_SWEPT);
38+}
39+
40 /*
41 * -----------------------------------------------------------------------
42 * PUBLIC FUNCTIONS
43@@ -1424,6 +1443,17 @@
44 *
45 * 3. If in BEGIN/END we must call ha_rollback() if we abort the transaction
46 * internally.
47+ *
48+ * NOTE ON CONSISTENT SNAPSHOTS:
49+ *
50+ * PBXT itself doesn't need this functiona as its transaction mechanism provides
51+ * consistent snapshots for all transactions by default. This function is needed
52+ * only for multi-engine cases like this:
53+ *
54+ * CREATE TABLE t1 ... ENGINE=INNODB
55+ * CREATE TABLE t2 ... ENGINE=PBXT
56+ * START TRANSACTION WITH CONSISTENT SNAPSHOT
57+ * SELECT * FROM t1 <-- at this point we need to know about the snapshot
58 */
59
60 static int pbxt_start_consistent_snapshot(handlerton *hton, THD *thd)
61@@ -1435,6 +1465,8 @@
62 xt_ha_open_database_of_table(self, (XTPathStrPtr) NULL);
63 }
64
65+ thd_init_xact(thd, self, true);
66+
67 if (xt_xn_begin(self)) {
68 trans_register_ha(thd, TRUE, hton);
69 } else {
70@@ -4631,19 +4663,8 @@
71 (void) ASSERT_NS(ISO_READ_UNCOMMITTED == XT_XACT_UNCOMMITTED_READ);
72 (void) ASSERT_NS(ISO_SERIALIZABLE == XT_XACT_SERIALIZABLE);
73
74- self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;
75- self->st_ignore_fkeys = (thd_test_options(thd,OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;
76- self->st_auto_commit = (thd_test_options(thd, (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
77-#ifdef DRIZZLED
78- self->st_table_trans = FALSE;
79-#else
80- self->st_table_trans = thd_sql_command(thd) == SQLCOM_LOCK_TABLES;
81-#endif
82- self->st_abort_trans = FALSE;
83- self->st_stat_ended = FALSE;
84- self->st_stat_trans = FALSE;
85- XT_PRINT0(self, "xt_xn_begin\n");
86- xt_xres_wait_for_recovery(self, XT_RECOVER_SWEPT);
87+ thd_init_xact(thd, self, true);
88+
89 if (!xt_xn_begin(self)) {
90 err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key);
91 pb_ex_in_use = 0;
92@@ -4870,15 +4891,9 @@
93
94 /* See comment {START-TRANS} */
95 if (!self->st_xact_data) {
96- self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;
97- self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;
98- self->st_auto_commit = (thd_test_options(thd,(OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) == 0;
99- /* self->st_table_trans = not set here! */
100- self->st_abort_trans = FALSE;
101- self->st_stat_ended = FALSE;
102- self->st_stat_trans = FALSE;
103- XT_PRINT0(self, "xt_xn_begin\n");
104- xt_xres_wait_for_recovery(self, XT_RECOVER_SWEPT);
105+
106+ thd_init_xact(thd, self, false);
107+
108 if (!xt_xn_begin(self)) {
109 err = xt_ha_pbxt_thread_error_for_mysql(thd, self, pb_ignore_dup_key);
110 goto complete;
111
112=== modified file 'test/mysql-test/r/pbxt_snapshot.result'
113--- test/mysql-test/r/pbxt_snapshot.result 2009-12-21 19:11:35 +0000
114+++ test/mysql-test/r/pbxt_snapshot.result 2010-01-21 11:41:12 +0000
115@@ -74,3 +74,12 @@
116 COMMIT;
117 DROP TABLE t1;
118 DROP TABLE t2;
119+CREATE TABLE t1 (i INT) ENGINE=PBXT;
120+SELECT * FROM t1;
121+i
122+START TRANSACTION WITH CONSISTENT SNAPSHOT;
123+INSERT INTO t1 VALUES (1);
124+ROLLBACK;
125+SELECT * FROM t1;
126+i
127+DROP TABLE t1;
128
129=== modified file 'test/mysql-test/t/pbxt_snapshot.test'
130--- test/mysql-test/t/pbxt_snapshot.test 2009-12-21 19:11:35 +0000
131+++ test/mysql-test/t/pbxt_snapshot.test 2010-01-21 11:41:12 +0000
132@@ -99,6 +99,18 @@
133 DROP TABLE t1;
134 DROP TABLE t2;
135
136+# bug 509968: START TRANSACTION WITH CONSISTENT SNAPSHOT breaks transactional flow
137+# happened because XTThread data was not inited properly and auto-commit flag
138+# (raised by the SELECT precedding the transaction) was not reset
139+
140+CREATE TABLE t1 (i INT) ENGINE=PBXT;
141+SELECT * FROM t1;
142+START TRANSACTION WITH CONSISTENT SNAPSHOT;
143+INSERT INTO t1 VALUES (1);
144+ROLLBACK;
145+SELECT * FROM t1;
146+DROP TABLE t1;
147+
148 --disable_query_log
149 drop database pbxt;
150 --enable_query_log

Subscribers

People subscribed via source and target branches