diff options
author | Alfranio Correia <alfranio.correia@sun.com> | 2009-09-29 15:27:12 +0100 |
---|---|---|
committer | Alfranio Correia <alfranio.correia@sun.com> | 2009-09-29 15:27:12 +0100 |
commit | 4e0cb6dbb7da3a8e98f6050779206d65f3096f47 (patch) | |
tree | 843223e93a47492e606ba45437990affb3529d89 /sql/rpl_mi.cc | |
parent | 63278c561cd6b24a622cab9e2674dd272b24f061 (diff) | |
download | mariadb-git-4e0cb6dbb7da3a8e98f6050779206d65f3096f47.tar.gz |
BUG#35542 Add option to sync master and relay log to disk after every event
BUG#31665 sync_binlog should cause relay logs to be synchronized
NOTE: Backporting the patch to next-mr.
Add sync_relay_log option to server, this option works for relay log
the same as option sync_binlog for binlog. This option also synchronize
master info to disk when set to non-zero value.
Original patches from Sinisa and Mark, with some modifications
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r-- | sql/rpl_mi.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index 5e46837e948..1bca44ac613 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -342,6 +342,7 @@ int flush_master_info(Master_info* mi, bool flush_relay_log_cache) { IO_CACHE* file = &mi->file; char lbuf[22]; + int err= 0; DBUG_ENTER("flush_master_info"); DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos)); @@ -358,9 +359,17 @@ int flush_master_info(Master_info* mi, bool flush_relay_log_cache) When we come to this place in code, relay log may or not be initialized; the caller is responsible for setting 'flush_relay_log_cache' accordingly. */ - if (flush_relay_log_cache && - flush_io_cache(mi->rli.relay_log.get_log_file())) - DBUG_RETURN(2); + if (flush_relay_log_cache) + { + IO_CACHE *log_file= mi->rli.relay_log.get_log_file(); + if (flush_io_cache(log_file)) + DBUG_RETURN(2); + + /* Sync to disk if --sync-relay-log is set */ + if (sync_relaylog_period && + my_sync(log_file->file, MY_WME)) + DBUG_RETURN(2); + } /* We flushed the relay log BEFORE the master.info file, because if we crash @@ -388,7 +397,10 @@ int flush_master_info(Master_info* mi, bool flush_relay_log_cache) mi->password, mi->port, mi->connect_retry, (int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert, mi->ssl_cipher, mi->ssl_key, mi->ssl_verify_server_cert); - DBUG_RETURN(-flush_io_cache(file)); + err= flush_io_cache(file); + if (sync_relaylog_period && !err) + err= my_sync(mi->fd, MYF(MY_WME)); + DBUG_RETURN(-err); } |