Re: pg_logical_emit_message() misses a XLogFlush()

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: bt23nguyent <bt23nguyent(at)oss(dot)nttdata(dot)com>, Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_logical_emit_message() misses a XLogFlush()
Date: 2023-10-16 07:17:23
Message-ID: ZSzjg3HxFLaxLs7W@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Oct 13, 2023 at 03:20:30PM +0530, Amit Kapila wrote:
> I would prefer to associate the new parameter 'flush' with
> non-transactional messages as per the proposed patch.

Check.

> Is there a reason to make the functions strict now when they were not earlier?

These two are already STRICT on HEAD:
=# select proname, provolatile, proisstrict from pg_proc
where proname ~ 'message';
proname | provolatile | proisstrict
-------------------------+-------------+-------------
pg_logical_emit_message | v | t
pg_logical_emit_message | v | t
(2 rows)

> 2.
> + The <parameter>flush</parameter> parameter (default set to
> + <literal>false</literal>) controls if the message is immediately
> + flushed to WAL or not. <parameter>flush</parameter> has no effect
> + with <parameter>transactional</parameter>, as the message's WAL
> + record is flushed when its transaction is committed.
>
> The last part of the message sounds a bit too specific (".. as the
> message's WAL record is flushed when its transaction is committed.")
> because sometimes the WAL could be flushed by walwriter even before
> the commit. Can we say something along the lines: ".. as the message's
> WAL record is flushed along with its transaction."?

Fine by me.

> 3.
> + /*
> + * Make sure that the message hits disk before leaving if not emitting a
> + * transactional message, if flush is requested.
> + */
> + if (!transactional && flush)
>
> Two ifs in the above comment sound a bit odd but if we want to keep it
> like that then adding 'and' before the second if may slightly improve
> it.

Sure, I've improved this comment.

An updated version is attached. How does it look?
--
Michael

Attachment Content-Type Size
v5-0001-Add-flush-argument-to-pg_logical_emit_message.patch text/x-diff 8.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2023-10-16 07:29:56 Re: Add support for AT LOCAL
Previous Message Michael Paquier 2023-10-16 07:16:37 Re: Add a new BGWORKER_BYPASS_ROLELOGINCHECK flag