On Tue, Nov 17, 2026 at 6:06 AM Masahiko Sawada <[email protected]> wrote: > > On Sun, Nov 15, 2026 at 9:13 AM Zhijie Hou <[email protected]> wrote: > > > I've attached the updated patches. >
Hi Sawada-san, I found an issue in 0002 with non-transactional messages. I found this while reviewing the patch with Claude, which also helped write the TAP test below. In apply_handle_message(), the non-transactional branch commits the handler's work locally but calls replorigin_xact_clear(false) first, so the commit doesn't advance the replication origin. Until the publisher receives feedback that this commit has been flushed, both the origin and the slot's confirmed_flush point before the message. Feedback lags, since apply workers default to synchronous_commit = off. If the worker exits in that window, the message is decoded and sent again on restart, and the handler runs again. The easiest way to hit it is a non-transactional message followed by a transaction that conflicts on the subscriber. Every retry re-applies the message before failing on the conflict again. With wal_retrieve_retry_interval = 200ms I saw 42 handler invocations for a single message in 8 seconds. Handlers are documented as needing to be idempotent, but repeating once per retry seems avoidable, since normal transactions don't have this problem. The fix is to record the message's LSN as the origin LSN instead of clearing it: - replorigin_xact_clear(false); + replorigin_xact_state.origin_lsn = msg.lsn; + replorigin_xact_state.origin_timestamp = 0; With origin_timestamp = 0, RecordTransactionCommit() uses the local commit time, so the commit still doesn't inherit the previous transaction's timestamp, which was the reason for the clear. With this change the handler runs once across all retries, and 001_basic.pl still passes. Attached is a TAP test (099_nontx_redelivery.pl) that reproduces the issue: it fails on v9 and passes with the change above. Regards, Ajin Cherian Fujitsu Australia
099_nontx_redelivery.pl
Description: Binary data
