Merge lp:~paul-mccullagh/maria/maria-pbxt-1009g into lp:~maria-captains/maria/5.1-converting

Proposed by Paul McCullagh
Status: Merged
Approved by: Kristian Nielsen
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~paul-mccullagh/maria/maria-pbxt-1009g
Merge into: lp:~maria-captains/maria/5.1-converting
Diff against target: 268 lines (+66/-52)
4 files modified
storage/pbxt/ChangeLog (+4/-0)
storage/pbxt/src/discover_xt.cc (+2/-2)
storage/pbxt/src/ha_pbxt.cc (+59/-49)
storage/pbxt/src/strutil_xt.cc (+1/-1)
To merge this branch: bzr merge lp:~paul-mccullagh/maria/maria-pbxt-1009g
Reviewer Review Type Date Requested Status
Kristian Nielsen Approve
Review via email: mp+16636@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul McCullagh (paul-mccullagh) wrote :

This patch fixes a bug that resulted in 2-phase commit not being used between PBXT and the binlog. This bug was a result of a hack which as added to solve a problem in an pre-release version of MySQL 5.1. The hack was removed.

Revision history for this message
Kristian Nielsen (knielsen) wrote :

Merged into lp:~maria-captains/maria/5.1-release (will later be merged into lp:maria).

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage/pbxt/ChangeLog'
2--- storage/pbxt/ChangeLog 2009-12-01 09:50:46 +0000
3+++ storage/pbxt/ChangeLog 2009-12-29 10:54:19 +0000
4@@ -1,6 +1,10 @@
5 PBXT Release Notes
6 ==================
7
8+------- 1.0.09g RC3 - 2009-12-16
9+
10+RN292: Fixed a bug that resulted in 2-phase commit not being used between PBXT and the binlog. This bug was a result of a hack which as added to solve a problem in an pre-release version of MySQL 5.1. The hack was removed.
11+
12 ------- 1.0.09f RC3 - 2009-11-30
13
14 RN291: Fixed bug #489088: On shutdown MySQL reports: [Warning] Plugin 'PBXT' will be forced to shutdown.
15
16=== modified file 'storage/pbxt/src/discover_xt.cc'
17--- storage/pbxt/src/discover_xt.cc 2009-12-16 08:13:18 +0000
18+++ storage/pbxt/src/discover_xt.cc 2009-12-29 10:54:19 +0000
19@@ -355,10 +355,10 @@
20 {
21 if (!(b_flags & HA_NOSAME))
22 return -1;
23- if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))
24+ if ((a_flags ^ b_flags) & HA_NULL_PART_KEY)
25 {
26 /* Sort NOT NULL keys before other keys */
27- return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;
28+ return (a_flags & HA_NULL_PART_KEY) ? 1 : -1;
29 }
30 if (a->name == primary_key_name)
31 return -1;
32
33=== modified file 'storage/pbxt/src/ha_pbxt.cc'
34--- storage/pbxt/src/ha_pbxt.cc 2009-11-27 15:37:02 +0000
35+++ storage/pbxt/src/ha_pbxt.cc 2009-12-29 10:54:19 +0000
36@@ -1442,7 +1442,7 @@
37 XTThreadPtr self;
38
39 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {
40- XT_PRINT1(self, "pbxt_commit all=%d\n", all);
41+ XT_PRINT2(self, "%s pbxt_commit all=%d\n", all ? "END CONN XACT" : "END STAT", all);
42
43 if (self->st_xact_data) {
44 /* There are no table locks, commit immediately in all cases
45@@ -1474,7 +1474,7 @@
46 XTThreadPtr self;
47
48 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {
49- XT_PRINT1(self, "pbxt_rollback all=%d in pbxt_commit\n", all);
50+ XT_PRINT2(self, "%s pbxt_rollback all=%d\n", all ? "CONN END XACT" : "STAT END", all);
51
52 if (self->st_xact_data) {
53 /* There are no table locks, rollback immediately in all cases
54@@ -1538,7 +1538,7 @@
55 * except when this is a statement commit with an explicit
56 * transaction (!all && !self->st_auto_commit).
57 */
58- if (all) {
59+ if (all || self->st_auto_commit) {
60 XID xid;
61
62 XT_PRINT0(self, "xt_xn_prepare in pbxt_prepare\n");
63@@ -2620,26 +2620,7 @@
64 }
65 #endif
66
67- /* GOTCHA: I have a huge problem with the transaction statement.
68- * It is not ALWAYS committed (I mean ha_commit_trans() is
69- * not always called - for example in SELECT).
70- *
71- * If I call trans_register_ha() but ha_commit_trans() is not called
72- * then MySQL thinks a transaction is still running (while
73- * I have committed the auto-transaction in ha_pbxt::external_lock()).
74- *
75- * This causes all kinds of problems, like transactions
76- * are killed when they should not be.
77- *
78- * To prevent this, I only inform MySQL that a transaction
79- * has beens started when an update is performed. I have determined that
80- * ha_commit_trans() is only guarenteed to be called if an update is done.
81- */
82- if (!pb_open_tab->ot_thread->st_stat_trans) {
83- trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
84- XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::write_row trans_register_ha all=FALSE\n");
85- pb_open_tab->ot_thread->st_stat_trans = TRUE;
86- }
87+ /* {START-STAT-HACK} previously position of start statement hack. */
88
89 xt_xlog_check_long_writer(pb_open_tab->ot_thread);
90
91@@ -2730,11 +2711,7 @@
92 XT_DISABLED_TRACE(("UPDATE tx=%d val=%d\n", (int) self->st_xact_data->xd_start_xn_id, (int) XT_GET_DISK_4(&new_data[1])));
93 //statistic_increment(ha_update_count,&LOCK_status);
94
95- if (!self->st_stat_trans) {
96- trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
97- XT_PRINT0(self, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
98- self->st_stat_trans = TRUE;
99- }
100+ /* {START-STAT-HACK} previously position of start statement hack. */
101
102 xt_xlog_check_long_writer(self);
103
104@@ -2821,11 +2798,7 @@
105 }
106 #endif
107
108- if (!pb_open_tab->ot_thread->st_stat_trans) {
109- trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
110- XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::delete_row trans_register_ha all=FALSE\n");
111- pb_open_tab->ot_thread->st_stat_trans = TRUE;
112- }
113+ /* {START-STAT-HACK} previously position of start statement hack. */
114
115 xt_xlog_check_long_writer(pb_open_tab->ot_thread);
116
117@@ -3155,15 +3128,12 @@
118
119 printf("index_init %s index %d cols req=%d/%d read_bits=%X write_bits=%X index_bits=%X\n", pb_open_tab->ot_table->tab_name->ps_path, (int) idx, pb_open_tab->ot_cols_req, pb_open_tab->ot_cols_req, (int) *table->read_set->bitmap, (int) *table->write_set->bitmap, (int) *ind->mi_col_map.bitmap);
120 #endif
121+ /* {START-STAT-HACK} previously position of start statement hack,
122+ * previous comment to code below: */
123 /* Start a statement based transaction as soon
124 * as a read is done for a modify type statement!
125 * Previously, this was done too late!
126 */
127- if (!thread->st_stat_trans) {
128- trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
129- XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
130- thread->st_stat_trans = TRUE;
131- }
132 }
133 else {
134 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);
135@@ -3612,15 +3582,12 @@
136 /* The number of columns required: */
137 if (pb_open_tab->ot_is_modify) {
138 pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE();
139+ /* {START-STAT-HACK} previously position of start statement hack,
140+ * previous comment to code below: */
141 /* Start a statement based transaction as soon
142 * as a read is done for a modify type statement!
143 * Previously, this was done too late!
144 */
145- if (!thread->st_stat_trans) {
146- trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
147- XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
148- thread->st_stat_trans = TRUE;
149- }
150 }
151 else {
152 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);
153@@ -4631,7 +4598,7 @@
154 cont_(b);
155 }
156
157- /* See (***) */
158+ /* See {IS-UPDATE-STAT} */
159 self->st_is_update = FALSE;
160
161 /* Auto begin a transaction (if one is not already running): */
162@@ -4660,7 +4627,7 @@
163 }
164
165 /*
166- * (**) GOTCHA: trans_register_ha() is not mentioned in the documentation.
167+ * {START-TRANS} GOTCHA: trans_register_ha() is not mentioned in the documentation.
168 * It must be called to inform MySQL that we have a transaction (see start_stmt).
169 *
170 * Here are some tests that confirm whether things are done correctly:
171@@ -4698,10 +4665,46 @@
172 */
173 if (!self->st_auto_commit) {
174 trans_register_ha(thd, TRUE, pbxt_hton);
175- XT_PRINT0(self, "ha_pbxt::external_lock trans_register_ha all=TRUE\n");
176+ XT_PRINT0(self, "CONN START XACT - ha_pbxt::external_lock --> trans_register_ha\n");
177 }
178 }
179
180+ /* Start a statment transaction: */
181+ /* {START-STAT-HACK} The problem that ha_commit_trans() is not
182+ * called by MySQL seems to be fixed (tests confirm this).
183+ * Here is the previous comment when this code was execute
184+ * here {START-STAT-HACK}
185+ *
186+ * GOTCHA: I have a huge problem with the transaction statement.
187+ * It is not ALWAYS committed (I mean ha_commit_trans() is
188+ * not always called - for example in SELECT).
189+ *
190+ * If I call trans_register_ha() but ha_commit_trans() is not called
191+ * then MySQL thinks a transaction is still running (while
192+ * I have committed the auto-transaction in ha_pbxt::external_lock()).
193+ *
194+ * This causes all kinds of problems, like transactions
195+ * are killed when they should not be.
196+ *
197+ * To prevent this, I only inform MySQL that a transaction
198+ * has beens started when an update is performed. I have determined that
199+ * ha_commit_trans() is only guarenteed to be called if an update is done.
200+ * --------
201+ *
202+ * So, this is the correct place to start a statement transaction.
203+ *
204+ * Note: if trans_register_ha() is not called before ha_write_row(), then
205+ * PBXT is not registered correctly as a modification transaction.
206+ * (mark_trx_read_write call in ha_write_row).
207+ * This leads to 2-phase commit not being called as it should when
208+ * binary logging is enabled.
209+ */
210+ if (!pb_open_tab->ot_thread->st_stat_trans) {
211+ trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
212+ XT_PRINT0(pb_open_tab->ot_thread, "STAT START - ha_pbxt::external_lock --> trans_register_ha\n");
213+ pb_open_tab->ot_thread->st_stat_trans = TRUE;
214+ }
215+
216 if (lock_type == F_WRLCK || self->st_xact_mode < XT_XACT_REPEATABLE_READ)
217 self->st_visible_time = self->st_database->db_xn_end_time;
218
219@@ -4826,7 +4829,7 @@
220 }
221 }
222
223- /* (***) This is required at this level!
224+ /* {IS-UPDATE-STAT} This is required at this level!
225 * No matter how often it is called, it is still the start of a
226 * statement. We need to make sure statements that are NOT mistaken
227 * for different type of statement.
228@@ -4841,7 +4844,7 @@
229 */
230 self->st_is_update = FALSE;
231
232- /* See comment (**) */
233+ /* See comment {START-TRANS} */
234 if (!self->st_xact_data) {
235 self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;
236 self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;
237@@ -4858,10 +4861,17 @@
238 }
239 if (!self->st_auto_commit) {
240 trans_register_ha(thd, TRUE, pbxt_hton);
241- XT_PRINT0(self, "ha_pbxt::start_stmt trans_register_ha all=TRUE\n");
242+ XT_PRINT0(self, "START CONN XACT - ha_pbxt::start_stmt --> trans_register_ha\n");
243 }
244 }
245
246+ /* Start a statment (see {START-STAT-HACK}): */
247+ if (!pb_open_tab->ot_thread->st_stat_trans) {
248+ trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
249+ XT_PRINT0(pb_open_tab->ot_thread, "START STAT - ha_pbxt::start_stmt --> trans_register_ha\n");
250+ pb_open_tab->ot_thread->st_stat_trans = TRUE;
251+ }
252+
253 if (pb_open_tab->ot_for_update || self->st_xact_mode < XT_XACT_REPEATABLE_READ)
254 self->st_visible_time = self->st_database->db_xn_end_time;
255
256
257=== modified file 'storage/pbxt/src/strutil_xt.cc'
258--- storage/pbxt/src/strutil_xt.cc 2009-11-24 10:55:06 +0000
259+++ storage/pbxt/src/strutil_xt.cc 2009-12-29 10:54:19 +0000
260@@ -380,7 +380,7 @@
261 /* Version number must also be set in configure.in! */
262 xtPublic c_char *xt_get_version(void)
263 {
264- return "1.0.09f RC";
265+ return "1.0.09g RC";
266 }
267
268 /* Copy and URL decode! */

Subscribers

People subscribed via source and target branches