Position affected by MySQL:Innodb:innodb_flush_log_at_trx_commit parameter
Source code 5.7.22
Impact phase: flush phase of MYSQL_BIN_LOG::ordered_commit
I. the function of influence
Innobase_flush_logs function, the function is as follows, in fact, the comments are also very clear. The binlog_group_flush parameter is 1.
/ * Flush InnoDB redo logs to the file system.@param [in] hton InnoDB handlerton@param [in] binlog_group_flush true if we got invoked by binloggroup commit during flush stage, false in other cases.@return false * / staticboolinnobase_flush_logs (handlerton* hton, bool binlog_group_flush) {DBUG_ENTER ("innobase_flush_logs"); DBUG_ASSERT (hton = = innodb_hton_ptr) If (srv_read_only_mode) {DBUG_RETURN (false);} / * If! binlog_group_flush, we got invoked by FLUSH LOGS or similar. Else, we got invoked by binlog group commit during flush stage. * / if (binlog_group_flush & & thd_flush_log_at_trx_commit (NULL) = = 0) {/ * innodb_flush_log_at_trx_commit=0 (write and sync once per second). Do not flush the redo log during binlog group commit. * / DBUG_RETURN (false);} / * Flush the redo log buffer to the redo log file. Sync it to disc if we are in FLUSH LOGS, or if innodb_flush_log_at_trx_commit=1 (write and sync at each commit). * / log_buffer_flush_to_disk (! binlog_group_flush | | thd_flush_log_at_trx_commit (NULL) = = 1); DBUG_RETURN (false);} II. Possible combinations
The innodb_flush_log_at_trx_commit parameter is 0
Binlog_group_flush & & thd_flush_log_at_trx_commit (NULL) = = 0 condition holds, so directly return, then in this case the log_buffer_flush_to_disk function will not be called, so will not do redo flushing disk. Relies on master threads.
The innodb_flush_log_at_trx_commit parameter is 1
! binlog_group_flush | | thd_flush_log_at_trx_commit (NULL) = = 1 is True if returned as 1, so log_buffer_flush_to_disk (True) is called, so you need to do redo flushing and sync.
The innodb_flush_log_at_trx_commit parameter is 2
! binlog_group_flush | | thd_flush_log_at_trx_commit (NULL) = = 1 returns 0 as Flase, so call
Log_buffer_flush_to_disk (Flase), so you need to do redo flushing instead of sync. Rely on OS's flushing mechanism.
Call stack frame # 0 innobase_flush_logs (hton=0x2e9edd0, binlog_group_flush=true) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/innobase/handler/ha_innodb.cc:4385#1 0x0000000000f65893 in flush_handlerton (thd=0x0, plugin=0x7ffff01558e8, arg=0x7ffff0155944) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:2606#2 0x00000000015d7716 in plugin_foreach_with_mask (thd=0x0, func=0xf65835, type=1, state_mask=4294967287 Arg=0x7ffff0155944) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_plugin.cc:2318#3 0x0000000000f658ef in ha_flush_logs (db_type=0x0, binlog_group_flush=true) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:2617#4 0x000000000185733d in MYSQL_BIN_LOG::process_flush_stage_queue (this=0x2e01c80, total_bytes_var=0x7ffff0155a88, rotate_var=0x7ffff0155a87 Out_queue_var=0x7ffff0155a78) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:8541#5 0x000000000185899f in MYSQL_BIN_LOG::ordered_commit (this=0x2e01c80, thd=0x7fff2c000b70, all=false, skip_commit=false) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:9189#6 0x000000000185700c in MYSQL_BIN_LOG::commit (this=0x2e01c80, thd=0x7fff2c000b70 All=false) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/binlog.cc:8440#7 0x0000000000f63df8 in ha_commit_trans (thd=0x7fff2c000b70, all=false) Ignore_global_read_lock=false) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/handler.cc:1818#8 0x00000000016b3e5d in trans_commit_stmt (thd=0x7fff2c000b70) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/transaction.cc:458#9 0x00000000015ac677 in mysql_execute_command (thd=0x7fff2c000b70 First_level=true) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:5239#10 0x00000000015adcd6 in mysql_parse (thd=0x7fff2c000b70, parser_state=0x7ffff0158600) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:5836#11 0x00000000015a1b95 in dispatch_command (thd=0x7fff2c000b70, com_data=0x7ffff0158d70 Command=COM_QUERY) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:1447#12 0x00000000015a09c6 in do_command (thd=0x7fff2c000b70) at / root/mysql5.7.14/percona-server-5.7.14-7/sql/sql_parse.cc:1010#13 0x00000000016e29d0 in handle_connection (arg=0x3803f30) at / root/mysql5.7.14/percona-server-5.7.14-7 up sqlbank Per_thread.cc:312#14 0x0000000001d7b4b0 in pfs_spawn_thread (arg=0x3810b80) at / root/mysql5.7.14/percona-server-5.7.14-7/storage/perfschema/pfs.cc:2188#15 0x0000003f74807aa1 in start_thread () from / lib64/libpthread.so.0#16 0x0000003f740e8bcd in clone () from / lib64/libc.so.6
Author Wechat: gaopp_22389860