diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/debug_sync.cc | 25 | ||||
-rw-r--r-- | sql/event_queue.cc | 2 | ||||
-rw-r--r-- | sql/field.cc | 6 | ||||
-rw-r--r-- | sql/gcalc_slicescan.cc | 4 | ||||
-rw-r--r-- | sql/item_create.cc | 2 | ||||
-rw-r--r-- | sql/item_func.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 6 | ||||
-rw-r--r-- | sql/log.h | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 4 | ||||
-rw-r--r-- | sql/mdl.cc | 6 | ||||
-rw-r--r-- | sql/mysqld.cc | 2 | ||||
-rw-r--r-- | sql/net_serv.cc | 4 | ||||
-rw-r--r-- | sql/records.cc | 4 | ||||
-rw-r--r-- | sql/rpl_injector.h | 4 | ||||
-rw-r--r-- | sql/rpl_parallel.cc | 12 | ||||
-rw-r--r-- | sql/rpl_record.cc | 6 | ||||
-rw-r--r-- | sql/service_wsrep.cc | 4 | ||||
-rw-r--r-- | sql/slave.cc | 8 | ||||
-rw-r--r-- | sql/sql_binlog.cc | 15 | ||||
-rw-r--r-- | sql/sql_cache.cc | 5 | ||||
-rw-r--r-- | sql/sql_class.cc | 2 | ||||
-rw-r--r-- | sql/sql_parse.cc | 2 | ||||
-rw-r--r-- | sql/sql_repl.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 4 | ||||
-rw-r--r-- | sql/sql_udf.cc | 5 | ||||
-rw-r--r-- | sql/table.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_high_priority_service.cc | 8 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 7 | ||||
-rw-r--r-- | sql/wsrep_server_service.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_sst.cc | 2 | ||||
-rw-r--r-- | sql/wsrep_thd.cc | 2 |
32 files changed, 115 insertions, 52 deletions
diff --git a/sql/debug_sync.cc b/sql/debug_sync.cc index dde3ce5a35b..09aa0695127 100644 --- a/sql/debug_sync.cc +++ b/sql/debug_sync.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2009, 2013, Oracle and/or its affiliates. - Copyright (c) 2009, 2020, MariaDB Corporation. + Copyright (c) 2009, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -354,7 +354,7 @@ static char *debug_sync_bmove_len(char *to, char *to_end, } -#if !defined(DBUG_OFF) +#ifdef DBUG_TRACE /** Create a string that describes an action. @@ -444,8 +444,7 @@ static void debug_sync_print_actions(THD *thd) DBUG_VOID_RETURN; } - -#endif /* !defined(DBUG_OFF) */ +#endif /* defined(DBUG_TRACE) */ /** @@ -776,6 +775,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action) else { const char *dsp_name= action->sync_point.c_ptr(); +#ifdef DBUG_TRACE DBUG_EXECUTE("debug_sync", { /* Functions as DBUG_PRINT args can change keyword and line nr. */ const char *sig_emit= action->signal.c_ptr(); @@ -786,6 +786,7 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action) dsp_name, action->activation_count, action->hit_limit, action->execute, action->timeout, sig_emit, sig_wait));}); +#endif /* Check this before sorting the array. action may move. */ is_dsp_now= !my_strcasecmp(system_charset_info, dsp_name, "now"); @@ -798,7 +799,9 @@ static bool debug_sync_set_action(THD *thd, st_debug_sync_action *action) sizeof(st_debug_sync_action), debug_sync_qsort_cmp); } } +#ifdef DBUG_TRACE DBUG_EXECUTE("debug_sync_list", debug_sync_print_actions(thd);); +#endif /* Execute the special sync point 'now' if activated above. */ if (is_dsp_now) @@ -1359,7 +1362,7 @@ uchar *debug_sync_value_ptr(THD *thd) static void debug_sync_execute(THD *thd, st_debug_sync_action *action) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE const char *dsp_name= action->sync_point.c_ptr(); const char *sig_emit= action->signal.c_ptr(); const char *sig_wait= action->wait_for.c_ptr(); @@ -1450,12 +1453,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) restore_current_mutex = false; set_timespec(abstime, action->timeout); - DBUG_EXECUTE("debug_sync_exec", { + DBUG_EXECUTE("debug_sync_exec", /* Functions as DBUG_PRINT args can change keyword and line nr. */ - const char *sig_glob= debug_sync_global.ds_signal.c_ptr(); DBUG_PRINT("debug_sync_exec", ("wait for '%s' at: '%s' curr: '%s'", - sig_wait, dsp_name, sig_glob));}); + sig_wait, dsp_name, + debug_sync_global.ds_signal.c_ptr()));); /* Wait until global signal string matches the wait_for string. @@ -1469,12 +1472,12 @@ static void debug_sync_execute(THD *thd, st_debug_sync_action *action) error= mysql_cond_timedwait(&debug_sync_global.ds_cond, &debug_sync_global.ds_mutex, &abstime); - DBUG_EXECUTE("debug_sync", { + DBUG_EXECUTE("debug_sync", /* Functions as DBUG_PRINT args can change keyword and line nr. */ - const char *sig_glob= debug_sync_global.ds_signal.c_ptr(); DBUG_PRINT("debug_sync", ("awoke from %s global: %s error: %d", - sig_wait, sig_glob, error));}); + sig_wait, debug_sync_global.ds_signal.c_ptr(), + error));); if (unlikely(error == ETIMEDOUT || error == ETIME)) { // We should not make the statement fail, even if in strict mode. diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 7a549e325bc..c4604b63084 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -542,7 +542,7 @@ Event_queue::empty_queue() void Event_queue::dbug_dump_queue(my_time_t when) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE my_time_t now= when; Event_queue_element *et; uint i; diff --git a/sql/field.cc b/sql/field.cc index 3d6eaba6f73..bf988fb5633 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -3377,7 +3377,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value, DBUG_ASSERT(marked_for_write_or_computed()); int error= 0; DBUG_ENTER("Field_new_decimal::store_value"); -#ifndef DBUG_OFF +#ifdef DBUG_TRACE { char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, decimal_value))); @@ -3392,7 +3392,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value, error= 1; decimal_value= &decimal_zero; } -#ifndef DBUG_OFF +#ifdef DBUG_TRACE { char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; DBUG_PRINT("info", ("saving with precision %d scale: %d value %s", @@ -3484,7 +3484,7 @@ int Field_new_decimal::store(const char *from, size_t length, } } -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char dbug_buff[DECIMAL_MAX_STR_LENGTH+2]; DBUG_PRINT("enter", ("value: %s", dbug_decimal_as_string(dbug_buff, &decimal_value))); diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index 93561f5fe97..b079bd7a714 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -116,16 +116,20 @@ static void GCALC_DBUG_PRINT_PI(const Gcalc_heap::Info *pi) int n_buf; if (pi->type == Gcalc_heap::nt_intersection) { +#ifdef DBUG_TRACE const Gcalc_scan_iterator::intersection_info *ic= i_data(pi); GCALC_DBUG_PRINT(("intersection point %d %d", ic->edge_a->thread, ic->edge_b->thread)); +#endif return; } if (pi->type == Gcalc_heap::nt_eq_node) { +#ifdef DBUG_TRACE const Gcalc_scan_iterator::point *e= eq_sp(pi); GCALC_DBUG_PRINT(("eq point %d", e->thread)); +#endif return; } n_buf= gcalc_pi_str(buf, pi, ""); diff --git a/sql/item_create.cc b/sql/item_create.cc index 635ad36f445..a6580047f36 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -5689,7 +5689,7 @@ int item_create_init() DBUG_RETURN(1); #endif -#ifndef DBUG_OFF +#ifdef DBUG_TRACE for (uint i=0 ; i < native_functions_hash.records ; i++) { Native_func_registry *func; diff --git a/sql/item_func.cc b/sql/item_func.cc index d07640d1120..81a53a88dc6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4616,10 +4616,12 @@ longlong Item_func_sleep::val_int() mysql_cond_destroy(&cond); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sleep_inject_query_done_debug_sync", { debug_sync_set_action (thd, STRING_WITH_LEN("dispatch_command_end SIGNAL query_done")); };); +#endif return MY_TEST(!error); // Return 1 killed } diff --git a/sql/log.cc b/sql/log.cc index ea094d74213..c679e8f5111 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -8218,10 +8218,12 @@ MYSQL_BIN_LOG::trx_group_commit_leader(group_commit_entry *leader) DBUG_ENTER("MYSQL_BIN_LOG::trx_group_commit_leader"); { +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("inject_binlog_commit_before_get_LOCK_log", DBUG_ASSERT(!debug_sync_set_action(leader->thd, STRING_WITH_LEN ("commit_before_get_LOCK_log SIGNAL waiting WAIT_FOR cont TIMEOUT 1"))); ); +#endif /* Lock the LOCK_log(), and once we get it, collect any additional writes that queued up while we were waiting. @@ -10399,6 +10401,7 @@ binlog_background_thread(void *arg __attribute__((unused))) mysql_mutex_unlock(&mysql_bin_log.LOCK_binlog_background_thread); /* Process any incoming commit_checkpoint_notify() calls. */ +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("inject_binlog_background_thread_before_mark_xid_done", DBUG_ASSERT(!debug_sync_set_action( thd, @@ -10407,6 +10410,7 @@ binlog_background_thread(void *arg __attribute__((unused))) "WAIT_FOR something_that_will_never_happen " "TIMEOUT 2"))); ); +#endif while (queue) { long count= queue->notify_count; @@ -10421,11 +10425,13 @@ binlog_background_thread(void *arg __attribute__((unused))) mysql_bin_log.mark_xid_done(queue->binlog_id, true); queue= next; +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("binlog_background_checkpoint_processed", DBUG_ASSERT(!debug_sync_set_action( thd, STRING_WITH_LEN("now SIGNAL binlog_background_checkpoint_processed"))); ); +#endif } if (stop) diff --git a/sql/log.h b/sql/log.h index e0a37c0a250..02c696357b8 100644 --- a/sql/log.h +++ b/sql/log.h @@ -734,7 +734,7 @@ public: } void harvest_bytes_written(Atomic_counter<uint64> *counter) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char buf1[22],buf2[22]; #endif DBUG_ENTER("harvest_bytes_written"); diff --git a/sql/log_event.cc b/sql/log_event.cc index 20cf4d45073..8bcdb3d6bae 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB + Copyright (c) 2009, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1376,7 +1376,7 @@ static void copy_str_and_move(const char **src, } -#ifndef DBUG_OFF +#ifdef DBUG_TRACE static char const * code_name(int code) { diff --git a/sql/mdl.cc b/sql/mdl.cc index 144ce1cfedf..863f063a774 100644 --- a/sql/mdl.cc +++ b/sql/mdl.cc @@ -1187,6 +1187,7 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, wait_result != ETIMEDOUT && wait_result != ETIME) { #ifdef WITH_WSREP +# ifdef ENABLED_DEBUG_SYNC // Allow tests to block the applier thread using the DBUG facilities DBUG_EXECUTE_IF("sync.wsrep_before_mdl_wait", { @@ -1196,6 +1197,7 @@ MDL_wait::timed_wait(MDL_context_owner *owner, struct timespec *abs_timeout, DBUG_ASSERT(!debug_sync_set_action((owner->get_thd()), STRING_WITH_LEN(act))); };); +# endif if (WSREP_ON && wsrep_thd_is_BF(owner->get_thd(), false)) { wait_result= mysql_cond_wait(&m_COND_wait_status, &m_LOCK_wait_status); @@ -2279,7 +2281,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) MDL_ticket *ticket; MDL_wait::enum_wait_status wait_status; DBUG_ENTER("MDL_context::acquire_lock"); -#ifndef DBUG_OFF +#ifdef DBUG_TRACE const char *mdl_lock_name= get_mdl_lock_name( mdl_request->key.mdl_namespace(), mdl_request->type)->str; #endif @@ -2305,7 +2307,7 @@ MDL_context::acquire_lock(MDL_request *mdl_request, double lock_wait_timeout) DBUG_RETURN(FALSE); } -#ifndef DBUG_OFF +#ifdef DBUG_TRACE const char *ticket_msg= dbug_print_mdl(ticket); #endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 09841a75f5a..4444e02d983 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1674,6 +1674,7 @@ void kill_mysql(THD *thd) DBUG_EXECUTE_IF("mysql_admin_shutdown_wait_for_slaves", thd->lex->is_shutdown_wait_for_slaves= true;); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("simulate_delay_at_shutdown", { DBUG_ASSERT(binlog_dump_thread_count == 3); @@ -1683,6 +1684,7 @@ void kill_mysql(THD *thd) DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); +#endif if (thd->lex->is_shutdown_wait_for_slaves) shutdown_wait_for_slaves= true; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 1d2409f16cf..2024172ec39 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2012, 2020, MariaDB Corporation. + Copyright (c) 2012, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -507,6 +507,7 @@ net_write_command(NET *net,uchar command, DBUG_ENTER("net_write_command"); DBUG_PRINT("enter",("length: %lu", (ulong) len)); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("simulate_error_on_packet_write", { if (command == COM_BINLOG_DUMP) @@ -518,6 +519,7 @@ net_write_command(NET *net,uchar command, DBUG_RETURN(true); } };); +#endif MYSQL_NET_WRITE_START(length); buff[4]=command; /* For first packet */ diff --git a/sql/records.cc b/sql/records.cc index 740b96a0cfd..8da605072a6 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -1,6 +1,6 @@ /* Copyright (c) 2000, 2010, Oracle and/or its affiliates. - Copyright (c) 2009, 2017, MariaDB Corporation + Copyright (c) 2009, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -568,7 +568,7 @@ template<bool Packed_addon_fields> static int rr_unpack_from_tempfile(READ_RECORD *info) { uchar *destination= info->rec_buf; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE my_off_t where= my_b_tell(info->io_cache); #endif if (Packed_addon_fields) diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 669a8e29543..28359d9555a 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -264,14 +264,14 @@ public: */ int check_state(enum_state const target_state) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE static char const *state_name[] = { "START_STATE", "TABLE_STATE", "ROW_STATE", "STATE_COUNT" }; - DBUG_ASSERT(target_state <= STATE_COUNT); DBUG_PRINT("info", ("In state %s", state_name[m_state])); #endif + DBUG_ASSERT(target_state <= STATE_COUNT); if (m_state <= target_state && target_state <= m_state + 1 && m_state < STATE_COUNT) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 65d5a06a76a..8409a9cd89c 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -247,6 +247,7 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, entry->stop_on_error_sub_id == (uint64)ULONGLONG_MAX) entry->stop_on_error_sub_id= sub_id; mysql_mutex_unlock(&entry->LOCK_parallel_entry); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("hold_worker_on_schedule", { if (entry->stop_on_error_sub_id < (uint64)ULONGLONG_MAX) { @@ -261,6 +262,7 @@ finish_event_group(rpl_parallel_thread *rpt, uint64 sub_id, STRING_WITH_LEN("now WAIT_FOR proceed_by_1000")); } }); +#endif if (rgi->killed_for_retry == rpl_group_info::RETRY_KILL_PENDING) wait_for_pending_deadlock_kill(thd, rgi); @@ -774,6 +776,7 @@ do_retry: rgi->killed_for_retry= rpl_group_info::RETRY_KILL_KILLED; thd->set_killed(KILL_CONNECTION); }); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("rpl_parallel_simulate_wait_at_retry", { if (rgi->current_gtid.seq_no == 1001) { debug_sync_set_action(thd, @@ -781,6 +784,7 @@ do_retry: } DEBUG_SYNC(thd, "rpl_parallel_simulate_wait_at_retry"); }); +#endif rgi->cleanup_context(thd, 1); wait_for_pending_deadlock_kill(thd, rgi); @@ -1191,6 +1195,7 @@ handle_rpl_parallel_thread(void *arg) bool did_enter_cond= false; PSI_stage_info old_stage; +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("hold_worker_on_schedule", { if (rgi->current_gtid.domain_id == 0 && rgi->current_gtid.seq_no == 100) { @@ -1205,6 +1210,7 @@ handle_rpl_parallel_thread(void *arg) STRING_WITH_LEN("now SIGNAL scheduled_gtid_0_x_100")); } }); +#endif if(unlikely(thd->wait_for_commit_ptr) && group_rgi != NULL) { @@ -2184,11 +2190,13 @@ rpl_parallel_entry::choose_thread(rpl_group_info *rgi, bool *did_enter_cond, unlock_or_exit_cond(rli->sql_driver_thd, &thr->LOCK_rpl_thread, did_enter_cond, old_stage); my_error(ER_CONNECTION_KILLED, MYF(0)); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("rpl_parallel_wait_queue_max", { debug_sync_set_action(rli->sql_driver_thd, STRING_WITH_LEN("now SIGNAL wait_queue_killed")); };); +#endif slave_output_error_info(rgi, rli->sql_driver_thd); return NULL; } @@ -2206,11 +2214,13 @@ rpl_parallel_entry::choose_thread(rpl_group_info *rgi, bool *did_enter_cond, Because debug_sync changes the thd->mysys_var->current_mutex, and this can cause THD::awake to use the wrong mutex. */ +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("rpl_parallel_wait_queue_max", { debug_sync_set_action(rli->sql_driver_thd, STRING_WITH_LEN("now SIGNAL wait_queue_ready")); };); +#endif rli->sql_driver_thd->ENTER_COND(&thr->COND_rpl_thread_queue, &thr->LOCK_rpl_thread, &stage_waiting_for_room_in_worker_thread, @@ -2365,11 +2375,13 @@ rpl_parallel::wait_for_done(THD *thd, Relay_log_info *rli) } } } +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("rpl_parallel_wait_for_done_trigger", { debug_sync_set_action(thd, STRING_WITH_LEN("now SIGNAL wait_for_done_waiting")); };); +#endif for (i= 0; i < domain_hash.records; ++i) { diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 7da296b47d9..6266acf7805 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2007, 2013, Oracle and/or its affiliates. - Copyright (c) 2008, 2019, MariaDB Corporation. + Copyright (c) 2008, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -319,7 +319,9 @@ unpack_row(rpl_group_info *rgi, normal unpack operation. */ uint16 const metadata= tabledef->field_metadata(i); - IF_DBUG(uchar const *const old_pack_ptr= pack_ptr;,) +#ifdef DBUG_TRACE + uchar const *const old_pack_ptr= pack_ptr; +#endif pack_ptr= f->unpack(f->ptr, pack_ptr, row_end, metadata); DBUG_PRINT("debug", ("field: %s; metadata: 0x%x;" diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index b32309642af..1731eeec667 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -226,7 +226,7 @@ extern "C" my_bool wsrep_thd_bf_abort(THD *bf_thd, THD *victim_thd, { mysql_mutex_assert_owner(&victim_thd->LOCK_thd_kill); mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data); - +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.before_wsrep_thd_abort", { const char act[]= @@ -236,7 +236,7 @@ extern "C" my_bool wsrep_thd_bf_abort(THD *bf_thd, THD *victim_thd, DBUG_ASSERT(!debug_sync_set_action(bf_thd, STRING_WITH_LEN(act))); };); - +#endif my_bool ret= wsrep_bf_abort(bf_thd, victim_thd); /* Send awake signal if victim was BF aborted or does not diff --git a/sql/slave.cc b/sql/slave.cc index aa6b2ad1d69..33a382edc47 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3841,12 +3841,14 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, Relay_log_info* rli= rgi->rli; DBUG_ENTER("apply_event_and_update_pos_apply"); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("inject_slave_sql_before_apply_event", { DBUG_ASSERT(!debug_sync_set_action (thd, STRING_WITH_LEN("now WAIT_FOR continue"))); DBUG_SET_INITIAL("-d,inject_slave_sql_before_apply_event"); };); +#endif if (reason == Log_event::EVENT_SKIP_NOT) exec_res= ev->apply_event(rgi); @@ -3875,7 +3877,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, } #endif -#ifndef DBUG_OFF +#ifdef DBUG_TRACE /* This only prints information to the debug trace. @@ -3901,7 +3903,7 @@ apply_event_and_update_pos_apply(Log_event* ev, THD* thd, rpl_group_info *rgi, if (exec_res == 0) { int error= ev->update_pos(rgi); - #ifndef DBUG_OFF +#ifdef DBUG_TRACE DBUG_PRINT("info", ("update_pos error = %d", error)); if (!rli->belongs_to_client()) { @@ -4432,6 +4434,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, #ifdef WITH_WSREP wsrep_after_statement(thd); #endif /* WITH_WSREP */ +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF( "pause_sql_thread_on_fde", if (ev && typ == FORMAT_DESCRIPTION_EVENT) { @@ -4440,6 +4443,7 @@ static int exec_relay_log_event(THD* thd, Relay_log_info* rli, STRING_WITH_LEN( "now SIGNAL paused_on_fde WAIT_FOR sql_thread_continue"))); }); +#endif DBUG_RETURN(exec_res); } diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index 0011487f1dc..4dd5f16f351 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -41,14 +41,13 @@ static int check_event_type(int type, Relay_log_info *rli) */ if (fd_event && fd_event->event_type_permutation) { - IF_DBUG({ - int new_type= fd_event->event_type_permutation[type]; - DBUG_PRINT("info", - ("converting event type %d to %d (%s)", - type, new_type, - Log_event::get_type_str((Log_event_type)new_type))); - }, - (void)0); +#ifdef DBUG_TRACE + int new_type= fd_event->event_type_permutation[type]; + DBUG_PRINT("info", + ("converting event type %d to %d (%s)", + type, new_type, + Log_event::get_type_str((Log_event_type)new_type))); +#endif type= fd_event->event_type_permutation[type]; } diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 520fbdc0ff2..60ac8274d84 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -4767,7 +4767,7 @@ void Query_cache::cache_dump() void Query_cache::queries_dump() { - +#ifdef DBUG_TRACE if (!initialized) { DBUG_PRINT("qcache", ("Query Cache not initialized")); @@ -4828,11 +4828,13 @@ void Query_cache::queries_dump() DBUG_PRINT("qcache", ("no queries in list")); } DBUG_PRINT("qcache", ("------------------")); +#endif } void Query_cache::tables_dump() { +#ifdef DBUG_TRACE if (!initialized || query_cache_size == 0) { DBUG_PRINT("qcache", ("Query Cache not initialized")); @@ -4855,6 +4857,7 @@ void Query_cache::tables_dump() else DBUG_PRINT("qcache", ("no tables in list")); DBUG_PRINT("qcache", ("--------------------")); +#endif } diff --git a/sql/sql_class.cc b/sql/sql_class.cc index f909158702a..87526acbdba 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -7352,7 +7352,7 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional) } -#if !defined(DBUG_OFF) && !defined(_lint) +#if defined(DBUG_TRACE) && !defined(_lint) static const char * show_query_type(THD::enum_binlog_query_type qtype) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 00cbfd22d07..ec22b539668 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -7941,6 +7941,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, thd->lex->sql_command != SQLCOM_SELECT && thd->wsrep_retry_counter < thd->variables.wsrep_retry_autocommit) { +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.wsrep_retry_autocommit", { const char act[]= @@ -7949,6 +7950,7 @@ static bool wsrep_mysql_parse(THD *thd, char *rawbuf, uint length, "WAIT_FOR wsrep_retry_autocommit_continue"; DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); }); +#endif WSREP_DEBUG("wsrep retrying AC query: %lu %s", thd->wsrep_retry_counter, wsrep_thd_query(thd)); wsrep_prepare_for_autocommit_retry(thd, rawbuf, length, parser_state); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index e15980e9b3c..aad53bb69d0 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2018, Oracle and/or its affiliates. - Copyright (c) 2008, 2020, MariaDB Corporation + Copyright (c) 2008, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -2866,6 +2866,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, info->error= ER_UNKNOWN_ERROR; goto err; } +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("simulate_delay_at_shutdown", { const char act[]= @@ -2874,6 +2875,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); +#endif /* heartbeat_period from @master_heartbeat_period user variable @@ -2963,12 +2965,14 @@ void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, if (should_stop(info)) break; +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("wait_after_binlog_EOF", { const char act[]= "now wait_for signal.rotate_finished"; DBUG_ASSERT(!debug_sync_set_action(current_thd, STRING_WITH_LEN(act))); };); +#endif THD_STAGE_INFO(thd, stage_finished_reading_one_binlog_switching_to_next_binlog); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 6917f24425d..5725370cdc2 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10129,7 +10129,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, DEBUG_SYNC(thd, "alter_opened_table"); -#ifdef WITH_WSREP +#if defined WITH_WSREP && defined ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.alter_opened_table", { const char act[]= diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 398cfeabfb0..adcf9fee9c3 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -615,7 +615,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) goto end; } -#ifdef WITH_WSREP +#if defined WITH_WSREP && defined ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.mdev_20225", { const char act[]= @@ -624,7 +624,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create) DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); -#endif /* WITH_WSREP */ +#endif /* WITH_WSREP && ENABLED_DEBUG_SYNC */ result= (create ? table->triggers->create_trigger(thd, tables, &stmt_query): diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index b55bbc7ffac..02f068e9bbc 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -620,7 +620,7 @@ int mysql_create_function(THD *thd,udf_func *udf) /* Allow creation of functions even if we can't open func table */ if (unlikely(!table)) - goto err; + goto err_open_func_table; table->use_all_columns(); restore_record(table, s->default_values); // Default values for fields table->field[0]->store(u_d->name.str, u_d->name.length, system_charset_info); @@ -634,7 +634,7 @@ int mysql_create_function(THD *thd,udf_func *udf) { my_error(ER_ERROR_ON_WRITE, MYF(0), "mysql.func", error); del_udf(u_d); - goto err; + goto err_open_func_table; } done: @@ -649,6 +649,7 @@ done: err: if (new_dl) dlclose(dl); +err_open_func_table: mysql_rwlock_unlock(&THR_LOCK_udf); DBUG_RETURN(1); } diff --git a/sql/table.cc b/sql/table.cc index 83051e4d16b..b3f80e16430 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -8763,7 +8763,7 @@ int TABLE::update_virtual_fields(handler *h, enum_vcol_update_mode update_mode) { /* Compute the actual value of the virtual fields */ DBUG_FIX_WRITE_SET(vf); -# ifndef DBUG_OFF +# ifdef DBUG_TRACE int field_error= # endif vcol_info->expr->save_in_field(vf, 0); diff --git a/sql/wsrep_high_priority_service.cc b/sql/wsrep_high_priority_service.cc index e165a204f56..708eb552866 100644 --- a/sql/wsrep_high_priority_service.cc +++ b/sql/wsrep_high_priority_service.cc @@ -405,6 +405,7 @@ int Wsrep_high_priority_service::apply_toi(const wsrep::ws_meta& ws_meta, WSREP_DEBUG("Wsrep_high_priority_service::apply_toi: %lld", client_state.toi_meta().seqno().get()); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.wsrep_apply_toi", { const char act[]= @@ -414,6 +415,7 @@ int Wsrep_high_priority_service::apply_toi(const wsrep::ws_meta& ws_meta, DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); +#endif int ret= apply_events(thd, m_rli, data, err); wsrep_thd_set_ignored_error(thd, false); @@ -459,6 +461,7 @@ int Wsrep_high_priority_service::log_dummy_write_set(const wsrep::ws_handle& ws_ DBUG_PRINT("info", ("Wsrep_high_priority_service::log_dummy_write_set: seqno=%lld", ws_meta.seqno().get())); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.wsrep_log_dummy_write_set", { const char act[]= @@ -467,6 +470,7 @@ int Wsrep_high_priority_service::log_dummy_write_set(const wsrep::ws_handle& ws_ DBUG_ASSERT(!debug_sync_set_action(m_thd, STRING_WITH_LEN(act))); };); +#endif if (ws_meta.ordered()) { @@ -562,8 +566,8 @@ int Wsrep_applier_service::apply_write_set(const wsrep::ws_meta& ws_meta, /* moved dbug sync point here, after possible THD switch for SR transactions has ben done */ - /* Allow tests to block the applier thread using the DBUG facilities */ #ifdef ENABLED_DEBUG_SYNC + /* Allow tests to block the applier thread using the DBUG facilities */ DBUG_EXECUTE_IF("sync.wsrep_apply_cb", { const char act[]= @@ -716,6 +720,7 @@ int Wsrep_replayer_service::apply_write_set(const wsrep::ws_meta& ws_meta, DBUG_ASSERT(thd->wsrep_trx().active()); DBUG_ASSERT(thd->wsrep_trx().state() == wsrep::transaction::s_replaying); +#ifdef ENABLED_DEBUG_SYNC /* Allow tests to block the replayer thread using the DBUG facilities */ DBUG_EXECUTE_IF("sync.wsrep_replay_cb", { @@ -726,6 +731,7 @@ int Wsrep_replayer_service::apply_write_set(const wsrep::ws_meta& ws_meta, DBUG_ASSERT(!debug_sync_set_action(thd, STRING_WITH_LEN(act))); };); +#endif wsrep_setup_uk_and_fk_checks(thd); diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index c20ebead8d6..e52613492f0 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -709,11 +709,14 @@ static std::string wsrep_server_incoming_address() /* In case port is not specified in wsrep_node_incoming_address, we use mysqld_port. + Note that we might get here before we execute set_ports(). */ - int port= (addr.get_port() > 0) ? addr.get_port() : (int) mysqld_port; + int local_port= (addr.get_port() > 0) ? addr.get_port() : (int) mysqld_port; + if (!local_port) + local_port= MYSQL_PORT; const char *fmt= (addr.is_ipv6()) ? "[%s]:%u" : "%s:%u"; - snprintf(inc_addr, inc_addr_max, fmt, addr.get_address(), port); + snprintf(inc_addr, inc_addr_max, fmt, addr.get_address(), local_port); } done: diff --git a/sql/wsrep_server_service.cc b/sql/wsrep_server_service.cc index 72c98de3f81..ac7226b9948 100644 --- a/sql/wsrep_server_service.cc +++ b/sql/wsrep_server_service.cc @@ -386,6 +386,7 @@ int Wsrep_server_service::wait_committing_transactions(int timeout) void Wsrep_server_service::debug_sync(const char* sync_point) { +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF(sync_point, { std::stringstream dbug_action; dbug_action << "now " @@ -396,4 +397,5 @@ void Wsrep_server_service::debug_sync(const char* sync_point) action.c_str(), action.length())); };); +#endif } diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 2d6e4f713c4..09211a96e1e 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -1739,6 +1739,7 @@ wait_signal: WSREP_INFO("Donor state reached"); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.wsrep_donor_state", { const char act[]= @@ -1748,6 +1749,7 @@ wait_signal: assert(!debug_sync_set_action(thd.ptr, STRING_WITH_LEN(act))); };); +#endif goto wait_signal; } diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc index 8639ca91150..62920e56105 100644 --- a/sql/wsrep_thd.cc +++ b/sql/wsrep_thd.cc @@ -348,6 +348,7 @@ bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd) mysql_mutex_assert_owner(&victim_thd->LOCK_thd_data); mysql_mutex_assert_owner(&victim_thd->LOCK_thd_kill); +#ifdef ENABLED_DEBUG_SYNC DBUG_EXECUTE_IF("sync.wsrep_bf_abort", { const char act[]= @@ -357,6 +358,7 @@ bool wsrep_bf_abort(THD* bf_thd, THD* victim_thd) DBUG_ASSERT(!debug_sync_set_action(bf_thd, STRING_WITH_LEN(act))); };); +#endif if (WSREP(victim_thd) && !victim_thd->wsrep_trx().active()) { |