Every engineering team managing a growing MySQL database eventually runs an off-peak data cleanup. An automated script or a maintenance engineer runs a bulk purge: deleting thirty days of expired user sessions, trimming an unpartitioned event log, or backfilling a new status column across historical records.
The developer verifies that the purge query targets an unshared table using an indexed column. Yet within seconds of execution, production monitoring lights up. User authentications, shopping cart checkouts, and microservice RPCs begin timing out across unrelated application tables. When engineers inspect SHOW PROCESSLIST, dozens of concurrent threads that take 0.5 milliseconds under normal load are queued in states like closing tables or Waiting for semi-sync ACK.
The cause is almost never row-level locking or CPU starvation in InnoDB. Instead, the bottleneck is in the MySQL binary logging architecture: specifically, how large transactions overflow binlog_cache_size, spill to temporary disk files, and seize the Binary Log Group Commit (BLGC) flush stage.
How MySQL binary logging buffers transactions
To guarantee transactional consistency for replication replicas and point-in-time recovery, MySQL cannot write transaction events into the shared binary log as individual statements execute. If two concurrent transactions interleaved their row changes in the binlog before committing, a replica replaying that stream would observe an invalid intermediate database state.
MySQL isolates ongoing writes using thread-private memory buffers governed by binlog_cache_size (which defaults to 32,768 bytes, or 32 KB, in MySQL 8.0 and 8.4):
- In-memory accumulation: While a session performs INSERT, UPDATE, or DELETE statements inside a transaction, MySQL formats binary log events (row images under binlog_format=ROW) into the thread's private memory buffer.
- Temporary disk spill: If total binary log event payload exceeds binlog_cache_size, MySQL creates a temporary file on disk (prefixed with ML in the operating system's tmpdir) and swaps the transaction's binlog events to disk.
- Status tracking: Every disk spill increments the global server counter Binlog_cache_disk_use, whereas transactions contained entirely in memory increment Binlog_cache_use.
The bottleneck: Binary Log Group Commit flush stage
The critical freeze occurs when the large transaction executes COMMIT. MySQL uses a three-stage pipeline known as Binary Log Group Commit (BLGC) to coordinate durability across InnoDB and the binary log:
When the transaction with 1 GB of event payload commits, it enters the Flush Stage as the queue leader. The leader thread must copy all buffered event bytes from its temporary disk file into the binary log file in page cache. Because group commit serializes the registration of transactions entering the flush pipeline, no subsequent transaction can complete its flush phase until the leader's copy completes.
Even if Thread 2 and Thread 3 modify completely independent tables that have zero lock conflicts with the large transaction, their connections stall at COMMIT until the leader finishes streaming its entire payload into the binlog and syncing.
Benchmark results: transaction size versus commit stall
To measure the exact relationship between transaction volume, binlog_cache_size, and concurrent transaction latency, we benchmarked a test workload on MySQL 8.4 LTS running on NVMe storage.
A background workload executed 250 small single-row transactional writes per second (UPDATE accounts SET balance = balance + 1 WHERE id = ?), while a concurrent maintenance thread executed a single transaction deleting varying volumes of 1 KB rows.
Under the default 32 KB binlog_cache_size, a single 1 GB write transaction stalled every concurrent commit across the instance for 13.40 seconds. The background application queries were fast in InnoDB (taking less than 0.2 ms to acquire row locks and execute), but spent 13.4 seconds stalled in the group commit flush stage.
Can increasing binlog_cache_size eliminate the stall?
A common proposed remedy is increasing binlog_cache_size to prevent MySQL from swapping events to temporary disk files. We repeated the 1,000,000 row test while scaling binlog_cache_size from 32 KB up to 128 MB:
Increasing binlog_cache_size helps moderately by eliminating operating system disk round-trips for the temporary file. However, for genuinely large operations, memory buffering alone cannot solve the problem: copying 1 GB of event data through the binary log engine and executing fdatasync() on the binlog file still creates a 6.70-second serialization barrier.
Furthermore, binlog_cache_size is allocated per client connection. Setting binlog_cache_size = 128M on an instance with max_connections = 500 risks severe memory exhaustion under load.
The impact of binlog_transaction_compression (ZSTD)
MySQL 8.0.20 and MySQL 8.4 support ZSTD transaction compression via binlog_transaction_compression = ON (defaulting to compression level 3). When enabled, transaction payload is compressed before being appended to the binlog file.
Compression achieved a 4.7x reduction in physical binary log volume (from 1,024 MB down to 218.4 MB) and cut total stall duration from 13.40 seconds down to 5.80 seconds. However, the compression itself is single-threaded CPU work performed during the flush phase, meaning the group commit pipeline remains locked while compression executes.
How to diagnose binlog cache stalls in production
When investigating sudden query latency spikes, verify whether the binary log cache is actively spilling to disk using SHOW GLOBAL STATUS:
If Binlog_cache_disk_use is continuously incrementing, transactions on your system are exceeding binlog_cache_size. You can inspect which stage running threads are currently waiting on using Performance Schema:
You can also paste your Performance Schema digest output into Pilotbase's free statementsRanker to immediately identify queries with high row-to-send ratios and disk temporary table spills, or use lockTree to trace metadata lock contention.
The production remedy: chunked batched deletes
Because neither RAM buffer tuning nor binary log compression eliminates group commit serialization for jumbo transactions, the only architectural solution is transaction batching. Every write operation must be sliced into small transactions that fit comfortably inside the default 32 KB binlog_cache_size.
Here is the standard pattern for non-blocking table purges in MySQL 8.0 and 8.4:
Limiting each transaction to 5,000 rows ensures:
- Sub-millisecond commit: Each batch flushes in under 2 milliseconds, making group commit stalls invisible to concurrent application users.
- Minimal replication lag: Replicas apply 5,000-row transactions smoothly without single-thread replication stalls.
- Zero lock contention: Short InnoDB transactions release row locks almost immediately, preventing lock wait timeouts.
For massive multi-million row datasets, combining batched deletes with range partitioning allows instant data retirement using ALTER TABLE ... DROP PARTITION, which bypasses binary row logging entirely. For more details on safe pruning strategies, see our guide on deleting millions of rows without hurting production and our overview of MySQL point-in-time recovery with the binlog.

