What Is MySQL’s Maximum Binlog Sequence Number and What Happens When It’s Reached?
This article investigates MySQL binlog numbering, discovers that the maximum sequence number is 2^31‑1 (2147483647), shows through three experiments how MySQL behaves when approaching or hitting this limit, and explains the resulting warnings and server shutdown.
Each MySQL binlog file is numbered, originally three digits and now up to six, starting from 000001. MySQL scans existing binlog files at startup, finds the highest number, and creates the next file.
Test 1 – What happens after 999999?
We stopped mysqld, manually created a binlog named mysql-bin.999999, and restarted MySQL. The server started normally, and show master status showed that the sequence continued beyond 999999 instead of resetting.
Source‑code investigation
In sql/binlog.cc the code checks: if (max_found == MAX_LOG_UNIQUE_FN_EXT) The macro is defined as: #define MAX_LOG_UNIQUE_FN_EXT 0x7FFFFFFF Converted to decimal, this value is 2^31‑1 = 2147483647. When the maximum is reached, MySQL aborts.
Test 2 – Approaching the limit
We created a binlog mysql-bin.2147483640, added it to mysql-bin.index, ensured mysql-bin.000001 existed, and restarted MySQL. After issuing FLUSH LOGS, the error log recorded a warning, and after the next rotation the server exited.
Test 3 – Can the number wrap around?
We repeated the experiment with mysql-bin.2147483646 while removing lower‑numbered files. MySQL still exited when the sequence reached the maximum; no wrap‑around occurred.
Conclusion
The maximum binlog sequence number is 2147483647. When the number exceeds 2147482647 (within 1 000 of the limit), MySQL writes warnings to the error log. Reaching the maximum causes the mysqld process to terminate, and a large number of binlog files degrades startup and log‑rotation performance.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
