summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorHe Zhenxing <zhenxing.he@sun.com>2009-10-12 21:03:04 +0800
committerHe Zhenxing <zhenxing.he@sun.com>2009-10-12 21:03:04 +0800
commit64fc766c93e4a5c9835af091d9adbb0799a301ad (patch)
tree45eb05d5a79315145783470db8208ec16cc42ea5 /plugin
parent7d3d0fc303183ef50a343680ce70df71d5675cd1 (diff)
downloadmariadb-git-64fc766c93e4a5c9835af091d9adbb0799a301ad.tar.gz
BUG#45674 FLUSH STATUS does not reset semisynchronous counters
Semi-sync status were not reset by FLUSH STATUS, this was because all semi-sync status variables are defined as SHOW_FUNC and FLUSH STATUS could only reset SHOW_LONG type variables. This problem is fixed by change all status variables that should be reset by FLUSH STATUS from SHOW_FUNC to SHOW_LONG. After the fix, the following status variables will be reset by FLUSH STATUS: Rpl_semi_sync_master_yes_tx Rpl_semi_sync_master_no_tx Note: normally, FLUSH STATUS itself will be written into binlog and be replicated, so after FLUSH STATS, one of Rpl_semi_sync_master_yes_tx Rpl_semi_sync_master_no_tx can be 1 dependent on the semi-sync status. So it's recommended to use FLUSH NO_WRITE_TO_BINLOG STATUS to avoid this.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/semisync/semisync_master.cc94
-rw-r--r--plugin/semisync/semisync_master.h27
-rw-r--r--plugin/semisync/semisync_master_plugin.cc77
3 files changed, 90 insertions, 108 deletions
diff --git a/plugin/semisync/semisync_master.cc b/plugin/semisync/semisync_master.cc
index decab205674..a51c1e5bc5c 100644
--- a/plugin/semisync/semisync_master.cc
+++ b/plugin/semisync/semisync_master.cc
@@ -30,16 +30,16 @@ unsigned long rpl_semi_sync_master_yes_transactions = 0;
unsigned long rpl_semi_sync_master_no_transactions = 0;
unsigned long rpl_semi_sync_master_off_times = 0;
unsigned long rpl_semi_sync_master_timefunc_fails = 0;
-unsigned long rpl_semi_sync_master_num_timeouts = 0;
+unsigned long rpl_semi_sync_master_wait_timeouts = 0;
unsigned long rpl_semi_sync_master_wait_sessions = 0;
-unsigned long rpl_semi_sync_master_back_wait_pos = 0;
-unsigned long rpl_semi_sync_master_trx_wait_time = 0;
+unsigned long rpl_semi_sync_master_wait_pos_backtraverse = 0;
+unsigned long rpl_semi_sync_master_avg_trx_wait_time = 0;
unsigned long long rpl_semi_sync_master_trx_wait_num = 0;
-unsigned long rpl_semi_sync_master_net_wait_time = 0;
+unsigned long rpl_semi_sync_master_avg_net_wait_time = 0;
unsigned long long rpl_semi_sync_master_net_wait_num = 0;
unsigned long rpl_semi_sync_master_clients = 0;
-unsigned long long rpl_semi_sync_master_net_wait_total_time = 0;
-unsigned long long rpl_semi_sync_master_trx_wait_total_time = 0;
+unsigned long long rpl_semi_sync_master_net_wait_time = 0;
+unsigned long long rpl_semi_sync_master_trx_wait_time = 0;
static int getWaitTime(const struct timeval& start_tv);
@@ -379,16 +379,6 @@ ReplSemiSyncMaster::ReplSemiSyncMaster()
master_enabled_(false),
wait_timeout_(0L),
state_(0),
- enabled_transactions_(0),
- disabled_transactions_(0),
- switched_off_times_(0),
- timefunc_fails_(0),
- wait_sessions_(0),
- wait_backtraverse_(0),
- total_trx_wait_num_(0),
- total_trx_wait_time_(0),
- total_net_wait_num_(0),
- total_net_wait_time_(0),
max_transactions_(0L)
{
strcpy(reply_file_name_, "");
@@ -611,7 +601,7 @@ int ReplSemiSyncMaster::reportReplyBinlog(uint32 server_id,
log_file_name, (unsigned long)log_file_pos);
}
- if (wait_sessions_ > 0)
+ if (rpl_semi_sync_master_wait_sessions > 0)
{
/* Let us check if some of the waiting threads doing a trx
* commit can now proceed.
@@ -707,7 +697,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
strcpy(wait_file_name_, trx_wait_binlog_name);
wait_file_pos_ = trx_wait_binlog_pos;
- wait_backtraverse_++;
+ rpl_semi_sync_master_wait_pos_backtraverse++;
if (trace_level_ & kTraceDetail)
sql_print_information("%s: move back wait position (%s, %lu),",
kWho, wait_file_name_, (unsigned long)wait_file_pos_);
@@ -752,7 +742,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
* when replication has progressed far enough, we will release
* these waiting threads.
*/
- wait_sessions_++;
+ rpl_semi_sync_master_wait_sessions++;
if (trace_level_ & kTraceDetail)
sql_print_information("%s: wait %lu ms for binlog sent (%s, %lu)",
@@ -760,7 +750,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
wait_file_name_, (unsigned long)wait_file_pos_);
wait_result = cond_timewait(&abstime);
- wait_sessions_--;
+ rpl_semi_sync_master_wait_sessions--;
if (wait_result != 0)
{
@@ -769,7 +759,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
"semi-sync up to file %s, position %lu.",
trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos,
reply_file_name_, (unsigned long)reply_file_pos_);
- total_wait_timeouts_++;
+ rpl_semi_sync_master_wait_timeouts++;
/* switch semi-sync off */
switch_off();
@@ -788,12 +778,12 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
"wait position (%s, %lu)",
trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos);
}
- timefunc_fails_++;
+ rpl_semi_sync_master_timefunc_fails++;
}
else
{
- total_trx_wait_num_++;
- total_trx_wait_time_ += wait_time;
+ rpl_semi_sync_master_trx_wait_num++;
+ rpl_semi_sync_master_trx_wait_time += wait_time;
}
}
}
@@ -806,7 +796,7 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
"wait position (%s, %lu)",
trx_wait_binlog_name, (unsigned long)trx_wait_binlog_pos);
}
- timefunc_fails_++;
+ rpl_semi_sync_master_timefunc_fails++;
/* switch semi-sync off */
switch_off();
@@ -823,9 +813,9 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
/* Update the status counter. */
if (is_on() && rpl_semi_sync_master_clients)
- enabled_transactions_++;
+ rpl_semi_sync_master_yes_transactions++;
else
- disabled_transactions_++;
+ rpl_semi_sync_master_no_transactions++;
/* The lock held will be released by thd_exit_cond, so no need to
call unlock() here */
@@ -865,7 +855,7 @@ int ReplSemiSyncMaster::switch_off()
assert(active_tranxs_ != NULL);
result = active_tranxs_->clear_active_tranx_nodes(NULL, 0);
- switched_off_times_++;
+ rpl_semi_sync_master_off_times++;
wait_file_name_inited_ = false;
reply_file_name_inited_ = false;
sql_print_information("Semi-sync replication switched OFF.");
@@ -1232,16 +1222,16 @@ int ReplSemiSyncMaster::resetMaster()
reply_file_name_inited_ = false;
commit_file_name_inited_ = false;
- enabled_transactions_ = 0;
- disabled_transactions_ = 0;
- switched_off_times_ = 0;
- timefunc_fails_ = 0;
- wait_sessions_ = 0;
- wait_backtraverse_ = 0;
- total_trx_wait_num_ = 0;
- total_trx_wait_time_ = 0;
- total_net_wait_num_ = 0;
- total_net_wait_time_ = 0;
+ rpl_semi_sync_master_yes_transactions = 0;
+ rpl_semi_sync_master_no_transactions = 0;
+ rpl_semi_sync_master_off_times = 0;
+ rpl_semi_sync_master_timefunc_fails = 0;
+ rpl_semi_sync_master_wait_sessions = 0;
+ rpl_semi_sync_master_wait_pos_backtraverse = 0;
+ rpl_semi_sync_master_trx_wait_num = 0;
+ rpl_semi_sync_master_trx_wait_time = 0;
+ rpl_semi_sync_master_net_wait_num = 0;
+ rpl_semi_sync_master_net_wait_time = 0;
unlock();
@@ -1253,26 +1243,14 @@ void ReplSemiSyncMaster::setExportStats()
lock();
rpl_semi_sync_master_status = state_ && rpl_semi_sync_master_clients;
- rpl_semi_sync_master_yes_transactions = enabled_transactions_;
- rpl_semi_sync_master_no_transactions = disabled_transactions_;
- rpl_semi_sync_master_off_times = switched_off_times_;
- rpl_semi_sync_master_timefunc_fails = timefunc_fails_;
- rpl_semi_sync_master_num_timeouts = total_wait_timeouts_;
- rpl_semi_sync_master_wait_sessions = wait_sessions_;
- rpl_semi_sync_master_back_wait_pos = wait_backtraverse_;
- rpl_semi_sync_master_trx_wait_num = total_trx_wait_num_;
- rpl_semi_sync_master_trx_wait_time =
- ((total_trx_wait_num_) ?
- (unsigned long)((double)total_trx_wait_time_ /
- ((double)total_trx_wait_num_)) : 0);
- rpl_semi_sync_master_net_wait_num = total_net_wait_num_;
- rpl_semi_sync_master_net_wait_time =
- ((total_net_wait_num_) ?
- (unsigned long)((double)total_net_wait_time_ /
- ((double)total_net_wait_num_)) : 0);
-
- rpl_semi_sync_master_net_wait_total_time = total_net_wait_time_;
- rpl_semi_sync_master_trx_wait_total_time = total_trx_wait_time_;
+ rpl_semi_sync_master_avg_trx_wait_time=
+ ((rpl_semi_sync_master_trx_wait_num) ?
+ (unsigned long)((double)rpl_semi_sync_master_trx_wait_time /
+ ((double)rpl_semi_sync_master_trx_wait_num)) : 0);
+ rpl_semi_sync_master_avg_net_wait_time=
+ ((rpl_semi_sync_master_net_wait_num) ?
+ (unsigned long)((double)rpl_semi_sync_master_net_wait_time /
+ ((double)rpl_semi_sync_master_net_wait_num)) : 0);
unlock();
}
diff --git a/plugin/semisync/semisync_master.h b/plugin/semisync/semisync_master.h
index 50a4665efb8..28c0041ff72 100644
--- a/plugin/semisync/semisync_master.h
+++ b/plugin/semisync/semisync_master.h
@@ -175,19 +175,7 @@ class ReplSemiSyncMaster
volatile bool master_enabled_; /* semi-sync is enabled on the master */
unsigned long wait_timeout_; /* timeout period(ms) during tranx wait */
- /* All status variables. */
bool state_; /* whether semi-sync is switched */
- unsigned long enabled_transactions_; /* semi-sync'ed tansactions */
- unsigned long disabled_transactions_; /* non-semi-sync'ed tansactions */
- unsigned long switched_off_times_; /* how many times are switched off? */
- unsigned long timefunc_fails_; /* how many time function fails? */
- unsigned long total_wait_timeouts_; /* total number of wait timeouts */
- unsigned long wait_sessions_; /* how many sessions wait for replies? */
- unsigned long wait_backtraverse_; /* wait position back traverses */
- unsigned long long total_trx_wait_num_; /* total trx waits: non-timeout ones */
- unsigned long long total_trx_wait_time_; /* total trx wait time: in us */
- unsigned long long total_net_wait_num_; /* total network waits */
- unsigned long long total_net_wait_time_; /* total network wait time */
/* The number of maximum active transactions. This should be the same as
* maximum connections because MySQL does not do connection sharing now.
@@ -356,22 +344,23 @@ class ReplSemiSyncMaster
/* System and status variables for the master component */
extern char rpl_semi_sync_master_enabled;
+extern char rpl_semi_sync_master_status;
+extern unsigned long rpl_semi_sync_master_clients;
extern unsigned long rpl_semi_sync_master_timeout;
extern unsigned long rpl_semi_sync_master_trace_level;
-extern char rpl_semi_sync_master_status;
extern unsigned long rpl_semi_sync_master_yes_transactions;
extern unsigned long rpl_semi_sync_master_no_transactions;
extern unsigned long rpl_semi_sync_master_off_times;
+extern unsigned long rpl_semi_sync_master_wait_timeouts;
extern unsigned long rpl_semi_sync_master_timefunc_fails;
extern unsigned long rpl_semi_sync_master_num_timeouts;
extern unsigned long rpl_semi_sync_master_wait_sessions;
-extern unsigned long rpl_semi_sync_master_back_wait_pos;
-extern unsigned long rpl_semi_sync_master_trx_wait_time;
-extern unsigned long rpl_semi_sync_master_net_wait_time;
+extern unsigned long rpl_semi_sync_master_wait_pos_backtraverse;
+extern unsigned long rpl_semi_sync_master_avg_trx_wait_time;
+extern unsigned long rpl_semi_sync_master_avg_net_wait_time;
extern unsigned long long rpl_semi_sync_master_net_wait_num;
extern unsigned long long rpl_semi_sync_master_trx_wait_num;
-extern unsigned long long rpl_semi_sync_master_net_wait_total_time;
-extern unsigned long long rpl_semi_sync_master_trx_wait_total_time;
-extern unsigned long rpl_semi_sync_master_clients;
+extern unsigned long long rpl_semi_sync_master_net_wait_time;
+extern unsigned long long rpl_semi_sync_master_trx_wait_time;
#endif /* SEMISYNC_MASTER_H */
diff --git a/plugin/semisync/semisync_master_plugin.cc b/plugin/semisync/semisync_master_plugin.cc
index 9c76b5369b6..4b98ec5d835 100644
--- a/plugin/semisync/semisync_master_plugin.cc
+++ b/plugin/semisync/semisync_master_plugin.cc
@@ -268,45 +268,60 @@ Binlog_transmit_observer transmit_observer = {
return 0; \
}
-DEF_SHOW_FUNC(clients, SHOW_LONG)
-DEF_SHOW_FUNC(net_wait_time, SHOW_LONG)
-DEF_SHOW_FUNC(net_wait_total_time, SHOW_LONGLONG)
-DEF_SHOW_FUNC(net_wait_num, SHOW_LONGLONG)
-DEF_SHOW_FUNC(off_times, SHOW_LONG)
-DEF_SHOW_FUNC(no_transactions, SHOW_LONG)
DEF_SHOW_FUNC(status, SHOW_BOOL)
-DEF_SHOW_FUNC(timefunc_fails, SHOW_LONG)
-DEF_SHOW_FUNC(trx_wait_time, SHOW_LONG)
-DEF_SHOW_FUNC(trx_wait_total_time, SHOW_LONGLONG)
+DEF_SHOW_FUNC(clients, SHOW_LONG)
+DEF_SHOW_FUNC(trx_wait_time, SHOW_LONGLONG)
DEF_SHOW_FUNC(trx_wait_num, SHOW_LONGLONG)
-DEF_SHOW_FUNC(back_wait_pos, SHOW_LONG)
-DEF_SHOW_FUNC(wait_sessions, SHOW_LONG)
-DEF_SHOW_FUNC(yes_transactions, SHOW_LONG)
+DEF_SHOW_FUNC(net_wait_time, SHOW_LONGLONG)
+DEF_SHOW_FUNC(net_wait_num, SHOW_LONGLONG)
+DEF_SHOW_FUNC(avg_net_wait_time, SHOW_LONG)
+DEF_SHOW_FUNC(avg_trx_wait_time, SHOW_LONG)
/* plugin status variables */
static SHOW_VAR semi_sync_master_status_vars[]= {
- {"Rpl_semi_sync_master_clients", (char*) &SHOW_FNAME(clients), SHOW_FUNC},
- {"Rpl_semi_sync_master_net_avg_wait_time",
- (char*) &SHOW_FNAME(net_wait_time), SHOW_FUNC},
- {"Rpl_semi_sync_master_net_wait_time",
- (char*) &SHOW_FNAME(net_wait_total_time), SHOW_FUNC},
- {"Rpl_semi_sync_master_net_waits", (char*) &SHOW_FNAME(net_wait_num), SHOW_FUNC},
- {"Rpl_semi_sync_master_no_times", (char*) &SHOW_FNAME(off_times), SHOW_FUNC},
- {"Rpl_semi_sync_master_no_tx", (char*) &SHOW_FNAME(no_transactions), SHOW_FUNC},
- {"Rpl_semi_sync_master_status", (char*) &SHOW_FNAME(status), SHOW_FUNC},
+ {"Rpl_semi_sync_master_status",
+ (char*) &SHOW_FNAME(status),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_clients",
+ (char*) &SHOW_FNAME(clients),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_yes_tx",
+ (char*) &rpl_semi_sync_master_yes_transactions,
+ SHOW_LONG},
+ {"Rpl_semi_sync_master_no_tx",
+ (char*) &rpl_semi_sync_master_no_transactions,
+ SHOW_LONG},
+ {"Rpl_semi_sync_master_wait_sessions",
+ (char*) &rpl_semi_sync_master_wait_sessions,
+ SHOW_LONG},
+ {"Rpl_semi_sync_master_no_times",
+ (char*) &rpl_semi_sync_master_off_times,
+ SHOW_LONG},
{"Rpl_semi_sync_master_timefunc_failures",
- (char*) &SHOW_FNAME(timefunc_fails), SHOW_FUNC},
- {"Rpl_semi_sync_master_tx_avg_wait_time",
- (char*) &SHOW_FNAME(trx_wait_time), SHOW_FUNC},
- {"Rpl_semi_sync_master_tx_wait_time",
- (char*) &SHOW_FNAME(trx_wait_total_time), SHOW_FUNC},
- {"Rpl_semi_sync_master_tx_waits", (char*) &SHOW_FNAME(trx_wait_num), SHOW_FUNC},
+ (char*) &rpl_semi_sync_master_timefunc_fails,
+ SHOW_LONG},
{"Rpl_semi_sync_master_wait_pos_backtraverse",
- (char*) &SHOW_FNAME(back_wait_pos), SHOW_FUNC},
- {"Rpl_semi_sync_master_wait_sessions",
- (char*) &SHOW_FNAME(wait_sessions), SHOW_FUNC},
- {"Rpl_semi_sync_master_yes_tx", (char*) &SHOW_FNAME(yes_transactions), SHOW_FUNC},
+ (char*) &rpl_semi_sync_master_wait_pos_backtraverse,
+ SHOW_LONG},
+ {"Rpl_semi_sync_master_tx_wait_time",
+ (char*) &SHOW_FNAME(trx_wait_time),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_tx_waits",
+ (char*) &SHOW_FNAME(trx_wait_num),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_tx_avg_wait_time",
+ (char*) &SHOW_FNAME(avg_trx_wait_time),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_net_wait_time",
+ (char*) &SHOW_FNAME(net_wait_time),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_net_waits",
+ (char*) &SHOW_FNAME(net_wait_num),
+ SHOW_FUNC},
+ {"Rpl_semi_sync_master_net_avg_wait_time",
+ (char*) &SHOW_FNAME(avg_net_wait_time),
+ SHOW_FUNC},
{NULL, NULL, SHOW_LONG},
};