innodb_flush_log_at_timeout

innodb_flush_log_at_timeout


文档解释

 innodb_flush_log_at_timeout

Property    Value
System Variable innodb_flush_log_at_timeout
Scope   Global
Dynamic Yes
Type    integer
Default Value   1
Minimum Value   1
Maximum Value   2700

Write and flush the logs every N seconds. innodb_flush_log_at_timeout allows the timeout period between flushes to be increased in order to reduce flushing and avoid impacting performance of binary log group commit. The default setting for innodb_flush_log_at_timeout is once per second.

master线程刷写日志的频率。可以增大此参数设置来减少刷写次数,避免对binlog group commit带来影响。默认值是1.

代码

/********************************************************************//**
The master thread is tasked to ensure that flush of log file happens
once every second in the background. This is to ensure that not more
than one second of trxs are lost in case of crash when
innodb_flush_logs_at_trx_commit != 1 */
static
void
srv_sync_log_buffer_in_background(void)
/*===================================*/
{
    time_t  current_time = time(NULL);

    srv_main_thread_op_info = "flushing log";
    if (difftime(current_time, srv_last_log_flush_time)
        >= srv_flush_log_at_timeout) {
        log_buffer_sync_in_background(true);
        srv_last_log_flush_time = current_time;
        srv_log_writes_and_flush++;
    }
}

如果上一次刷新时间跟现在的差超过了srv_last_log_flush_time的值,则进行log_buffer_sync_in_background刷新操作

/****************************************************************//**
This functions writes the log buffer to the log file and if 'flush'
is set it forces a flush of the log file as well. This is meant to be
called from background master thread only as it does not wait for
the write (+ possible flush) to finish. */
void
log_buffer_sync_in_background(
/*==========================*/
    bool    flush)  /*!< in: flush the logs to disk */
{
    lsn_t   lsn;

    log_mutex_enter();

    lsn = log_sys->lsn;

    if (flush
        && log_sys->n_pending_flushes > 0
        && log_sys->current_flush_lsn >= lsn) {
        /* The write + flush will write enough */
        log_mutex_exit();
        return;
    }

    log_mutex_exit();

    log_write_up_to(lsn, flush);
}

当然关于master线程更多的逻辑不在此介绍了。然而还是觉得,如果在参数innodb_flush_log_at_trx_commit=1的情况下,还有必要周期性的进行log_buffer_sync吗?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这些是MySQL数据库的超时设置,含义如下: - `connect_timeout`: 连接MySQL服务器的超时时间,单位是秒。 - `delayed_insert_timeout`: 对于使用`INSERT DELAYED`语句插入的数据,如果没有被立即处理,将在该时间后超时。超时后,数据将被插入表中。 - `have_statement_timeout`: 是否启用语句执行超时。如果启用,当执行一个查询或其他语句时,如果超过指定时间仍未执行完毕,将自动中断该语句的执行。 - `innodb_flush_log_at_timeout`: InnoDB存储引擎将日志缓冲区中的数据写入磁盘的超时时间,单位是秒。 - `innodb_lock_wait_timeout`: InnoDB存储引擎等待获取锁的超时时间,单位是秒。 - `innodb_rollback_on_timeout`: InnoDB存储引擎在等待锁超时时是否自动回滚事务。 - `interactive_timeout`: 连接空闲状态下的超时时间,单位是秒。如果在此时间内没有任何活动,则MySQL服务器将关闭连接。 - `lock_wait_timeout`: 获取锁的超时时间,单位是秒。 - `net_read_timeout`: 从MySQL服务器读取数据的超时时间,单位是秒。 - `net_write_timeout`: 向MySQL服务器写入数据的超时时间,单位是秒。 - `rpl_stop_slave_timeout`: 停止从服务器的超时时间,单位是秒。 - `slave_net_timeout`: 从服务器连接的超时时间,单位是秒。 - `wait_timeout`: 非交互式连接的超时时间,单位是秒。如果在此时间内没有任何活动,则MySQL服务器将关闭连接。 这些超时设置用于控制MySQL服务器的行为,在一定程度上可以提高MySQL服务器的性能和安全性。可以根据实际需求灵活配置这些超时选项。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值