Re: Add wait events for server logging destination writes

From: 신성준 <shinsj4653(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: wolakk(at)gmail(dot)com, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, x4mmm(at)yandex-team(dot)ru, andreas(at)proxel(dot)se, nik(at)postgres(dot)ai
Subject: Re: Add wait events for server logging destination writes
Date: 2026-06-06 16:52:34
Message-ID: CACdN0M65jfGbOcBDm5rM_3nGVYNan7EQ9vQ1WAyk6Xx8X10Wrw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

cfbot flagged v3 as needing a rebase -- it stopped applying after the
recent changes to elog.c (the switch to a const WCHAR pointer in
write_eventlog(), pgindent, etc.) and the new COPY pipe wait events in
wait_event_names.txt.

v4 is the same change rebased over current master, no functional
difference from v3. The only real conflict was in write_eventlog(),
where the EventlogWrite wrapping now sits on top of the const
utf16_const pointer; everything else merged cleanly.

Still applies as two patches:
v4-0001 - portable part (SysloggerWrite, StderrWrite, SyslogWrite)
v4-0002 - Windows part (WriteConsoleW plus EventlogWrite)

Builds clean on current master with both Autoconf and Meson, no new
warnings.

Thanks,
Seongjun Shin

2026년 6월 7일 (일) 오전 1:25, 신성준 <shinsj4653(at)gmail(dot)com>님이 작성:
>
> Hi,
>
> Thanks Kirk, glad it's useful.
>
> Kyotaro Horiguchi wrote:
> > Should we also consider instrumenting ReportEventW()/ReportEventA()?
> > They seem to be another Windows-specific logging output path.
> >
> > Also, if the intention is to cover all places where logging output
> > can block, I wonder whether the syslog() calls should be covered as
> > well.
>
> Good points -- both are blocking output paths and there's no real
> reason to leave them out, so v3 instruments them rather than excluding
> them with a comment. The intent is exactly to cover the places where
> logging output can block, so this makes the series consistent.
>
> v3 adds two more WaitEventIO events:
>
> IO / SyslogWrite - syslog(3) in write_syslog()
> IO / EventlogWrite - ReportEventW()/ReportEventA() in write_eventlog()
>
> Same approach as before: the wait is reported only around the leaf
> call, using the existing pgstat_report_wait_start()/end() helpers, so
> it stays allocation-free and safe on the error-reporting path, and the
> series still touches just elog.c and wait_event_names.txt.
>
> This also matches Michael's point on v2 -- each event covers a routine
> rather than a single call site, so SyslogWrite wraps the syslog(3)
> calls in write_syslog() and EventlogWrite wraps both ReportEvent
> variants in write_eventlog(), the same way SysloggerWrite already
> covers the two writes in write_pipe_chunks().
>
> As before, 0001 is the portable part and 0002 is the Windows part
> (WriteConsoleW plus the new EventlogWrite).
>
> One caveat: EventlogWrite is Windows-only, so I couldn't get a runtime
> before/after for it here -- I've only confirmed it builds (cfbot's
> Windows task should cover that). The other events still show up in the
> sampling I posted earlier. If someone on Windows can exercise the
> event-log path I'd appreciate a confirmation.
>
> Applies cleanly on current master; full build passes locally on both
> Autoconf and Meson, with no new warnings.
>
> Thanks,
> Seongjun Shin
>
> 2026년 6월 1일 (월) 오후 2:49, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>님이 작성:
> >
> > Hello.
> >
> > At Sun, 31 May 2026 17:50:08 +0900, 신성준 <shinsj4653(at)gmail(dot)com> wrote in
> > > Attached is a short series that adds two WaitEventIO events and reports
> > > them around those writes:
> > >
> > > IO / SysloggerWrite - write(2) to the syslogger pipe
> > > IO / StderrWrite - write(2) to stderr, and WriteConsoleW()
> > >
> > > 0001 adds the events and covers the write(2) paths. 0002 does the
> > > Windows WriteConsoleW() path, split out since it's platform-specific.
> >
> > Should we also consider instrumenting ReportEventW()/ReportEventA()?
> > They seem to be another Windows-specific logging output path.
> >
> > Also, if the intention is to cover all places where logging output can
> > block, I wonder whether the syslog() calls should be covered as
> > well. If they are intentionally excluded, perhaps a short comment
> > explaining the rationale would be useful.
> >
> > Regards.
> >
> > --
> > Kyotaro Horiguchi
> > NTT Open Source Software Center

Attachment Content-Type Size
v4-0001-Add-wait-events-for-server-logging-destination-wr.patch application/octet-stream 4.6 KB
v4-0002-Add-wait-events-for-Windows-specific-logging-outp.patch application/octet-stream 3.5 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Nestorov 2026-06-06 17:37:51 Re: [PATCH] btree_gist: add cross-type integer operator support for GiST
Previous Message 신성준 2026-06-06 16:25:25 Re: Add wait events for server logging destination writes