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
=== modified file 'storage/pbxt/ChangeLog'
--- storage/pbxt/ChangeLog 2009-12-01 09:50:46 +0000
+++ storage/pbxt/ChangeLog 2009-12-29 10:54:19 +0000
@@ -1,6 +1,10 @@
1PBXT Release Notes1PBXT Release Notes
2==================2==================
33
4------- 1.0.09g RC3 - 2009-12-16
5
6RN292: 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.
7
4------- 1.0.09f RC3 - 2009-11-308------- 1.0.09f RC3 - 2009-11-30
59
6RN291: Fixed bug #489088: On shutdown MySQL reports: [Warning] Plugin 'PBXT' will be forced to shutdown.10RN291: Fixed bug #489088: On shutdown MySQL reports: [Warning] Plugin 'PBXT' will be forced to shutdown.
711
=== modified file 'storage/pbxt/src/discover_xt.cc'
--- storage/pbxt/src/discover_xt.cc 2009-12-16 08:13:18 +0000
+++ storage/pbxt/src/discover_xt.cc 2009-12-29 10:54:19 +0000
@@ -355,10 +355,10 @@
355 {355 {
356 if (!(b_flags & HA_NOSAME))356 if (!(b_flags & HA_NOSAME))
357 return -1;357 return -1;
358 if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY))358 if ((a_flags ^ b_flags) & HA_NULL_PART_KEY)
359 {359 {
360 /* Sort NOT NULL keys before other keys */360 /* Sort NOT NULL keys before other keys */
361 return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1;361 return (a_flags & HA_NULL_PART_KEY) ? 1 : -1;
362 }362 }
363 if (a->name == primary_key_name)363 if (a->name == primary_key_name)
364 return -1;364 return -1;
365365
=== modified file 'storage/pbxt/src/ha_pbxt.cc'
--- storage/pbxt/src/ha_pbxt.cc 2009-11-27 15:37:02 +0000
+++ storage/pbxt/src/ha_pbxt.cc 2009-12-29 10:54:19 +0000
@@ -1442,7 +1442,7 @@
1442 XTThreadPtr self;1442 XTThreadPtr self;
14431443
1444 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {1444 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {
1445 XT_PRINT1(self, "pbxt_commit all=%d\n", all);1445 XT_PRINT2(self, "%s pbxt_commit all=%d\n", all ? "END CONN XACT" : "END STAT", all);
14461446
1447 if (self->st_xact_data) {1447 if (self->st_xact_data) {
1448 /* There are no table locks, commit immediately in all cases1448 /* There are no table locks, commit immediately in all cases
@@ -1474,7 +1474,7 @@
1474 XTThreadPtr self;1474 XTThreadPtr self;
14751475
1476 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {1476 if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) {
1477 XT_PRINT1(self, "pbxt_rollback all=%d in pbxt_commit\n", all);1477 XT_PRINT2(self, "%s pbxt_rollback all=%d\n", all ? "CONN END XACT" : "STAT END", all);
14781478
1479 if (self->st_xact_data) {1479 if (self->st_xact_data) {
1480 /* There are no table locks, rollback immediately in all cases1480 /* There are no table locks, rollback immediately in all cases
@@ -1538,7 +1538,7 @@
1538 * except when this is a statement commit with an explicit1538 * except when this is a statement commit with an explicit
1539 * transaction (!all && !self->st_auto_commit).1539 * transaction (!all && !self->st_auto_commit).
1540 */1540 */
1541 if (all) {1541 if (all || self->st_auto_commit) {
1542 XID xid;1542 XID xid;
15431543
1544 XT_PRINT0(self, "xt_xn_prepare in pbxt_prepare\n");1544 XT_PRINT0(self, "xt_xn_prepare in pbxt_prepare\n");
@@ -2620,26 +2620,7 @@
2620 }2620 }
2621#endif2621#endif
26222622
2623 /* GOTCHA: I have a huge problem with the transaction statement.2623 /* {START-STAT-HACK} previously position of start statement hack. */
2624 * It is not ALWAYS committed (I mean ha_commit_trans() is
2625 * not always called - for example in SELECT).
2626 *
2627 * If I call trans_register_ha() but ha_commit_trans() is not called
2628 * then MySQL thinks a transaction is still running (while
2629 * I have committed the auto-transaction in ha_pbxt::external_lock()).
2630 *
2631 * This causes all kinds of problems, like transactions
2632 * are killed when they should not be.
2633 *
2634 * To prevent this, I only inform MySQL that a transaction
2635 * has beens started when an update is performed. I have determined that
2636 * ha_commit_trans() is only guarenteed to be called if an update is done.
2637 */
2638 if (!pb_open_tab->ot_thread->st_stat_trans) {
2639 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
2640 XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::write_row trans_register_ha all=FALSE\n");
2641 pb_open_tab->ot_thread->st_stat_trans = TRUE;
2642 }
26432624
2644 xt_xlog_check_long_writer(pb_open_tab->ot_thread);2625 xt_xlog_check_long_writer(pb_open_tab->ot_thread);
26452626
@@ -2730,11 +2711,7 @@
2730 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])));2711 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])));
2731 //statistic_increment(ha_update_count,&LOCK_status);2712 //statistic_increment(ha_update_count,&LOCK_status);
27322713
2733 if (!self->st_stat_trans) {2714 /* {START-STAT-HACK} previously position of start statement hack. */
2734 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
2735 XT_PRINT0(self, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
2736 self->st_stat_trans = TRUE;
2737 }
27382715
2739 xt_xlog_check_long_writer(self);2716 xt_xlog_check_long_writer(self);
27402717
@@ -2821,11 +2798,7 @@
2821 }2798 }
2822#endif2799#endif
28232800
2824 if (!pb_open_tab->ot_thread->st_stat_trans) {2801 /* {START-STAT-HACK} previously position of start statement hack. */
2825 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
2826 XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::delete_row trans_register_ha all=FALSE\n");
2827 pb_open_tab->ot_thread->st_stat_trans = TRUE;
2828 }
28292802
2830 xt_xlog_check_long_writer(pb_open_tab->ot_thread);2803 xt_xlog_check_long_writer(pb_open_tab->ot_thread);
28312804
@@ -3155,15 +3128,12 @@
31553128
3156 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);3129 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);
3157#endif3130#endif
3131 /* {START-STAT-HACK} previously position of start statement hack,
3132 * previous comment to code below: */
3158 /* Start a statement based transaction as soon3133 /* Start a statement based transaction as soon
3159 * as a read is done for a modify type statement!3134 * as a read is done for a modify type statement!
3160 * Previously, this was done too late!3135 * Previously, this was done too late!
3161 */3136 */
3162 if (!thread->st_stat_trans) {
3163 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
3164 XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
3165 thread->st_stat_trans = TRUE;
3166 }
3167 }3137 }
3168 else {3138 else {
3169 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);3139 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);
@@ -3612,15 +3582,12 @@
3612 /* The number of columns required: */3582 /* The number of columns required: */
3613 if (pb_open_tab->ot_is_modify) {3583 if (pb_open_tab->ot_is_modify) {
3614 pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE();3584 pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE();
3585 /* {START-STAT-HACK} previously position of start statement hack,
3586 * previous comment to code below: */
3615 /* Start a statement based transaction as soon3587 /* Start a statement based transaction as soon
3616 * as a read is done for a modify type statement!3588 * as a read is done for a modify type statement!
3617 * Previously, this was done too late!3589 * Previously, this was done too late!
3618 */3590 */
3619 if (!thread->st_stat_trans) {
3620 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
3621 XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n");
3622 thread->st_stat_trans = TRUE;
3623 }
3624 }3591 }
3625 else {3592 else {
3626 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);3593 pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set);
@@ -4631,7 +4598,7 @@
4631 cont_(b);4598 cont_(b);
4632 }4599 }
46334600
4634 /* See (***) */4601 /* See {IS-UPDATE-STAT} */
4635 self->st_is_update = FALSE;4602 self->st_is_update = FALSE;
46364603
4637 /* Auto begin a transaction (if one is not already running): */4604 /* Auto begin a transaction (if one is not already running): */
@@ -4660,7 +4627,7 @@
4660 }4627 }
46614628
4662 /*4629 /*
4663 * (**) GOTCHA: trans_register_ha() is not mentioned in the documentation.4630 * {START-TRANS} GOTCHA: trans_register_ha() is not mentioned in the documentation.
4664 * It must be called to inform MySQL that we have a transaction (see start_stmt).4631 * It must be called to inform MySQL that we have a transaction (see start_stmt).
4665 *4632 *
4666 * Here are some tests that confirm whether things are done correctly:4633 * Here are some tests that confirm whether things are done correctly:
@@ -4698,10 +4665,46 @@
4698 */4665 */
4699 if (!self->st_auto_commit) {4666 if (!self->st_auto_commit) {
4700 trans_register_ha(thd, TRUE, pbxt_hton);4667 trans_register_ha(thd, TRUE, pbxt_hton);
4701 XT_PRINT0(self, "ha_pbxt::external_lock trans_register_ha all=TRUE\n");4668 XT_PRINT0(self, "CONN START XACT - ha_pbxt::external_lock --> trans_register_ha\n");
4702 }4669 }
4703 }4670 }
47044671
4672 /* Start a statment transaction: */
4673 /* {START-STAT-HACK} The problem that ha_commit_trans() is not
4674 * called by MySQL seems to be fixed (tests confirm this).
4675 * Here is the previous comment when this code was execute
4676 * here {START-STAT-HACK}
4677 *
4678 * GOTCHA: I have a huge problem with the transaction statement.
4679 * It is not ALWAYS committed (I mean ha_commit_trans() is
4680 * not always called - for example in SELECT).
4681 *
4682 * If I call trans_register_ha() but ha_commit_trans() is not called
4683 * then MySQL thinks a transaction is still running (while
4684 * I have committed the auto-transaction in ha_pbxt::external_lock()).
4685 *
4686 * This causes all kinds of problems, like transactions
4687 * are killed when they should not be.
4688 *
4689 * To prevent this, I only inform MySQL that a transaction
4690 * has beens started when an update is performed. I have determined that
4691 * ha_commit_trans() is only guarenteed to be called if an update is done.
4692 * --------
4693 *
4694 * So, this is the correct place to start a statement transaction.
4695 *
4696 * Note: if trans_register_ha() is not called before ha_write_row(), then
4697 * PBXT is not registered correctly as a modification transaction.
4698 * (mark_trx_read_write call in ha_write_row).
4699 * This leads to 2-phase commit not being called as it should when
4700 * binary logging is enabled.
4701 */
4702 if (!pb_open_tab->ot_thread->st_stat_trans) {
4703 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
4704 XT_PRINT0(pb_open_tab->ot_thread, "STAT START - ha_pbxt::external_lock --> trans_register_ha\n");
4705 pb_open_tab->ot_thread->st_stat_trans = TRUE;
4706 }
4707
4705 if (lock_type == F_WRLCK || self->st_xact_mode < XT_XACT_REPEATABLE_READ)4708 if (lock_type == F_WRLCK || self->st_xact_mode < XT_XACT_REPEATABLE_READ)
4706 self->st_visible_time = self->st_database->db_xn_end_time;4709 self->st_visible_time = self->st_database->db_xn_end_time;
47074710
@@ -4826,7 +4829,7 @@
4826 }4829 }
4827 }4830 }
48284831
4829 /* (***) This is required at this level!4832 /* {IS-UPDATE-STAT} This is required at this level!
4830 * No matter how often it is called, it is still the start of a4833 * No matter how often it is called, it is still the start of a
4831 * statement. We need to make sure statements that are NOT mistaken4834 * statement. We need to make sure statements that are NOT mistaken
4832 * for different type of statement.4835 * for different type of statement.
@@ -4841,7 +4844,7 @@
4841 */4844 */
4842 self->st_is_update = FALSE;4845 self->st_is_update = FALSE;
48434846
4844 /* See comment (**) */4847 /* See comment {START-TRANS} */
4845 if (!self->st_xact_data) {4848 if (!self->st_xact_data) {
4846 self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;4849 self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ;
4847 self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;4850 self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0;
@@ -4858,10 +4861,17 @@
4858 }4861 }
4859 if (!self->st_auto_commit) {4862 if (!self->st_auto_commit) {
4860 trans_register_ha(thd, TRUE, pbxt_hton);4863 trans_register_ha(thd, TRUE, pbxt_hton);
4861 XT_PRINT0(self, "ha_pbxt::start_stmt trans_register_ha all=TRUE\n");4864 XT_PRINT0(self, "START CONN XACT - ha_pbxt::start_stmt --> trans_register_ha\n");
4862 }4865 }
4863 }4866 }
48644867
4868 /* Start a statment (see {START-STAT-HACK}): */
4869 if (!pb_open_tab->ot_thread->st_stat_trans) {
4870 trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton);
4871 XT_PRINT0(pb_open_tab->ot_thread, "START STAT - ha_pbxt::start_stmt --> trans_register_ha\n");
4872 pb_open_tab->ot_thread->st_stat_trans = TRUE;
4873 }
4874
4865 if (pb_open_tab->ot_for_update || self->st_xact_mode < XT_XACT_REPEATABLE_READ)4875 if (pb_open_tab->ot_for_update || self->st_xact_mode < XT_XACT_REPEATABLE_READ)
4866 self->st_visible_time = self->st_database->db_xn_end_time;4876 self->st_visible_time = self->st_database->db_xn_end_time;
48674877
48684878
=== modified file 'storage/pbxt/src/strutil_xt.cc'
--- storage/pbxt/src/strutil_xt.cc 2009-11-24 10:55:06 +0000
+++ storage/pbxt/src/strutil_xt.cc 2009-12-29 10:54:19 +0000
@@ -380,7 +380,7 @@
380/* Version number must also be set in configure.in! */380/* Version number must also be set in configure.in! */
381xtPublic c_char *xt_get_version(void)381xtPublic c_char *xt_get_version(void)
382{382{
383 return "1.0.09f RC";383 return "1.0.09g RC";
384}384}
385385
386/* Copy and URL decode! */386/* Copy and URL decode! */

Subscribers

People subscribed via source and target branches