You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Self-hosted PostgreSQL log tail: events written after the last read and before a log rotation are never collected #4699
Found while tracing a flaky test, PgLogEventsLivePostgresTests.TheSelfHostedCollector_ReadsTheTargetsOwnLog_EndToEnd (CI run 36500483761, 2026-09-29 00:02Z).
What happens
PgServerLogTail.TailCteSql reads the last 4 MB of the newest stderr log file only (ORDER BY modification DESC LIMIT 1). After PostgreSQL rotates its log, the next read looks only at the new file. Anything written to the old file after the previous read is never read. That can be up to one collection interval of lock waits, errors, deadlocks and plans.
When
At every rotation. By default (log_rotation_age = 1d) that is daily at midnight in log_timezone.
Also at every log_rotation_size rotation, which can be often on a busy server.
The type header already documents the gap between two windows when the log grows faster than the window. It doesn't cover this one. The managed route (RdsLogSource) keeps a resume marker and isn't affected.
How the test showed it
The workflow's workload step wrote a lock wait at 23:59:33Z.
PostgreSQL rotated its log at 00:00:00Z.
The test read at 00:02:05Z and saw only the new file, so its LockWait assertion failed.
On a local rig, running pg_rotate_logfile() between the workload and the read reproduces the failure every time.
The test is being fixed on its own: it will drive its own events, so it no longer depends on the workflow step. This issue is the product gap, which that fix does not change.
Possible directions (need a design call)
When the newest file has changed since the last read, also read the previous file's tail from where the last read ended.
Or keep a per-target resume marker (file name and offset), as the RDS route does.
Activity
Fix the resume CTE's newline search and add the live rotation pins (#…
Update the binary-twin byte pin for the resume newline search (#4699)
Resume the csvlog and jsonlog log tails from a per-format marker (#4699)
Consume the log-tail resume row in pg_deadlocks and pg_plan_capture (#…
The self-hosted log-events live test drives its own events, so a log …
Restore the csvlog and jsonlog resume markers that the previous push …
Consume the resume row on the plan-capture csvlog route and pin per-r…
Bind the log resume parameters in the log-events live tests (#4699)
Pin the log row cap and rotation edge cases against live targets (#4699)
Bring the tailer byte pin up to the newest-first capped match arm (#4699
Self-hosted PostgreSQL log tail: resume from a per-consumer marker so…
erikdarlingdata commentedon Sep 29, 2026
Closed by the watcher: delivered in PR #4704, merged to dev.