Analyzing MySQL Binary Log Events with the infobin Tool
This article introduces the open‑source infobin utility for parsing MySQL binary logs, explains how it detects long‑running and large transactions, measures event generation speed, aggregates per‑table DML events, and demonstrates its usage with sample commands and output, offering a faster alternative to mysqlbinlog.
The author presents infobin , a C‑based command‑line tool that parses MySQL binary logs to extract useful operational metrics. The tool is not promoted commercially; it is shared as an example of how Event knowledge can be leveraged for custom analysis.
Main functions of infobin:
Detect long‑running (uncommitted) transactions by comparing the timestamps of QUERY_EVENT and the final XID_EVENT .
Identify large transactions by summing the size of all events between GTID_LOG_EVENT and XID_EVENT (or between QUERY_EVENT and XID_EVENT for compatibility).
Measure binary‑log event generation speed by splitting the log into pieces (parameter piece ) and calculating time differences between the first and last event of each piece.
Count DML events per table by scanning MAP_EVENT and subsequent row‑based events, aggregating sizes and frequencies for INSERT , UPDATE , and DELETE .
Typical command‑line usage:
./infobin mysql-bin.0000053100000015-t > log.logHelp output (truncated) shows the required arguments and optional flags:
USAGE: ./infobin binlogfile pieces bigtrxsize bigtrxtime [-t] [-force]Example workflow demonstrated in the article:
Flush the binary log and perform three transactions: delete 98,304 rows from table tti , insert one row into tti with a 20‑second sleep before commit, and insert one row into table tpp .
Run infobin on the generated binary log and inspect the resulting log.log file.
The output confirms the tool correctly identifies:
A large transaction (>500 KB) caused by the massive delete operation (≈ 800 KB).
A long‑running transaction lasting 31 seconds due to the intentional sleep.
Per‑table DML statistics: table tpp has one INSERT (40 bytes); table tti has one INSERT (48 bytes) and 109 DELETE events (≈ 888 KB).
The author concludes that once you understand MySQL Event structures, you can build custom parsers in any language, and that infobin is considerably faster than using mysqlbinlog combined with shell or Python scripts.
For deeper knowledge, the author recommends his book “深入理解 MySQL 主从原理 32 讲” and provides contact information (WeChat: gp_22389860) for further discussion.
Aikesheng Open Source Community
The Aikesheng Open Source Community provides stable, enterprise‑grade MySQL open‑source tools and services, releases a premium open‑source component each year (1024), and continuously operates and maintains them.
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.