Commit 6a84e340 authored by Andrei Elkin's avatar Andrei Elkin Committed by Monty

MDEV-13073. This patch replaces semisync's native function_enter,exit

and its custom trace faciltiy with standard DBUG_ based equivalents.
parent c0ea3056
...@@ -35,32 +35,6 @@ class Trace { ...@@ -35,32 +35,6 @@ class Trace {
unsigned long trace_level_; /* the level for tracing */ unsigned long trace_level_; /* the level for tracing */
inline void function_enter(const char *func_name)
{
if (trace_level_ & kTraceFunction)
sql_print_information("---> %s enter", func_name);
}
inline int function_exit(const char *func_name, int exit_code)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit (%d)", func_name, exit_code);
return exit_code;
}
inline bool function_exit(const char *func_name, bool exit_code)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit (%s)", func_name,
exit_code ? "True" : "False");
return exit_code;
}
inline void function_exit(const char *func_name)
{
if (trace_level_ & kTraceFunction)
sql_print_information("<--- %s exit", func_name);
}
Trace() Trace()
:trace_level_(0L) :trace_level_(0L)
{} {}
......
...@@ -142,18 +142,18 @@ int ActiveTranx::compare(const char *log_file_name1, my_off_t log_file_pos1, ...@@ -142,18 +142,18 @@ int ActiveTranx::compare(const char *log_file_name1, my_off_t log_file_pos1,
int ActiveTranx::insert_tranx_node(const char *log_file_name, int ActiveTranx::insert_tranx_node(const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ActiveTranx:insert_tranx_node";
TranxNode *ins_node; TranxNode *ins_node;
int result = 0; int result = 0;
unsigned int hash_val; unsigned int hash_val;
function_enter(kWho); DBUG_ENTER("Active_tranx:insert_tranx_node");
ins_node = allocator_.allocate_node(); ins_node = allocator_.allocate_node();
if (!ins_node) if (!ins_node)
{ {
sql_print_error("%s: transaction node allocation failed for: (%s, %lu)", sql_print_error("%s: transaction node allocation failed for: (%s, %lu)",
kWho, log_file_name, (ulong)log_file_pos); "Active_tranx:insert_tranx_node",
log_file_name, (ulong)log_file_pos);
result = -1; result = -1;
goto l_end; goto l_end;
} }
...@@ -185,7 +185,7 @@ int ActiveTranx::insert_tranx_node(const char *log_file_name, ...@@ -185,7 +185,7 @@ int ActiveTranx::insert_tranx_node(const char *log_file_name,
* mysql_bin_log.LOCK_log when appending events. * mysql_bin_log.LOCK_log when appending events.
*/ */
sql_print_error("%s: binlog write out-of-order, tail (%s, %lu), " sql_print_error("%s: binlog write out-of-order, tail (%s, %lu), "
"new node (%s, %lu)", kWho, "new node (%s, %lu)", "Active_tranx:insert_tranx_node",
trx_rear_->log_name_, (ulong)trx_rear_->log_pos_, trx_rear_->log_name_, (ulong)trx_rear_->log_pos_,
ins_node->log_name_, (ulong)ins_node->log_pos_); ins_node->log_name_, (ulong)ins_node->log_pos_);
result = -1; result = -1;
...@@ -197,20 +197,19 @@ int ActiveTranx::insert_tranx_node(const char *log_file_name, ...@@ -197,20 +197,19 @@ int ActiveTranx::insert_tranx_node(const char *log_file_name,
ins_node->hash_next_ = trx_htb_[hash_val]; ins_node->hash_next_ = trx_htb_[hash_val];
trx_htb_[hash_val] = ins_node; trx_htb_[hash_val] = ins_node;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: insert (%s, %lu) in entry(%u)",
sql_print_information("%s: insert (%s, %lu) in entry(%u)", kWho, "Active_tranx:insert_tranx_node",
ins_node->log_name_, (ulong)ins_node->log_pos_, ins_node->log_name_, (ulong)ins_node->log_pos_,
hash_val); hash_val));
l_end: l_end:
return function_exit(kWho, result);
DBUG_RETURN(result);
} }
bool ActiveTranx::is_tranx_end_pos(const char *log_file_name, bool ActiveTranx::is_tranx_end_pos(const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ActiveTranx::is_tranx_end_pos"; DBUG_ENTER("Active_tranx::is_tranx_end_pos");
function_enter(kWho);
unsigned int hash_val = get_hash_value(log_file_name, log_file_pos); unsigned int hash_val = get_hash_value(log_file_name, log_file_pos);
TranxNode *entry = trx_htb_[hash_val]; TranxNode *entry = trx_htb_[hash_val];
...@@ -223,21 +222,19 @@ bool ActiveTranx::is_tranx_end_pos(const char *log_file_name, ...@@ -223,21 +222,19 @@ bool ActiveTranx::is_tranx_end_pos(const char *log_file_name,
entry = entry->hash_next_; entry = entry->hash_next_;
} }
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: probe (%s, %lu) in entry(%u)",
sql_print_information("%s: probe (%s, %lu) in entry(%u)", kWho, "Active_tranx::is_tranx_end_pos",
log_file_name, (ulong)log_file_pos, hash_val); log_file_name, (ulong)log_file_pos, hash_val));
function_exit(kWho, (entry != NULL)); DBUG_RETURN(entry != NULL);
return (entry != NULL);
} }
int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name, int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ActiveTranx::::clear_active_tranx_nodes";
TranxNode *new_front; TranxNode *new_front;
function_enter(kWho); DBUG_ENTER("Active_tranx::::clear_active_tranx_nodes");
if (log_file_name != NULL) if (log_file_name != NULL)
{ {
...@@ -271,8 +268,8 @@ int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name, ...@@ -271,8 +268,8 @@ int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name,
trx_rear_ = NULL; trx_rear_ = NULL;
} }
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: cleared all nodes",
sql_print_information("%s: cleared all nodes", kWho); "Active_tranx::::clear_active_tranx_nodes"));
} }
else if (new_front != trx_front_) else if (new_front != trx_front_)
{ {
...@@ -305,13 +302,13 @@ int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name, ...@@ -305,13 +302,13 @@ int ActiveTranx::clear_active_tranx_nodes(const char *log_file_name,
trx_front_ = new_front; trx_front_ = new_front;
allocator_.free_nodes_before(trx_front_); allocator_.free_nodes_before(trx_front_);
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: cleared %d nodes back until pos (%s, %lu)",
sql_print_information("%s: cleared %d nodes back until pos (%s, %lu)", "Active_tranx::::clear_active_tranx_nodes",
kWho, n_frees, n_frees,
trx_front_->log_name_, (ulong)trx_front_->log_pos_); trx_front_->log_name_, (ulong)trx_front_->log_pos_));
} }
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
...@@ -482,13 +479,14 @@ void ReplSemiSyncMaster::cond_broadcast() ...@@ -482,13 +479,14 @@ void ReplSemiSyncMaster::cond_broadcast()
int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time) int ReplSemiSyncMaster::cond_timewait(struct timespec *wait_time)
{ {
const char *kWho = "ReplSemiSyncMaster::cond_timewait()";
int wait_res; int wait_res;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::cond_timewait()");
wait_res= mysql_cond_timedwait(&COND_binlog_send, wait_res= mysql_cond_timedwait(&COND_binlog_send,
&LOCK_binlog, wait_time); &LOCK_binlog, wait_time);
return function_exit(kWho, wait_res);
DBUG_RETURN(wait_res);
} }
void ReplSemiSyncMaster::add_slave() void ReplSemiSyncMaster::add_slave()
...@@ -520,13 +518,12 @@ void ReplSemiSyncMaster::remove_slave() ...@@ -520,13 +518,12 @@ void ReplSemiSyncMaster::remove_slave()
int ReplSemiSyncMaster::reportReplyPacket(uint32 server_id, const uchar *packet, int ReplSemiSyncMaster::reportReplyPacket(uint32 server_id, const uchar *packet,
ulong packet_len) ulong packet_len)
{ {
const char *kWho = "ReplSemiSyncMaster::reportReplyPacket";
int result= -1; int result= -1;
char log_file_name[FN_REFLEN+1]; char log_file_name[FN_REFLEN+1];
my_off_t log_file_pos; my_off_t log_file_pos;
ulong log_file_len = 0; ulong log_file_len = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::report_reply_packet");
if (unlikely(packet[REPLY_MAGIC_NUM_OFFSET] != ReplSemiSyncMaster::kPacketMagicNum)) if (unlikely(packet[REPLY_MAGIC_NUM_OFFSET] != ReplSemiSyncMaster::kPacketMagicNum))
{ {
...@@ -552,30 +549,30 @@ int ReplSemiSyncMaster::reportReplyPacket(uint32 server_id, const uchar *packet, ...@@ -552,30 +549,30 @@ int ReplSemiSyncMaster::reportReplyPacket(uint32 server_id, const uchar *packet,
DBUG_ASSERT(dirname_length(log_file_name) == 0); DBUG_ASSERT(dirname_length(log_file_name) == 0);
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: Got reply(%s, %lu) from server %u",
sql_print_information("%s: Got reply(%s, %lu) from server %u", "Repl_semi_sync_master::report_reply_packet",
kWho, log_file_name, (ulong)log_file_pos, server_id); log_file_name, (ulong)log_file_pos, server_id));
rpl_semi_sync_master_get_ack++; rpl_semi_sync_master_get_ack++;
reportReplyBinlog(server_id, log_file_name, log_file_pos); reportReplyBinlog(server_id, log_file_name, log_file_pos);
l_end: l_end:
return function_exit(kWho, result);
DBUG_RETURN(result);
} }
int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id, int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
const char *log_file_name, const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ReplSemiSyncMaster::reportReplyBinlog";
int cmp; int cmp;
bool can_release_threads = false; bool can_release_threads = false;
bool need_copy_send_pos = true; bool need_copy_send_pos = true;
if (!(getMasterEnabled())) DBUG_ENTER("Repl_semi_sync_master::report_reply_binlog");
return 0;
function_enter(kWho); if (!(getMasterEnabled()))
DBUG_RETURN(0);
lock(); lock();
...@@ -623,9 +620,9 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id, ...@@ -623,9 +620,9 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
assert(active_tranxs_ != NULL); assert(active_tranxs_ != NULL);
active_tranxs_->clear_active_tranx_nodes(log_file_name, log_file_pos); active_tranxs_->clear_active_tranx_nodes(log_file_name, log_file_pos);
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: Got reply at (%s, %lu)",
sql_print_information("%s: Got reply at (%s, %lu)", kWho, "Repl_semi_sync_master::report_reply_binlog",
log_file_name, (ulong)log_file_pos); log_file_name, (ulong)log_file_pos));
} }
if (rpl_semi_sync_master_wait_sessions > 0) if (rpl_semi_sync_master_wait_sessions > 0)
...@@ -650,13 +647,13 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id, ...@@ -650,13 +647,13 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
if (can_release_threads) if (can_release_threads)
{ {
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: signal all waiting threads.",
sql_print_information("%s: signal all waiting threads.", kWho); "Repl_semi_sync_master::report_reply_binlog"));
cond_broadcast(); cond_broadcast();
} }
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
int ReplSemiSyncMaster::waitAfterSync(const char *log_file, my_off_t log_pos) int ReplSemiSyncMaster::waitAfterSync(const char *log_file, my_off_t log_pos)
...@@ -777,9 +774,8 @@ void ReplSemiSyncMaster::dump_end(THD* thd) ...@@ -777,9 +774,8 @@ void ReplSemiSyncMaster::dump_end(THD* thd)
int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
my_off_t trx_wait_binlog_pos) my_off_t trx_wait_binlog_pos)
{ {
const char *kWho = "ReplSemiSyncMaster::commitTrx";
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::commit_trx");
if (getMasterEnabled() && trx_wait_binlog_name) if (getMasterEnabled() && trx_wait_binlog_name)
{ {
...@@ -803,12 +799,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -803,12 +799,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
if (!getMasterEnabled() || !is_on()) if (!getMasterEnabled() || !is_on())
goto l_end; goto l_end;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: wait pos (%s, %lu), repl(%d)\n",
{ "Repl_semi_sync_master::commit_trx",
sql_print_information("%s: wait pos (%s, %lu), repl(%d)\n", kWho,
trx_wait_binlog_name, (ulong)trx_wait_binlog_pos, trx_wait_binlog_name, (ulong)trx_wait_binlog_pos,
(int)is_on()); (int)is_on()));
}
while (is_on() && !thd_killed(current_thd)) while (is_on() && !thd_killed(current_thd))
{ {
...@@ -821,9 +815,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -821,9 +815,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
/* We have already sent the relevant binlog to the slave: no need to /* We have already sent the relevant binlog to the slave: no need to
* wait here. * wait here.
*/ */
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: Binlog reply is ahead (%s, %lu),",
sql_print_information("%s: Binlog reply is ahead (%s, %lu),", "Repl_semi_sync_master::commit_trx",
kWho, reply_file_name_, (ulong)reply_file_pos_); reply_file_name_,
(ulong)reply_file_pos_));
break; break;
} }
} }
...@@ -842,9 +837,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -842,9 +837,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
wait_file_pos_ = trx_wait_binlog_pos; wait_file_pos_ = trx_wait_binlog_pos;
rpl_semi_sync_master_wait_pos_backtraverse++; rpl_semi_sync_master_wait_pos_backtraverse++;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: move back wait position (%s, %lu),",
sql_print_information("%s: move back wait position (%s, %lu),", "Repl_semi_sync_master::commit_trx",
kWho, wait_file_name_, (ulong)wait_file_pos_); wait_file_name_, (ulong)wait_file_pos_));
} }
} }
else else
...@@ -853,9 +848,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -853,9 +848,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
wait_file_pos_ = trx_wait_binlog_pos; wait_file_pos_ = trx_wait_binlog_pos;
wait_file_name_inited_ = true; wait_file_name_inited_ = true;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: init wait position (%s, %lu),",
sql_print_information("%s: init wait position (%s, %lu),", "Repl_semi_sync_master::commit_trx",
kWho, wait_file_name_, (ulong)wait_file_pos_); wait_file_name_, (ulong)wait_file_pos_));
} }
/* Calcuate the waiting period. */ /* Calcuate the waiting period. */
...@@ -875,10 +870,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -875,10 +870,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
*/ */
rpl_semi_sync_master_wait_sessions++; rpl_semi_sync_master_wait_sessions++;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: wait %lu ms for binlog sent (%s, %lu)",
sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)", "Repl_semi_sync_master::commit_trx",
kWho, wait_timeout_, wait_timeout_,
wait_file_name_, (ulong)wait_file_pos_); wait_file_name_, (ulong)wait_file_pos_));
wait_result = cond_timewait(&abstime); wait_result = cond_timewait(&abstime);
rpl_semi_sync_master_wait_sessions--; rpl_semi_sync_master_wait_sessions--;
...@@ -902,12 +897,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -902,12 +897,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
wait_time = getWaitTime(start_ts); wait_time = getWaitTime(start_ts);
if (wait_time < 0) if (wait_time < 0)
{ {
if (trace_level_ & kTraceGeneral) DBUG_PRINT("semisync", ("Replication semi-sync getWaitTime fail at "
{ "wait position (%s, %lu)",
sql_print_error("Replication semi-sync getWaitTime fail at " trx_wait_binlog_name,
"wait position (%s, %lu)", (ulong)trx_wait_binlog_pos));
trx_wait_binlog_name, (ulong)trx_wait_binlog_pos);
}
rpl_semi_sync_master_timefunc_fails++; rpl_semi_sync_master_timefunc_fails++;
} }
else else
...@@ -940,7 +933,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -940,7 +933,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
THD_EXIT_COND(NULL, & old_stage); THD_EXIT_COND(NULL, & old_stage);
} }
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
/* Indicate that semi-sync replication is OFF now. /* Indicate that semi-sync replication is OFF now.
...@@ -963,10 +956,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name, ...@@ -963,10 +956,10 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
*/ */
int ReplSemiSyncMaster::switch_off() int ReplSemiSyncMaster::switch_off()
{ {
const char *kWho = "ReplSemiSyncMaster::switch_off";
int result; int result;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::switch_off");
state_ = false; state_ = false;
/* Clear the active transaction list. */ /* Clear the active transaction list. */
...@@ -979,17 +972,16 @@ int ReplSemiSyncMaster::switch_off() ...@@ -979,17 +972,16 @@ int ReplSemiSyncMaster::switch_off()
sql_print_information("Semi-sync replication switched OFF."); sql_print_information("Semi-sync replication switched OFF.");
cond_broadcast(); /* wake up all waiting threads */ cond_broadcast(); /* wake up all waiting threads */
return function_exit(kWho, result); DBUG_RETURN(result);
} }
int ReplSemiSyncMaster::try_switch_on(int server_id, int ReplSemiSyncMaster::try_switch_on(int server_id,
const char *log_file_name, const char *log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ReplSemiSyncMaster::try_switch_on";
bool semi_sync_on = false; bool semi_sync_on = false;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::try_switch_on");
/* If the current sending event's position is larger than or equal to the /* If the current sending event's position is larger than or equal to the
* 'largest' commit transaction binlog position, the slave is already * 'largest' commit transaction binlog position, the slave is already
...@@ -1019,20 +1011,19 @@ int ReplSemiSyncMaster::try_switch_on(int server_id, ...@@ -1019,20 +1011,19 @@ int ReplSemiSyncMaster::try_switch_on(int server_id,
(ulong)log_file_pos); (ulong)log_file_pos);
} }
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
int ReplSemiSyncMaster::reserveSyncHeader(String* packet) int ReplSemiSyncMaster::reserveSyncHeader(String* packet)
{ {
const char *kWho = "ReplSemiSyncMaster::reserveSyncHeader"; DBUG_ENTER("Repl_semi_sync_master::reserve_sync_header");
function_enter(kWho);
/* Set the magic number and the sync status. By default, no sync /* Set the magic number and the sync status. By default, no sync
* is required. * is required.
*/ */
packet->append(reinterpret_cast<const char*>(kSyncHeader), packet->append(reinterpret_cast<const char*>(kSyncHeader),
sizeof(kSyncHeader)); sizeof(kSyncHeader));
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet, int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet,
...@@ -1040,21 +1031,20 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet, ...@@ -1040,21 +1031,20 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet,
my_off_t log_file_pos, my_off_t log_file_pos,
bool* need_sync) bool* need_sync)
{ {
const char *kWho = "ReplSemiSyncMaster::updateSyncHeader";
int cmp = 0; int cmp = 0;
bool sync = false; bool sync = false;
DBUG_ENTER("Repl_semi_sync_master::update_sync_header");
/* If the semi-sync master is not enabled, or the slave is not a semi-sync /* If the semi-sync master is not enabled, or the slave is not a semi-sync
* target, do not request replies from the slave. * target, do not request replies from the slave.
*/ */
if (!getMasterEnabled() || !thd->semi_sync_slave) if (!getMasterEnabled() || !thd->semi_sync_slave)
{ {
*need_sync = false; *need_sync = false;
return 0; DBUG_RETURN(0);
} }
function_enter(kWho);
lock(); lock();
/* This is the real check inside the mutex. */ /* This is the real check inside the mutex. */
...@@ -1119,10 +1109,10 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet, ...@@ -1119,10 +1109,10 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet,
} }
} }
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: server(%lu), (%s, %lu) sync(%d), repl(%d)",
sql_print_information("%s: server(%d), (%s, %lu) sync(%d), repl(%d)", "Repl_semi_sync_master::update_sync_header",
kWho, thd->variables.server_id, log_file_name, thd->variables.server_id, log_file_name,
(ulong)log_file_pos, sync, (int)is_on()); (ulong)log_file_pos, sync, (int)is_on()));
*need_sync= sync; *need_sync= sync;
l_end: l_end:
...@@ -1136,16 +1126,15 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet, ...@@ -1136,16 +1126,15 @@ int ReplSemiSyncMaster::updateSyncHeader(THD* thd, unsigned char *packet,
(packet)[2] = kPacketFlagSync; (packet)[2] = kPacketFlagSync;
} }
return function_exit(kWho, 0); DBUG_RETURN(0);
} }
int ReplSemiSyncMaster::writeTranxInBinlog(const char* log_file_name, int ReplSemiSyncMaster::writeTranxInBinlog(const char* log_file_name,
my_off_t log_file_pos) my_off_t log_file_pos)
{ {
const char *kWho = "ReplSemiSyncMaster::writeTranxInBinlog";
int result = 0; int result = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::write_tranx_in_binlog");
lock(); lock();
...@@ -1202,17 +1191,16 @@ int ReplSemiSyncMaster::writeTranxInBinlog(const char* log_file_name, ...@@ -1202,17 +1191,16 @@ int ReplSemiSyncMaster::writeTranxInBinlog(const char* log_file_name,
l_end: l_end:
unlock(); unlock();
return function_exit(kWho, result); DBUG_RETURN(result);
} }
int ReplSemiSyncMaster::flushNet(THD *thd, int ReplSemiSyncMaster::flushNet(THD *thd,
const char *event_buf) const char *event_buf)
{ {
const char *kWho = "ReplSemiSyncMaster::flushNet";
int result = -1; int result = -1;
NET* net= &thd->net; NET* net= &thd->net;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::flush_net");
assert((unsigned char)event_buf[1] == kPacketMagicNum); assert((unsigned char)event_buf[1] == kPacketMagicNum);
if ((unsigned char)event_buf[2] != kPacketFlagSync) if ((unsigned char)event_buf[2] != kPacketFlagSync)
...@@ -1239,15 +1227,15 @@ int ReplSemiSyncMaster::flushNet(THD *thd, ...@@ -1239,15 +1227,15 @@ int ReplSemiSyncMaster::flushNet(THD *thd,
l_end: l_end:
thd->clear_error(); thd->clear_error();
return function_exit(kWho, result);
DBUG_RETURN(result);
} }
int ReplSemiSyncMaster::afterResetMaster() int ReplSemiSyncMaster::afterResetMaster()
{ {
const char *kWho = "ReplSemiSyncMaster::afterResetMaster";
int result = 0; int result = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::after_reset_master");
if (rpl_semi_sync_master_enabled) if (rpl_semi_sync_master_enabled)
{ {
...@@ -1280,20 +1268,19 @@ int ReplSemiSyncMaster::afterResetMaster() ...@@ -1280,20 +1268,19 @@ int ReplSemiSyncMaster::afterResetMaster()
unlock(); unlock();
return function_exit(kWho, result); DBUG_RETURN(result);
} }
int ReplSemiSyncMaster::beforeResetMaster() int ReplSemiSyncMaster::beforeResetMaster()
{ {
const char *kWho = "ReplSemiSyncMaster::beforeResetMaster";
int result = 0; int result = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_master::before_reset_master");
if (rpl_semi_sync_master_enabled) if (rpl_semi_sync_master_enabled)
disableMaster(); disableMaster();
return function_exit(kWho, result); DBUG_RETURN(result);
} }
void ReplSemiSyncMaster::checkAndSwitch() void ReplSemiSyncMaster::checkAndSwitch()
......
...@@ -36,8 +36,7 @@ pthread_handler_t ack_receive_handler(void *arg) ...@@ -36,8 +36,7 @@ pthread_handler_t ack_receive_handler(void *arg)
Ack_receiver::Ack_receiver() Ack_receiver::Ack_receiver()
{ {
const char *kWho = "Ack_receiver::Ack_receiver"; DBUG_ENTER("Ack_receiver::Ack_receiver");
function_enter(kWho);
m_status= ST_DOWN; m_status= ST_DOWN;
mysql_mutex_init(key_ss_mutex_Ack_receiver_mutex, &m_mutex, mysql_mutex_init(key_ss_mutex_Ack_receiver_mutex, &m_mutex,
...@@ -45,25 +44,23 @@ Ack_receiver::Ack_receiver() ...@@ -45,25 +44,23 @@ Ack_receiver::Ack_receiver()
mysql_cond_init(key_ss_cond_Ack_receiver_cond, &m_cond, NULL); mysql_cond_init(key_ss_cond_Ack_receiver_cond, &m_cond, NULL);
m_pid= 0; m_pid= 0;
function_exit(kWho); DBUG_VOID_RETURN;
} }
void Ack_receiver::cleanup() void Ack_receiver::cleanup()
{ {
const char *kWho = "Ack_receiver::~Ack_receiver"; DBUG_ENTER("Ack_receiver::~Ack_receiver");
function_enter(kWho);
stop(); stop();
mysql_mutex_destroy(&m_mutex); mysql_mutex_destroy(&m_mutex);
mysql_cond_destroy(&m_cond); mysql_cond_destroy(&m_cond);
function_exit(kWho); DBUG_VOID_RETURN;
} }
bool Ack_receiver::start() bool Ack_receiver::start()
{ {
const char *kWho = "Ack_receiver::start"; DBUG_ENTER("Ack_receiver::start");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if(m_status == ST_DOWN) if(m_status == ST_DOWN)
...@@ -87,19 +84,18 @@ bool Ack_receiver::start() ...@@ -87,19 +84,18 @@ bool Ack_receiver::start()
m_status= ST_DOWN; m_status= ST_DOWN;
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, true); DBUG_RETURN(true);
} }
(void) pthread_attr_destroy(&attr); (void) pthread_attr_destroy(&attr);
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, false); DBUG_RETURN(false);
} }
void Ack_receiver::stop() void Ack_receiver::stop()
{ {
const char *kWho = "Ack_receiver::stop"; DBUG_ENTER("Ack_receiver::stop");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
if (m_status == ST_UP) if (m_status == ST_UP)
...@@ -116,17 +112,16 @@ void Ack_receiver::stop() ...@@ -116,17 +112,16 @@ void Ack_receiver::stop()
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
function_exit(kWho); DBUG_VOID_RETURN;
} }
bool Ack_receiver::add_slave(THD *thd) bool Ack_receiver::add_slave(THD *thd)
{ {
Slave *slave; Slave *slave;
const char *kWho = "Ack_receiver::add_slave"; DBUG_ENTER("Ack_receiver::add_slave");
function_enter(kWho);
if (!(slave= new Slave)) if (!(slave= new Slave))
return function_exit(kWho, true); DBUG_RETURN(true);
slave->thd= thd; slave->thd= thd;
slave->vio= *thd->net.vio; slave->vio= *thd->net.vio;
...@@ -139,15 +134,14 @@ bool Ack_receiver::add_slave(THD *thd) ...@@ -139,15 +134,14 @@ bool Ack_receiver::add_slave(THD *thd)
mysql_cond_broadcast(&m_cond); mysql_cond_broadcast(&m_cond);
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
return function_exit(kWho, false); DBUG_RETURN(false);
} }
void Ack_receiver::remove_slave(THD *thd) void Ack_receiver::remove_slave(THD *thd)
{ {
I_List_iterator<Slave> it(m_slaves); I_List_iterator<Slave> it(m_slaves);
Slave *slave; Slave *slave;
const char *kWho = "Ack_receiver::remove_slave"; DBUG_ENTER("Ack_receiver::remove_slave");
function_enter(kWho);
mysql_mutex_lock(&m_mutex); mysql_mutex_lock(&m_mutex);
...@@ -161,7 +155,8 @@ void Ack_receiver::remove_slave(THD *thd) ...@@ -161,7 +155,8 @@ void Ack_receiver::remove_slave(THD *thd)
} }
} }
mysql_mutex_unlock(&m_mutex); mysql_mutex_unlock(&m_mutex);
function_exit(kWho);
DBUG_VOID_RETURN;
} }
inline void Ack_receiver::set_stage_info(const PSI_stage_info &stage) inline void Ack_receiver::set_stage_info(const PSI_stage_info &stage)
......
...@@ -58,9 +58,8 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -58,9 +58,8 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
const char **payload, const char **payload,
unsigned long *payload_len) unsigned long *payload_len)
{ {
const char *kWho = "ReplSemiSyncSlave::slaveReadSyncHeader";
int read_res = 0; int read_res = 0;
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_slave::slave_read_sync_header");
if (rpl_semi_sync_slave_status) if (rpl_semi_sync_slave_status)
{ {
...@@ -71,8 +70,9 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -71,8 +70,9 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
*payload_len = total_len - 2; *payload_len = total_len - 2;
*payload = header + 2; *payload = header + 2;
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: reply - %d",
sql_print_information("%s: reply - %d", kWho, semi_sync_need_reply); "Repl_semi_sync_slave::slave_read_sync_header",
semi_sync_need_reply));
if (semi_sync_need_reply) if (semi_sync_need_reply)
*semi_flags |= SEMI_SYNC_NEED_ACK; *semi_flags |= SEMI_SYNC_NEED_ACK;
...@@ -90,7 +90,7 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header, ...@@ -90,7 +90,7 @@ int ReplSemiSyncSlave::slaveReadSyncHeader(const char *header,
*payload_len= total_len; *payload_len= total_len;
} }
return function_exit(kWho, read_res); DBUG_RETURN(read_res);
} }
int ReplSemiSyncSlave::slaveStart(Master_info *mi) int ReplSemiSyncSlave::slaveStart(Master_info *mi)
...@@ -203,7 +203,6 @@ int ReplSemiSyncSlave::requestTransmit(Master_info *mi) ...@@ -203,7 +203,6 @@ int ReplSemiSyncSlave::requestTransmit(Master_info *mi)
int ReplSemiSyncSlave::slaveReply(Master_info *mi) int ReplSemiSyncSlave::slaveReply(Master_info *mi)
{ {
const char *kWho = "ReplSemiSyncSlave::slaveReply";
MYSQL* mysql= mi->mysql; MYSQL* mysql= mi->mysql;
const char *binlog_filename= const_cast<char *>(mi->master_log_name); const char *binlog_filename= const_cast<char *>(mi->master_log_name);
my_off_t binlog_filepos= mi->master_log_pos; my_off_t binlog_filepos= mi->master_log_pos;
...@@ -215,7 +214,7 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -215,7 +214,7 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
int reply_res = 0; int reply_res = 0;
int name_len = strlen(binlog_filename); int name_len = strlen(binlog_filename);
function_enter(kWho); DBUG_ENTER("Repl_semi_sync_slave::slave_reply");
if (rpl_semi_sync_slave_status && semi_sync_need_reply) if (rpl_semi_sync_slave_status && semi_sync_need_reply)
{ {
...@@ -226,9 +225,9 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -226,9 +225,9 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
binlog_filename, binlog_filename,
name_len + 1 /* including trailing '\0' */); name_len + 1 /* including trailing '\0' */);
if (trace_level_ & kTraceDetail) DBUG_PRINT("semisync", ("%s: reply (%s, %lu)",
sql_print_information("%s: reply (%s, %lu)", kWho, "Repl_semi_sync_slave::slave_reply",
binlog_filename, (ulong)binlog_filepos); binlog_filename, (ulong)binlog_filepos));
net_clear(net, 0); net_clear(net, 0);
/* Send the reply. */ /* Send the reply. */
...@@ -248,5 +247,5 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi) ...@@ -248,5 +247,5 @@ int ReplSemiSyncSlave::slaveReply(Master_info *mi)
} }
} }
return function_exit(kWho, reply_res); DBUG_RETURN(reply_res);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment