| From: | torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> |
|---|---|
| To: | João Rito <joaovictor(dot)rito(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | solai v <solai(dot)cdac(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, nagata(at)sraoss(dot)co(dot)jp |
| Subject: | Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations? |
| Date: | 2026-11-24 14:48:05 |
| Message-ID: | bcb809bbc1378c9dd9769743ec3c63e3@oss.nttdata.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Nov 10, 2026 at 9:19 AM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
wrote:
Thanks for your review!
> Regarding the patch:
>
> - ReorderBufferQueueMessage(ctx->reorder, xid, snapshot, buf->endptr,
> + /*
> + * Non-transactional messages are processed as separate transactions
> on
> + * the receiver, so use endptr as the confirmed flush position for
> them.
> + */
> + ReorderBufferQueueMessage(ctx->reorder, xid, snapshot,
> + message->transactional ? buf->origptr : buf->endptr,
> message->transactional,
>
> I think this needs more comments: what we assume on the consumer side
> (a non-transactional message is applied and confirmed as a unit of its
> own, like a commit), and what happens if we used origptr for a
> non-transactional message instead; a consumer that reports the
> message's LSN as its flush position can get the message decoded again
> after a restart, since decoding resumes from the confirmed position
> inclusive. It's the same reason why the commit message carries both
> commit_lsn and end_lsn.
Agreed.
> Also, logicaldecoding.sgml says "The lsn has WAL location of the
> message" for message_cb, which needs the same update, in the
> back-branch patches too.
Agreed.
Also, since the parameter is actually named `message_lsn` rather than
`lsn`, the attached patch changes this as well.
On 2026-11-12 07:15, João Rito wrote:
Thanks for your review!
> One more small idea: the existing tests pass both before and after the
> patch, so none of them covers this change. Maybe a small test in
> contrib/test_decoding could check that a transactional message and the
> next change get different LSNs.
It might be redundant, but the attached patch adds tests to check the
LSNs for both transactional and non-transactional messages.
What do you think?
--
Thanks,
--
Atsushi Torikoshi
Seconded from NTT DATA CORPORATION to SRA OSS K.K.
| Attachment | Content-Type | Size |
|---|---|---|
| v4-0001-Use-start-LSN-for-transactional-logical-decoding-.patch | text/x-diff | 7.3 KB |
| v4-0001-Correct-documentation-of-logical-decoding-message-v15-19.txt | text/x-diff | 2.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ilia Evdokimov | 2026-11-24 15:11:53 | Re: Fold NOT IN / <> ALL expressions containing NULL to FALSE |
| Previous Message | Andrei Lepikhov | 2026-11-24 14:46:38 | Re: Numeric equality and hashing without detoasting |