Bug #118040 Reduce Redundant init_and_set_log_file_name Calls
Submitted: 23 Apr 11:35 Modified: 23 Apr 12:59
Reporter: alex xing (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Replication Severity:S5 (Performance)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[23 Apr 11:35] alex xing
Description:
When mysqld starts or executes RESET MASTER, the function init_and_set_log_file_name() is called twice:

First in MYSQL_BIN_LOG::open_binlog()

Then again in MYSQL_BIN_LOG::open()

The second call is unnecessary, and since generate_new_name() scans all binlog files, it introduces extra overhead.

Current Call Flow:
MYSQL_BIN_LOG::open_binlog
|--> init_and_set_log_file_name
|  |-->  generate_new_name
|--> MYSQL_BIN_LOG::open
|  |--> init_and_set_log_file_name
|  |  |--> generate_new_name

How to repeat:
just read the code 

Suggested fix:
optimize as the below patch
[23 Apr 11:37] alex xing
a simple patch to describe the optimization

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: binlog_open_optimzie.patch (application/octet-stream, text), 472 bytes.

[23 Apr 11:38] alex xing
a simple patch to describe the optimization

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: binlog_open_optimize.patch (application/octet-stream, text), 472 bytes.

[23 Apr 12:59] MySQL Verification Team
Hello Alex Xing,

Thank you for the report and contribution.

regards,
umesh