diff options
author | unknown <knielsen@knielsen-hq.org> | 2009-12-29 12:34:44 +0100 |
---|---|---|
committer | unknown <knielsen@knielsen-hq.org> | 2009-12-29 12:34:44 +0100 |
commit | a4eb3f44aeddc3e8ccbf777b831a1cf0fd1bb5c6 (patch) | |
tree | ac400519beb43927001a792e6154996c0eb50d78 /storage/pbxt/src | |
parent | 99685f1bd69866a5cba9b38c0d3a678a7024cad1 (diff) | |
parent | bb718f79dd2f97b036e73fbafdf6ae86e1a15d2a (diff) | |
download | mariadb-git-a4eb3f44aeddc3e8ccbf777b831a1cf0fd1bb5c6.tar.gz |
Merge PBXT fix from Paul.
Diffstat (limited to 'storage/pbxt/src')
-rw-r--r-- | storage/pbxt/src/discover_xt.cc | 4 | ||||
-rw-r--r-- | storage/pbxt/src/ha_pbxt.cc | 108 | ||||
-rw-r--r-- | storage/pbxt/src/strutil_xt.cc | 2 |
3 files changed, 62 insertions, 52 deletions
diff --git a/storage/pbxt/src/discover_xt.cc b/storage/pbxt/src/discover_xt.cc index d0e3785c4b4..2a42c77ac69 100644 --- a/storage/pbxt/src/discover_xt.cc +++ b/storage/pbxt/src/discover_xt.cc @@ -355,10 +355,10 @@ static int sort_keys(KEY *a, KEY *b) { if (!(b_flags & HA_NOSAME)) return -1; - if ((a_flags ^ b_flags) & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) + if ((a_flags ^ b_flags) & HA_NULL_PART_KEY) { /* Sort NOT NULL keys before other keys */ - return (a_flags & (HA_NULL_PART_KEY | HA_END_SPACE_KEY)) ? 1 : -1; + return (a_flags & HA_NULL_PART_KEY) ? 1 : -1; } if (a->name == primary_key_name) return -1; diff --git a/storage/pbxt/src/ha_pbxt.cc b/storage/pbxt/src/ha_pbxt.cc index 70d8b6609e8..b088ad8daf2 100644 --- a/storage/pbxt/src/ha_pbxt.cc +++ b/storage/pbxt/src/ha_pbxt.cc @@ -1447,7 +1447,7 @@ static int pbxt_commit(handlerton *hton, THD *thd, bool all) XTThreadPtr self; if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) { - XT_PRINT1(self, "pbxt_commit all=%d\n", all); + XT_PRINT2(self, "%s pbxt_commit all=%d\n", all ? "END CONN XACT" : "END STAT", all); if (self->st_xact_data) { /* There are no table locks, commit immediately in all cases @@ -1479,7 +1479,7 @@ static int pbxt_rollback(handlerton *hton, THD *thd, bool all) XTThreadPtr self; if ((self = (XTThreadPtr) *thd_ha_data(thd, hton))) { - XT_PRINT1(self, "pbxt_rollback all=%d in pbxt_commit\n", all); + XT_PRINT2(self, "%s pbxt_rollback all=%d\n", all ? "CONN END XACT" : "STAT END", all); if (self->st_xact_data) { /* There are no table locks, rollback immediately in all cases @@ -1543,7 +1543,7 @@ static int pbxt_prepare(handlerton *hton, THD *thd, bool all) * except when this is a statement commit with an explicit * transaction (!all && !self->st_auto_commit). */ - if (all) { + if (all || self->st_auto_commit) { XID xid; XT_PRINT0(self, "xt_xn_prepare in pbxt_prepare\n"); @@ -2625,26 +2625,7 @@ int ha_pbxt::write_row(byte *buf) } #endif - /* GOTCHA: I have a huge problem with the transaction statement. - * It is not ALWAYS committed (I mean ha_commit_trans() is - * not always called - for example in SELECT). - * - * If I call trans_register_ha() but ha_commit_trans() is not called - * then MySQL thinks a transaction is still running (while - * I have committed the auto-transaction in ha_pbxt::external_lock()). - * - * This causes all kinds of problems, like transactions - * are killed when they should not be. - * - * To prevent this, I only inform MySQL that a transaction - * has beens started when an update is performed. I have determined that - * ha_commit_trans() is only guarenteed to be called if an update is done. - */ - if (!pb_open_tab->ot_thread->st_stat_trans) { - trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); - XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::write_row trans_register_ha all=FALSE\n"); - pb_open_tab->ot_thread->st_stat_trans = TRUE; - } + /* {START-STAT-HACK} previously position of start statement hack. */ xt_xlog_check_long_writer(pb_open_tab->ot_thread); @@ -2735,11 +2716,7 @@ int ha_pbxt::update_row(const byte * old_data, byte * new_data) 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]))); //statistic_increment(ha_update_count,&LOCK_status); - if (!self->st_stat_trans) { - trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); - XT_PRINT0(self, "ha_pbxt::update_row trans_register_ha all=FALSE\n"); - self->st_stat_trans = TRUE; - } + /* {START-STAT-HACK} previously position of start statement hack. */ xt_xlog_check_long_writer(self); @@ -2826,11 +2803,7 @@ int ha_pbxt::delete_row(const byte * buf) } #endif - if (!pb_open_tab->ot_thread->st_stat_trans) { - trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); - XT_PRINT0(pb_open_tab->ot_thread, "ha_pbxt::delete_row trans_register_ha all=FALSE\n"); - pb_open_tab->ot_thread->st_stat_trans = TRUE; - } + /* {START-STAT-HACK} previously position of start statement hack. */ xt_xlog_check_long_writer(pb_open_tab->ot_thread); @@ -3160,15 +3133,12 @@ int ha_pbxt::index_init(uint idx, bool XT_UNUSED(sorted)) 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); #endif + /* {START-STAT-HACK} previously position of start statement hack, + * previous comment to code below: */ /* Start a statement based transaction as soon * as a read is done for a modify type statement! * Previously, this was done too late! */ - if (!thread->st_stat_trans) { - trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); - XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n"); - thread->st_stat_trans = TRUE; - } } else { pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); @@ -3617,15 +3587,12 @@ int ha_pbxt::rnd_init(bool scan) /* The number of columns required: */ if (pb_open_tab->ot_is_modify) { pb_open_tab->ot_cols_req = table->read_set->MX_BIT_SIZE(); + /* {START-STAT-HACK} previously position of start statement hack, + * previous comment to code below: */ /* Start a statement based transaction as soon * as a read is done for a modify type statement! * Previously, this was done too late! */ - if (!thread->st_stat_trans) { - trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); - XT_PRINT0(thread, "ha_pbxt::update_row trans_register_ha all=FALSE\n"); - thread->st_stat_trans = TRUE; - } } else { pb_open_tab->ot_cols_req = ha_get_max_bit(table->read_set); @@ -4636,7 +4603,7 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type) cont_(b); } - /* See (***) */ + /* See {IS-UPDATE-STAT} */ self->st_is_update = FALSE; /* Auto begin a transaction (if one is not already running): */ @@ -4665,7 +4632,7 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type) } /* - * (**) GOTCHA: trans_register_ha() is not mentioned in the documentation. + * {START-TRANS} GOTCHA: trans_register_ha() is not mentioned in the documentation. * It must be called to inform MySQL that we have a transaction (see start_stmt). * * Here are some tests that confirm whether things are done correctly: @@ -4703,10 +4670,46 @@ xtPublic int ha_pbxt::external_lock(THD *thd, int lock_type) */ if (!self->st_auto_commit) { trans_register_ha(thd, TRUE, pbxt_hton); - XT_PRINT0(self, "ha_pbxt::external_lock trans_register_ha all=TRUE\n"); + XT_PRINT0(self, "CONN START XACT - ha_pbxt::external_lock --> trans_register_ha\n"); } } + /* Start a statment transaction: */ + /* {START-STAT-HACK} The problem that ha_commit_trans() is not + * called by MySQL seems to be fixed (tests confirm this). + * Here is the previous comment when this code was execute + * here {START-STAT-HACK} + * + * GOTCHA: I have a huge problem with the transaction statement. + * It is not ALWAYS committed (I mean ha_commit_trans() is + * not always called - for example in SELECT). + * + * If I call trans_register_ha() but ha_commit_trans() is not called + * then MySQL thinks a transaction is still running (while + * I have committed the auto-transaction in ha_pbxt::external_lock()). + * + * This causes all kinds of problems, like transactions + * are killed when they should not be. + * + * To prevent this, I only inform MySQL that a transaction + * has beens started when an update is performed. I have determined that + * ha_commit_trans() is only guarenteed to be called if an update is done. + * -------- + * + * So, this is the correct place to start a statement transaction. + * + * Note: if trans_register_ha() is not called before ha_write_row(), then + * PBXT is not registered correctly as a modification transaction. + * (mark_trx_read_write call in ha_write_row). + * This leads to 2-phase commit not being called as it should when + * binary logging is enabled. + */ + if (!pb_open_tab->ot_thread->st_stat_trans) { + trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); + XT_PRINT0(pb_open_tab->ot_thread, "STAT START - ha_pbxt::external_lock --> trans_register_ha\n"); + pb_open_tab->ot_thread->st_stat_trans = TRUE; + } + if (lock_type == F_WRLCK || self->st_xact_mode < XT_XACT_REPEATABLE_READ) self->st_visible_time = self->st_database->db_xn_end_time; @@ -4831,7 +4834,7 @@ int ha_pbxt::start_stmt(THD *thd, thr_lock_type lock_type) } } - /* (***) This is required at this level! + /* {IS-UPDATE-STAT} This is required at this level! * No matter how often it is called, it is still the start of a * statement. We need to make sure statements that are NOT mistaken * for different type of statement. @@ -4846,7 +4849,7 @@ int ha_pbxt::start_stmt(THD *thd, thr_lock_type lock_type) */ self->st_is_update = FALSE; - /* See comment (**) */ + /* See comment {START-TRANS} */ if (!self->st_xact_data) { self->st_xact_mode = thd_tx_isolation(thd) <= ISO_READ_COMMITTED ? XT_XACT_COMMITTED_READ : XT_XACT_REPEATABLE_READ; self->st_ignore_fkeys = (thd_test_options(thd, OPTION_NO_FOREIGN_KEY_CHECKS)) != 0; @@ -4863,10 +4866,17 @@ int ha_pbxt::start_stmt(THD *thd, thr_lock_type lock_type) } if (!self->st_auto_commit) { trans_register_ha(thd, TRUE, pbxt_hton); - XT_PRINT0(self, "ha_pbxt::start_stmt trans_register_ha all=TRUE\n"); + XT_PRINT0(self, "START CONN XACT - ha_pbxt::start_stmt --> trans_register_ha\n"); } } + /* Start a statment (see {START-STAT-HACK}): */ + if (!pb_open_tab->ot_thread->st_stat_trans) { + trans_register_ha(pb_mysql_thd, FALSE, pbxt_hton); + XT_PRINT0(pb_open_tab->ot_thread, "START STAT - ha_pbxt::start_stmt --> trans_register_ha\n"); + pb_open_tab->ot_thread->st_stat_trans = TRUE; + } + if (pb_open_tab->ot_for_update || self->st_xact_mode < XT_XACT_REPEATABLE_READ) self->st_visible_time = self->st_database->db_xn_end_time; diff --git a/storage/pbxt/src/strutil_xt.cc b/storage/pbxt/src/strutil_xt.cc index baeb53bbc33..5c3856de100 100644 --- a/storage/pbxt/src/strutil_xt.cc +++ b/storage/pbxt/src/strutil_xt.cc @@ -380,7 +380,7 @@ xtPublic void xt_int8_to_byte_size(xtInt8 value, char *string) /* Version number must also be set in configure.in! */ xtPublic c_char *xt_get_version(void) { - return "1.0.09f RC"; + return "1.0.09g RC"; } /* Copy and URL decode! */ |