summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authordlenev@jabberwock.localdomain <>2004-04-02 00:47:20 +0400
committerdlenev@jabberwock.localdomain <>2004-04-02 00:47:20 +0400
commita80f46bfdf6e84d04a9af5d27b6985299e1d225c (patch)
treedfc52e593ad673b6bc6c3758338f9b94e68f3daa /sql
parentad7e09dec4a3d05170ca4e86a9c285f4d3fac05e (diff)
downloadmariadb-git-a80f46bfdf6e84d04a9af5d27b6985299e1d225c.tar.gz
WL#775 "Add status variable identifying binlog_cache_size shortage"
Added two status variables: binlog_cache_use - counts number of transactions that used somehow transaction temporary binary log. binlog_cache_disk_use - counts number of transactions that required disk I/O for storing info in this this binary log.
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.cc29
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/mysqld.cc4
3 files changed, 31 insertions, 3 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index 38b95424637..ddf2e68db47 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -405,6 +405,16 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans)
my_b_tell(&thd->transaction.trans_log))
{
mysql_bin_log.write(thd, &thd->transaction.trans_log, 1);
+ statistic_increment(binlog_cache_use, &LOCK_status);
+ if (thd->transaction.trans_log.disk_writes != 0)
+ {
+ /*
+ We have to do this after addition of trans_log to main binlog since
+ this operation can cause flushing of end of trans_log to disk.
+ */
+ statistic_increment(binlog_cache_disk_use, &LOCK_status);
+ thd->transaction.trans_log.disk_writes= 0;
+ }
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
@@ -492,10 +502,23 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
Update the binary log with a BEGIN/ROLLBACK block if we have cached some
queries and we updated some non-transactional table. Such cases should
be rare (updating a non-transactional table inside a transaction...).
+ Count disk writes to trans_log in any case.
*/
- if (unlikely((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) &&
- my_b_tell(&thd->transaction.trans_log)))
- mysql_bin_log.write(thd, &thd->transaction.trans_log, 0);
+ if (my_b_tell(&thd->transaction.trans_log))
+ {
+ if (unlikely(thd->options & OPTION_STATUS_NO_TRANS_UPDATE))
+ mysql_bin_log.write(thd, &thd->transaction.trans_log, 0);
+ statistic_increment(binlog_cache_use, &LOCK_status);
+ if (thd->transaction.trans_log.disk_writes != 0)
+ {
+ /*
+ We have to do this after addition of trans_log to main binlog since
+ this operation can cause flushing of end of trans_log to disk.
+ */
+ statistic_increment(binlog_cache_disk_use, &LOCK_status);
+ thd->transaction.trans_log.disk_writes= 0;
+ }
+ }
/* Flushed or not, empty the binlog cache */
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 4fd41b7bd66..a979ef137ae 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -791,6 +791,7 @@ extern ulonglong log_10_int[20];
extern ulonglong keybuff_size;
extern ulong refresh_version,flush_version, thread_id,query_id,opened_tables;
extern ulong created_tmp_tables, created_tmp_disk_tables, bytes_sent;
+extern ulong binlog_cache_use, binlog_cache_disk_use;
extern ulong aborted_threads,aborted_connects;
extern ulong delayed_insert_timeout;
extern ulong delayed_insert_limit, delayed_queue_size;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index d602c44c8f9..308f50c3eb0 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -297,6 +297,7 @@ ulong select_range_check_count, select_range_count, select_scan_count;
ulong select_full_range_join_count,select_full_join_count;
ulong specialflag=0,opened_tables=0,created_tmp_tables=0,
created_tmp_disk_tables=0;
+ulong binlog_cache_use= 0, binlog_cache_disk_use= 0;
ulong max_connections,max_used_connections,
max_connect_errors, max_user_connections = 0;
ulong thread_id=1L,current_pid;
@@ -4719,6 +4720,8 @@ The minimum value for this variable is 4096.",
struct show_var_st status_vars[]= {
{"Aborted_clients", (char*) &aborted_threads, SHOW_LONG},
{"Aborted_connects", (char*) &aborted_connects, SHOW_LONG},
+ {"Binlog_cache_disk_use", (char*) &binlog_cache_disk_use, SHOW_LONG},
+ {"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG},
{"Bytes_received", (char*) &bytes_received, SHOW_LONG},
{"Bytes_sent", (char*) &bytes_sent, SHOW_LONG},
{"Com_admin_commands", (char*) &com_other, SHOW_LONG},
@@ -5013,6 +5016,7 @@ static void mysql_init_variables(void)
filesort_merge_passes= select_range_check_count= select_range_count= 0;
select_scan_count= select_full_range_join_count= select_full_join_count= 0;
specialflag= opened_tables= created_tmp_tables= created_tmp_disk_tables= 0;
+ binlog_cache_use= binlog_cache_disk_use= 0;
max_used_connections= slow_launch_threads = 0;
max_sort_char= 0;
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;