From 79a2dbc8794a8f28be92386acdb4028a887190cc Mon Sep 17 00:00:00 2001 From: Andrei Elkin Date: Mon, 14 Jun 2021 19:22:29 +0300 Subject: [PATCH] MDEV-21117 post-push fixes 1. work around MDEV-25912 to not apply assert at wsrep running time; 2. handle wsrep mode of the server recovery 3. convert hton calls to static binlog_commit ones. 4. satisfy MSAN complain on uninitialized std::pair --- sql/handler.cc | 19 +++++++++---------- sql/handler.h | 4 ++++ sql/log.cc | 2 +- sql/log.h | 2 +- sql/log_event.cc | 5 +++++ sql/sql_table.cc | 4 ++-- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index 78ee18a4542ad..0ec8afde16e15 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2401,16 +2401,16 @@ struct xarecover_st static xid_recovery_member* xid_member_insert(HASH *hash_arg, my_xid xid_arg, MEM_ROOT *ptr_mem_root) { - xid_recovery_member *member= (xid_recovery_member*) + xid_recovery_member *member= (xid_recovery_member *) alloc_root(ptr_mem_root, sizeof(xid_recovery_member)); + if (!member) return NULL; - member->xid= xid_arg; - member->in_engine_prepare= 1; - member->decided_to_commit= false; + *member= xid_recovery_member(xid_arg, 1, false); - return my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; + return + my_hash_insert(hash_arg, (uchar*) member) ? NULL : member; } /* @@ -2636,13 +2636,11 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, sql_print_error("Error in memory allocation at xarecover_handlerton"); break; } - } else + } if (IF_WSREP((wsrep_emulate_bin_log && wsrep_is_wsrep_xid(info->list + i) && x <= wsrep_limit), false) || - (info->commit_list ? - my_hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : - tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT)) + tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) { int rc= hton->commit_by_xid(hton, info->list+i); if (rc == 0) @@ -2653,7 +2651,8 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, }); } } - else + else if (WSREP_ON || + tc_heuristic_recover == TC_HEURISTIC_RECOVER_ROLLBACK) { int rc= hton->rollback_by_xid(hton, info->list+i); if (rc == 0) diff --git a/sql/handler.h b/sql/handler.h index d2bb514f5cf41..2f15ec8f38920 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -956,6 +956,10 @@ struct xid_recovery_member uint in_engine_prepare; // number of engines that have xid prepared bool decided_to_commit; Binlog_offset binlog_coord; // semisync recovery binlog offset + + xid_recovery_member(my_xid xid_arg, uint prepare_arg, bool decided_arg) + : xid(xid_arg), in_engine_prepare(prepare_arg), + decided_to_commit(decided_arg) {}; }; /* for recover() handlerton call */ diff --git a/sql/log.cc b/sql/log.cc index 047d644e5da64..a6e83d1b4f597 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -11040,7 +11040,7 @@ void Recovery_context::process_gtid(int round, Gtid_log_event *gev, last_gtid_coord= Binlog_offset(id_binlog, prev_event_pos); DBUG_ASSERT(!last_gtid_valid); - DBUG_ASSERT(!last_gtid.seq_no == 0); + DBUG_ASSERT(last_gtid.seq_no != 0); if (round == 1 || (do_truncate && !truncate_validated)) { diff --git a/sql/log.h b/sql/log.h index d61e46603305c..6227e57975741 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1243,7 +1243,7 @@ class Gtid_list_log_event; const char * get_gtid_list_event(IO_CACHE *cache, Gtid_list_log_event **out_gtid_list); -int binlog_commit(THD *thd, bool all, bool is_ro_1pc); +int binlog_commit(THD *thd, bool all, bool is_ro_1pc= false); int binlog_commit_by_xid(handlerton *hton, XID *xid); int binlog_rollback_by_xid(handlerton *hton, XID *xid); diff --git a/sql/log_event.cc b/sql/log_event.cc index c77059ee8f50b..b0d47ff496b05 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2624,6 +2624,11 @@ Gtid_log_event::Gtid_log_event(const uchar *buf, uint event_len, */ DBUG_ASSERT(static_cast(buf - buf_0) <= event_len); /* and the last of them is tested. */ +#ifdef MYSQL_SERVER +#ifdef WITH_WSREP + if (!WSREP_ON) +#endif +#endif DBUG_ASSERT(static_cast(buf - buf_0) == event_len || buf_0[event_len - 1] == 0); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e637d68097355..8953ca6c1a523 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10410,7 +10410,7 @@ do_continue:; DROP + CREATE + data statement to the binary log */ thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; - (binlog_hton->commit)(binlog_hton, thd, 1); + binlog_commit(thd, true); } /* We don't replicate alter table statement on temporary tables */ @@ -10624,7 +10624,7 @@ do_continue:; thd->variables.option_bits&= ~OPTION_BIN_COMMIT_OFF; thd->binlog_xid= thd->query_id; ddl_log_update_xid(&ddl_log_state, thd->binlog_xid); - binlog_hton->commit(binlog_hton, thd, 1); + binlog_commit(thd, true); thd->binlog_xid= 0; }