| From: | torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | João Rito <joaovictor(dot)rito(at)gmail(dot)com>, 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-25 13:53:06 |
| Message-ID: | 2f0691c078f23ba600831bb9e368aca7@oss.nttdata.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 2026-11-25 08:11, Masahiko Sawada wrote:
> On Tue, Nov 24, 2026 at 6:48 AM torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
> wrote:
>>
>> 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.
>
> Thank you for updating the patch!
> v4-0001-Use-start-LSN-for-transactional-logical-decoding-.patch
> basically looks good to me. I've attached a top-up patch for minor
> things. Please feel free to merge them if you think it's okay.
Thanks for the fix! It seems better.
Applied it and attached v5 patch.
>
> The
> v4-0001-Correct-documentation-of-logical-decoding-message-v15-19.txt
> looks good to me, so I'm going to push it, barring any objections.
--
Thanks,
--
Atsushi Torikoshi
Seconded from NTT DATA CORPORATION to SRA OSS K.K.
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Use-start-LSN-for-transactional-logical-decoding-.patch | text/x-diff | 8.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tatsuya Kawata | 2026-11-25 13:57:14 | Re: HashAggregate loses worker spill stats on rescan |
| Previous Message | Álvaro Herrera | 2026-11-25 13:48:36 | Re: pg_commit_ts pages can be written before WAL is flushed |