Bug #118040 Reduce Redundant init_and_set_log_file_name Calls

Submitted: 23 Apr 2025 11:35 Modified: 23 Apr 2025 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 2025 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 2025 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 2025 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 2025 12:59] MySQL Verification Team
Hello Alex Xing,

Thank you for the report and contribution.

regards,
umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.044 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.