Bug #70428 function find_uniq_filename can be optimized
| Submitted: | 26 Sep 2013 3:40 | Modified: | 30 Sep 2013 3:57 |
|---|---|---|---|
| Reporter: | zhai weixiang (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: Logging | Severity: | S3 (Non-critical) |
| Version: | 5.6, 5.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[30 Sep 2013 3:57]
MySQL Verification Team
Hello Zhai, Thank you for the bug report. Thanks, Umesh
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.038 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.
Description: In function find_uniq_filename, the binlog dir was always scaned to find the biggest unique number. If there are too many files in the dir, this scan may be Inefficient (must hold LOCK_log while rotate the binlog file). Since Variable log_bin_basename is read only . Actually I think we only need to scan the dir only once (for example , after the instance was started, or some operation such as purge binlog/reset master, etc...) and store the biggest number. This number can be added when binlog rotate is needed. We only need to check if the new filename was existed in the binlog dir. related trace: MYSQL_BIN_LOG::new_file_impl -> MYSQL_LOG::generate_new_name -> find_uniq_filename() quoted code from find_uniq_filename() file_info= dir_info->dir_entry; for (i= dir_info->number_off_files ; i-- ; file_info++) { if (memcmp(file_info->name, start, length) == 0 && test_if_number(file_info->name+length, &number,0)) { set_if_bigger(max_found,(ulong) number); } } How to repeat: read related code. Suggested fix: optimize it