Bug #66079 unnecessary calling trx_sys_update_mysql_binlog_offset when sql_log_bin=0
Submitted: 30 Jul 2012 2:59 Modified: 30 Jul 2012 12:36
Reporter: xiaobin lin (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S5 (Performance)
Version:5.5+ OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution, sql_log_bin, trx_sys_update_mysql_binlog_offset

[30 Jul 2012 2:59] xiaobin lin
Description:
As we know trx_sys_update_mysql_binlog_offset is used for update the latest MySQL binlog name and offset info in trx sys header if MySQL binlogging is on.

But When run the following commands, 
set sql_log_bin=1;
insert into ... (1)
set sql_log_bin=0;
insert into ... (2)

When the second "insert" statement is executing, we can see the code in (trx0trx.c:877) is exected, which should be unnecessary.

The direct reason is that trx->mysql_log_file_name is not NULL here, but the current binlog file name.
The root reason is that when mysql_bin_log_commit_pos(sql/log.cc) is called, the trx->mysql_log_file_name is set to current binlog filename.

How to repeat:
Read code and as above

Suggested fix:

As trx->mysql_log_offset of a normal binlog event can not be 0, we can use this value to decide.
Simple patch as:

diff a/storage/innobase/trx/trx0trx.c  b/storage/innobase/trx/trx0trx.c
874c874
<       if (trx->mysql_log_file_name
---
>       if (trx->mysql_log_offset && trx->mysql_log_file_name
[30 Jul 2012 12:36] Valeriy Kravchuk
Thank you for the problem report and patch contributed.