Skip to content

Log events and deadlocks drop every line under a log_line_prefix with fields between the zone and the pid ('%m %u@%d [%p] '); plan capture accepts that shape since #4016 #4041

Description

@erikdarlingdata

Found while working #4014.

What

PgLogEntryAssembler.s_prefixLine's space family is (?<zone>[^ \n]+) \[(?<pid>\d+)\]: the pid bracket must come right after the zone. Under a log_line_prefix that renders fields between them, for example '%m %u@%d [%p] ', which gives ... UTC app@db [5555] ERROR: ..., no line matches. It fails the space family, and the managed family needs a colon after the zone.

Every log family that reads through the assembler therefore stores nothing on such a target:

  • pg_log_events: every family is dropped.
  • pg_deadlocks: both routes. PgDeadlockLogParser.FromReport goes through the assembler, and the deadlock patterns also demand the bracket after the zone.

Plan capture is the exception. Its own pattern accepts this shape since #4016 ([^ \[\n]+ [^\[\n]*\[\d+\]).

A test written for #4014, AReportUnderACustomPrefixWithFieldsBeforeThePid_StillReads, failed even with the deadlock pattern widened, because the assembler refused the candidate. It was taken out of #4014 rather than fixed there, for the reason below.

Impact

Unmeasured in the field. The common prefixes aren't affected:

  • PostgreSQL's default '%m [%p] ';
  • pgBadger's '%t [%p]: user=%u,db=%d,...';
  • Cloud SQL's '%m [%p]: [%l-1] db=%d,user=%u ';
  • the managed default '%t:%r:%u@%d:[%p]:'.

A target that does put fields before the pid reads as a server with no log events and no deadlocks, which is the silent-failure shape these families refuse by name elsewhere.

Fix

Extend the assembler's space family, both deadlock patterns and the log-events SQL to allow fields between the zone and the pid, as plan capture does, through a gap that excludes [. That keeps #4008's rule that the gap cannot pass the line's real bracket.

This is the reader #3996 hardened over several review rounds, and its label-boundary rules (s_prefixRun) must hold for the new run too. So it gets its own PR and a security review round, not a rider on #4014.

Activity

  1. added
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Sep 23, 2026
  2. erikdarlingdata commented on Sep 23, 2026

    @erikdarlingdata
    OwnerAuthor

    Disposition (backtrack of #3898-#4043, 2026-09-23): work order 3 of 6, tier 2 (user-visible on targets with this prefix; the common default prefixes are unaffected). A lane is on it now: the assembler's space family, both deadlock patterns and every prefix spelling are to accept fields before the pid, keeping #3996's label-boundary rules and #4008's no-backtrack gap. Draft PR plus a security review round.

  3. erikdarlingdata commented on Sep 23, 2026

    @erikdarlingdata
    OwnerAuthor

    Closed by the watcher: delivered in PR #4047, merged to dev.

  4. removed
    in-progressActively being worked by a local session or its agents (PR open or in flight)
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions