Read logical decoding lag from the spill counters
The same transaction decoded twice: at the 64MB default it spilled nothing, and with logical_decoding_work_mem at 64kB it recorded spill_txns 2, spill_count 613 and 40,311,936 spilled bytes against 40,327,788 decoded.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
Logical replication lag is usually chased through slot LSNs, which say how far behind the consumer is but not why. When a transaction is larger than the memory the decoder is allowed, PostgreSQL writes the reorder buffer to disk and reassembles it before sending anything. That cost is invisible in the LSN figures and visible in three counters almost nobody reads.
Meridian's CDC pipeline falls behind during nightly batch jobs and catches up by morning. The slot is active, the network is idle, and no query is slow.
Simple terms
When PostgreSQL streams changes to a logical consumer, it first has to reassemble each transaction in memory, because changes only become sendable once the transaction commits. There is a memory budget for that. A transaction bigger than the budget gets written out to disk and read back, which is slow, invisible in the usual lag numbers, and the real reason a nightly batch job puts your replication hours behind. PostgreSQL counts exactly how much it had to spill, and that counter is the one that tells you what to change.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other WAL & replication runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Fixes these errors
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.