| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: pgsql: Reduce log level of some logical decoding messages from LOG to D |
| Date: | 2026-04-06 15:57:26 |
| Message-ID: | CAHGQGwFARNb_2J1Skvw5RQSsyhqUqWQgQJNDhP+v-7fzinLfOw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers pgsql-hackers |
On Mon, Apr 6, 2026 at 11:55 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Thu, Apr 2, 2026 at 8:45 PM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> > > If something goes wrong, enabling the messages for the future
> > > won't tell you what went wrong in the past. I am wondering whether a
> > > better approach might be to set the LOG level based on context -- that
> > > is, if it's actually logical decoding, log this at LOG, but if it's
> > > just someone peeking at a slot or similar, reduce the log level to
> > > DEBUG1 or, really, probably more like DEBUG3.
> >
> > You are suggesting something like that logical walsender and
> > pg_logical_slot_get_changes() should log at LOG, while the slotsync worker
> > should use DEBUG? Sorry, I may be misunderstanding, since the slotsync worker
> > can also use logical decoding mechanism internally. Could you clarify what you
> > have in mind by "peeking at a slot or similar"?
>
> No, what I mean is that if someone runs an SQL function from the
> foreground, they probably don't want that to result in a LOG message,
> but if background activity results in such a message, the LOG message
> is probably a good idea. The reasons are:
>
> 1. Somebody might run many foreground queries that rely on the logical
> decoding infrastructure, so logging something every time such a query
> is executed could produce a lot of log spam. But there shouldn't be so
> much background logical decoding for this to be an issue.
>
> 2. If logical replication is not working, that may be a major issue
> for the DBA. A problem running pg_logical_slot_get_changes() is likely
> not as critical (and if it is, they can always lower
> client_min_messages or log_min_messages for that session only).
This seems similar to Bharath's suggestion in [1]. You can already do this by
setting log_min_messages = 'warning,walsender:debug1'. With that setting,
DEBUG1 logical decoding messages from walsender are logged at LOG, while
backends follow log_min_messages=warning, so logical decoding SQL functions
don't emit those DEBUG1 messages.
But probably are you suggesting making this behavior the default? If yes,
one straightforward approach to implement that would be to log these messages
at LOG when AmWalSenderProcess() or AmLogicalSlotSyncWorkerProcess() is true,
and at DEBUG1 otherwise.
The downside of this approach is that it becomes harder to suppress these
messages for walsender or slotsync worker if some users want to do that.
For example, raising log_min_messages to FATAL or PANIC would suppress them,
but would also hide ERROR messages, which isn't desirable in production.
Regards,
[1] https://postgr.es/m/CALj2ACX_SSJYKt5od1C2874yeotTO9JewfRY9B=3DYx2daUAMw@mail.gmail.com
--
Fujii Masao
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2026-04-06 16:15:47 | Re: pgsql: Reduce log level of some logical decoding messages from LOG to D |
| Previous Message | Robert Haas | 2026-04-06 15:19:13 | pgsql: Expose helper functions scan_quoted_identifier and scan_identifi |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Robert Haas | 2026-04-06 16:09:41 | Re: PG 19 release notes and authors |
| Previous Message | Jacob Champion | 2026-04-06 15:55:19 | Re: PG 19 release notes and authors |