Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations?
torikoshia <torikoshia@oss.nttdata.com>
From: torikoshia <torikoshia@oss.nttdata.com>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, nagata@sraoss.co.jp
Cc: pgsql-hackers@lists.postgresql.org
Date: 2026-06-11T02:27:20Z
Lists: pgsql-hackers
Nagata-san, Horiguchi-san, Thank you for confirming! My understanding is as follows: - It is not clear why only logical messages return endptr. - According to the documentation, the value should be startptr rather than endptr. - PostgreSQL itself does not have mechanism that uses this LSN, so either value does not cause a problem within PostgreSQL. Regarding the third point, I believe this distinction is important for consumers of logical decoding. Typically, a consumer records the LSN up to which the decoded result has been successfully processed and uses that LSN as the restart point after a crash or other failure. From that perspective, whether startptr or endptr is returned matters. With the current behavior, consumers need to be aware that only logical messages return endptr (and this does not appear to be documented, so one would have to discover it through testing). Then they need special handling to translate the completion LSN for logical messages back to the previous processing position. On this point, I have started discussing with the Debezium community, where I originally encountered this issue. The main question is whether a change in PostgreSQL's behavior would be welcomed, or whether Debezium instead treats logical messages differently from other decoded records. If they reach some consensus, I would be happy to share the outcome here. It is also possible that someone from the Debezium community will comment on this thread directly. I think it's valuable to hear from anyone familiar with products or applications that decode pg_logical_emit_message(). For example, I wonder whether Fujitsu's 'Userlog Operation' might also be affected: https://www.postgresql.fastware.com/hubfs/_Global/Manuals/FEP-v17forx86-UserlogOperationGuide.pdf Thanks, -- Atsushi Torikoshi
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Generic Messages for Logical Decoding
- 3fe3511d0512 9.6.0 cited