Bug #73741 Add three status variables to report binlog generation, dump & relay
Description:
Add some status variables to report the binlog activity, such as the following (binlog_total_bytes)
mysql> update t_item set col2=col2-1 where col1=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show status like 'binlog%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 1 |
| Binlog_stmt_cache_disk_use | 0 |
| Binlog_stmt_cache_use | 0 |
| Binlog_total_bytes | 191 |
+----------------------------+-------+
5 rows in set (0.00 sec)
mysql> update t_item set col2=col2-1 where col1=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show status like 'binlog%';
+----------------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| Binlog_cache_disk_use | 0 |
| Binlog_cache_use | 2 |
| Binlog_stmt_cache_disk_use | 0 |
| Binlog_stmt_cache_use | 0 |
| Binlog_total_bytes | 382 |
+----------------------------+-------+
5 rows in set (0.00 sec)
So we will be able to get the binlog generated during a time period.
The code for binlog dump and binlog relay is not finished.
How to repeat:
N/A
Suggested fix:
diff -rc --exclude='*.orig' --exclude=sql_yacc.h --exclude=sql_yacc.cc mysql-5.6.20/sql/binlog.cc mysql-5.6.20-patched/sql/binlog.cc
*** mysql-5.6.20/sql/binlog.cc 2014-07-18 23:48:39.000000000 +0800
--- mysql-5.6.20-patched/sql/binlog.cc 2014-08-27 19:03:02.000000000 +0800
***************
*** 38,43 ****
--- 38,45 ----
using std::string;
using std::list;
+ extern ulonglong binlog_total_bytes;
+
#define FLAGSTR(V,F) ((V)&(F)?#F" ":"")
/**
***************
*** 6931,6936 ****
--- 6933,6943 ----
flush_error= result.first;
}
+ if (total_bytes > 0)
+ {
+ binlog_total_bytes += total_bytes;
+ }
+
if (need_LOCK_log)
mysql_mutex_unlock(&LOCK_log);
diff -rc --exclude='*.orig' --exclude=sql_yacc.h --exclude=sql_yacc.cc mysql-5.6.20/sql/mysqld.cc mysql-5.6.20-patched/sql/mysqld.cc
*** mysql-5.6.20/sql/mysqld.cc 2014-07-18 23:48:39.000000000 +0800
--- mysql-5.6.20-patched/sql/mysqld.cc 2014-08-27 19:06:56.000000000 +0800
***************
*** 547,552 ****
--- 547,553 ----
bool thread_cache_size_specified= false;
bool host_cache_size_specified= false;
bool table_definition_cache_specified= false;
+ ulonglong binlog_total_bytes=0;
Error_log_throttle err_log_throttle(Log_throttle::LOG_THROTTLE_WINDOW_SIZE,
sql_print_error,
***************
*** 7887,7892 ****
--- 7888,7894 ----
{"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG},
{"Binlog_stmt_cache_disk_use",(char*) &binlog_stmt_cache_disk_use, SHOW_LONG},
{"Binlog_stmt_cache_use", (char*) &binlog_stmt_cache_use, SHOW_LONG},
+ {"Binlog_total_bytes", (char*) &binlog_total_bytes, SHOW_LONGLONG},
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
{"Com", (char*) com_status_vars, SHOW_ARRAY},
***************
*** 8195,8200 ****
--- 8197,8203 ----
delayed_insert_errors= thread_created= 0;
specialflag= 0;
binlog_cache_use= binlog_cache_disk_use= 0;
+ binlog_total_bytes= 0;
max_used_connections= slow_launch_threads = 0;
mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0;
prepared_stmt_count= 0;
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Add some status variables to report the binlog activity, such as the following (binlog_total_bytes) mysql> update t_item set col2=col2-1 where col1=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> show status like 'binlog%'; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 1 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Binlog_total_bytes | 191 | +----------------------------+-------+ 5 rows in set (0.00 sec) mysql> update t_item set col2=col2-1 where col1=1; Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> show status like 'binlog%'; +----------------------------+-------+ | Variable_name | Value | +----------------------------+-------+ | Binlog_cache_disk_use | 0 | | Binlog_cache_use | 2 | | Binlog_stmt_cache_disk_use | 0 | | Binlog_stmt_cache_use | 0 | | Binlog_total_bytes | 382 | +----------------------------+-------+ 5 rows in set (0.00 sec) So we will be able to get the binlog generated during a time period. The code for binlog dump and binlog relay is not finished. How to repeat: N/A Suggested fix: diff -rc --exclude='*.orig' --exclude=sql_yacc.h --exclude=sql_yacc.cc mysql-5.6.20/sql/binlog.cc mysql-5.6.20-patched/sql/binlog.cc *** mysql-5.6.20/sql/binlog.cc 2014-07-18 23:48:39.000000000 +0800 --- mysql-5.6.20-patched/sql/binlog.cc 2014-08-27 19:03:02.000000000 +0800 *************** *** 38,43 **** --- 38,45 ---- using std::string; using std::list; + extern ulonglong binlog_total_bytes; + #define FLAGSTR(V,F) ((V)&(F)?#F" ":"") /** *************** *** 6931,6936 **** --- 6933,6943 ---- flush_error= result.first; } + if (total_bytes > 0) + { + binlog_total_bytes += total_bytes; + } + if (need_LOCK_log) mysql_mutex_unlock(&LOCK_log); diff -rc --exclude='*.orig' --exclude=sql_yacc.h --exclude=sql_yacc.cc mysql-5.6.20/sql/mysqld.cc mysql-5.6.20-patched/sql/mysqld.cc *** mysql-5.6.20/sql/mysqld.cc 2014-07-18 23:48:39.000000000 +0800 --- mysql-5.6.20-patched/sql/mysqld.cc 2014-08-27 19:06:56.000000000 +0800 *************** *** 547,552 **** --- 547,553 ---- bool thread_cache_size_specified= false; bool host_cache_size_specified= false; bool table_definition_cache_specified= false; + ulonglong binlog_total_bytes=0; Error_log_throttle err_log_throttle(Log_throttle::LOG_THROTTLE_WINDOW_SIZE, sql_print_error, *************** *** 7887,7892 **** --- 7888,7894 ---- {"Binlog_cache_use", (char*) &binlog_cache_use, SHOW_LONG}, {"Binlog_stmt_cache_disk_use",(char*) &binlog_stmt_cache_disk_use, SHOW_LONG}, {"Binlog_stmt_cache_use", (char*) &binlog_stmt_cache_use, SHOW_LONG}, + {"Binlog_total_bytes", (char*) &binlog_total_bytes, SHOW_LONGLONG}, {"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS}, {"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS}, {"Com", (char*) com_status_vars, SHOW_ARRAY}, *************** *** 8195,8200 **** --- 8197,8203 ---- delayed_insert_errors= thread_created= 0; specialflag= 0; binlog_cache_use= binlog_cache_disk_use= 0; + binlog_total_bytes= 0; max_used_connections= slow_launch_threads = 0; mysqld_user= mysqld_chroot= opt_init_file= opt_bin_logname = 0; prepared_stmt_count= 0;