Bug #40732 Binarylog is appended an odd numeric extension exceed a limit of signed long
Submitted: 14 Nov 2008 9:22 Modified: 14 Jul 2009 11:23
Reporter: Meiji KIMURA Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Replication Severity:S3 (Non-critical)
Version:5.0 OS:Any
Assigned to: Luis Soares CPU Architecture:Any

[14 Nov 2008 9:22] Meiji KIMURA
Description:
A number of binary log's file name is ever-increasing. It become 1000000 after 999999.
There is no documentation about this, so I looked into source codes. (Windows 32-bit) A
filename is created in find_uniq_filename() in log.cc like this.

sprintf(end,"%06ld",max_found+1);

I supposed that an upper limit of a sequential number is 4294967295 because of max_found
is unsigned long. But it is created "%06ld", so a sequential number is displayed as signed
long like these,

:
bin-log.2147483645
bin-log.2147483646
bin-log.2147483647
bin-log.-2147483648
bin-log.-2147483647
bin-log.-2147483646
:

This specification looks very strange. It should become 2147483648 after 2147483647 like this.

:
bin-log.2147483645
bin-log.2147483646
bin-log.2147483647
bin-log.2147483648
bin-log.2147483649
bin-log.2147483650
:

How to repeat:
Refer to this link;
http://bugs.mysql.com/bug.php?id=40611

Suggested fix:
Modify 'sprintf(end,"%06ld",max_found+1);' to 'sprintf(end,"%06lu",max_found+1);'.
[15 Jan 2009 13:04] Susanne Ebrecht
Verified as described in actual bzr trees:

./sql/log.cc

5.1:
line 1818: sprintf(end,"%06ld",max_found+1);

5.0:
line 1400: sprintf(end,"%06ld",max_found+1);

6.0:
line 3049: sprintf(end,"%06ld",max_found+1);

Lowest supported version where it occurs is 5.0.
[14 Jul 2009 11:23] Luis Soares
Setting as CAN'T REPEAT after fix for BUG#40611.

See also BUG#46166.