===== sql/log.cc 1.220 vs edited ===== --- 1.220/sql/log.cc 2007-07-30 16:27:30 +01:00 +++ edited/sql/log.cc 2007-10-26 14:43:41 +01:00 @@ -35,6 +35,8 @@ MYSQL_LOG mysql_log, mysql_slow_log, mysql_bin_log; ulong sync_binlog_counter= 0; +ulong sync_relaylog_counter= 0; + static Muted_query_log_event invisible_commit; static bool test_if_number(const char *str, @@ -1444,6 +1446,20 @@ } +bool MYSQL_LOG::flush_and_sync_relay() +{ + int err=0, fd=log_file.file; + safe_mutex_assert_owner(&LOCK_log); + if (flush_io_cache(&log_file)) + return 1; + if (++sync_relaylog_counter >= sync_relaylog_period && sync_relaylog_period) + { + sync_relaylog_counter= 0; + err=my_sync(fd, MYF(MY_WME)); + } + return err; +} + bool MYSQL_LOG::appendv(const char* buf, uint len,...) { bool error= 0; @@ -1463,6 +1479,9 @@ } bytes_written += len; } while ((buf=va_arg(args,const char*)) && (len=va_arg(args,uint))); + if (flush_and_sync_relay()) + goto err; + DBUG_PRINT("info",("max_size: %lu",max_size)); if ((uint) my_b_append_tell(&log_file) > max_size) new_file(0); @@ -1577,6 +1596,7 @@ } return err; } + void MYSQL_LOG::start_union_events(THD *thd, query_id_t query_id_param) { ===== sql/mysql_priv.h 1.462 vs edited ===== --- 1.462/sql/mysql_priv.h 2007-10-18 23:39:52 +01:00 +++ edited/sql/mysql_priv.h 2007-10-26 14:43:40 +01:00 @@ -1299,6 +1299,7 @@ extern ulong back_log; extern ulong specialflag, current_pid; extern ulong expire_logs_days, sync_binlog_period, sync_binlog_counter; +extern ulong sync_relaylog_period, sync_relaylog_counter; extern ulong opt_tc_log_size, tc_log_max_pages_used, tc_log_page_size; extern ulong tc_log_page_waits; extern my_bool relay_log_purge, opt_innodb_safe_binlog, opt_innodb; ===== sql/mysqld.cc 1.628 vs edited ===== --- 1.628/sql/mysqld.cc 2007-10-12 10:30:45 +01:00 +++ edited/sql/mysqld.cc 2007-10-26 14:43:39 +01:00 @@ -441,7 +441,7 @@ */ ulong prepared_stmt_count=0; ulong thread_id=1L,current_pid; -ulong slow_launch_threads = 0, sync_binlog_period; +ulong slow_launch_threads = 0, sync_binlog_period, sync_relaylog_period; ulong expire_logs_days = 0; ulong rpl_recovery_rank=0; @@ -4843,7 +4843,8 @@ OPT_INNODB_ROLLBACK_ON_TIMEOUT, OPT_SECURE_FILE_PRIV, OPT_KEEP_FILES_ON_CREATE, - OPT_INNODB_ADAPTIVE_HASH_INDEX + OPT_INNODB_ADAPTIVE_HASH_INDEX, + OPT_SYNC_RELAY_LOG }; @@ -6186,6 +6187,11 @@ {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.", (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"sync-relay-log", OPT_SYNC_RELAY_LOG, + "Synchronously flush relay log to disk after every #th event. " + "Use 0 (default) to disable synchronous flushing.", + (gptr*) &sync_relaylog_period, (gptr*) &sync_relaylog_period, 0, GET_ULONG, + REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, {"table_cache", OPT_TABLE_CACHE, "The number of open tables for all threads.", (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, ===== sql/set_var.cc 1.191 vs edited ===== --- 1.191/sql/set_var.cc 2007-10-18 23:39:52 +01:00 +++ edited/sql/set_var.cc 2007-10-26 14:43:38 +01:00 @@ -398,6 +398,7 @@ &SV::table_type); #ifdef HAVE_REPLICATION sys_var_sync_binlog_period sys_sync_binlog_period("sync_binlog", &sync_binlog_period); +sys_var_sync_relaylog_period sys_sync_relaylog_period("sync_relay_log", &sync_relaylog_period); #endif sys_var_bool_ptr sys_sync_frm("sync_frm", &opt_sync_frm); sys_var_const_str sys_system_time_zone("system_time_zone", @@ -755,6 +756,7 @@ &sys_storage_engine, #ifdef HAVE_REPLICATION &sys_sync_binlog_period, + &sys_sync_relaylog_period, #endif &sys_sync_frm, &sys_system_time_zone, @@ -1079,6 +1081,7 @@ {sys_storage_engine.name, (char*) &sys_storage_engine, SHOW_SYS}, #ifdef HAVE_REPLICATION {sys_sync_binlog_period.name,(char*) &sys_sync_binlog_period, SHOW_SYS}, + {sys_sync_relaylog_period.name,(char*) &sys_sync_relaylog_period, SHOW_SYS}, #endif {sys_sync_frm.name, (char*) &sys_sync_frm, SHOW_SYS}, #ifdef HAVE_TZNAME @@ -2681,6 +2684,13 @@ sync_binlog_period= (ulong) var->save_result.ulonglong_value; return 0; } + +bool sys_var_sync_relaylog_period::update(THD *thd, set_var *var) +{ + sync_relaylog_period= (ulong) var->save_result.ulonglong_value; + return 0; +} + #endif /* HAVE_REPLICATION */ bool sys_var_rand_seed1::update(THD *thd, set_var *var) ===== sql/set_var.h 1.83 vs edited ===== --- 1.83/sql/set_var.h 2007-02-21 11:05:01 +00:00 +++ edited/sql/set_var.h 2007-10-26 14:43:42 +01:00 @@ -534,6 +534,15 @@ :sys_var_long_ptr(name_arg,value_ptr_arg) {} bool update(THD *thd, set_var *var); }; + +class sys_var_sync_relaylog_period :public sys_var_long_ptr +{ +public: + sys_var_sync_relaylog_period(const char *name_arg, ulong *value_ptr_arg) + :sys_var_long_ptr(name_arg,value_ptr_arg) {} + bool update(THD *thd, set_var *var); +}; + #endif class sys_var_rand_seed1 :public sys_var ===== sql/sql_class.h 1.345 vs edited ===== --- 1.345/sql/sql_class.h 2007-08-02 01:39:10 +01:00 +++ edited/sql/sql_class.h 2007-10-25 13:38:02 +01:00 @@ -329,6 +329,7 @@ int update_log_index(LOG_INFO* linfo, bool need_update_threads); void rotate_and_purge(uint flags); bool flush_and_sync(); + bool flush_and_sync_relay(); int purge_logs(const char *to_log, bool included, bool need_mutex, bool need_update_threads, ulonglong *decrease_log_space);