diff options
author | unknown <guilhem@mysql.com> | 2004-06-10 15:56:13 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-06-10 15:56:13 +0200 |
commit | 7ece3c749152fd9a5df821398852a4cb02ec13a2 (patch) | |
tree | 9776f371549ba002dc5dde8ab3d942e3ec380a66 /sql/log.cc | |
parent | 7f4402201f87978960e206f97674bf30f1a414ae (diff) | |
download | mariadb-git-7ece3c749152fd9a5df821398852a4cb02ec13a2.tar.gz |
WL#1595 "Optionally fsync() the binlog after every statement":
New option --sync-binlog=x (and global settable variable) which will fsync the binlog
after every x-th disk write to it. That is, if in autocommit mode, after every x-th statement
written to the binlog; if using transactions, after every x-th transaction written to the binlog.
x==0 means no fsync. x==1 is the slowest.
There is no test added for this, I have just checked that it works as --sync-binlog=1 dramatically
slows down mysqld.
Made sync-frm a global settable variable.
sql/log.cc:
every sync_binlog_period-th disk binlog write, we fsync the binlog
sql/mysql_priv.h:
new option sync_binlog
sql/mysqld.cc:
new option sync_binlog
sql/set_var.cc:
Making sync-frm a settable global option.
New settable global option sync-binlog.
sql/set_var.h:
new global settable variable sync_binlog needs a specific ::update because it needs to take LOCK_log
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sql/log.cc b/sql/log.cc index e7a142230b1..47a6a4a9b4c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -31,6 +31,7 @@ #include <m_ctype.h> // For test_if_number MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; +ulong sync_binlog_counter= 0; static bool test_if_number(const char *str, long *res, bool allow_wildcards); @@ -1164,6 +1165,13 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command, } +inline bool sync_binlog(IO_CACHE *cache) +{ + return (sync_binlog_period && + (sync_binlog_period == ++sync_binlog_counter) && + (sync_binlog_counter= 0, my_sync(cache->file, MYF(MY_WME)))); +} + /* Write an event to the binary log */ @@ -1369,9 +1377,9 @@ COLLATION_CONNECTION=%lu,COLLATION_DATABASE=%lu,COLLATION_SERVER=%lu", if (file == &log_file) // we are writing to the real log (disk) { - if (flush_io_cache(file)) + if (flush_io_cache(file) || sync_binlog(file)) goto err; - + if (opt_using_transactions && !my_b_tell(&thd->transaction.trans_log)) { /* @@ -1529,7 +1537,8 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback) commit_or_rollback ? 6 : 8, TRUE); qinfo.set_log_pos(this); - if (qinfo.write(&log_file) || flush_io_cache(&log_file)) + if (qinfo.write(&log_file) || flush_io_cache(&log_file) || + sync_binlog(&log_file)) goto err; } if (cache->error) // Error on read |