On Tue, Nov 10, 2020 at 4:19 PM Ajin Cherian <itsa...@gmail.com> wrote: > > I was doing some testing, and I found some issues. Two issues. The > first one, seems to be a behaviour that might be acceptable, the > second one not so much. > I was using test_decoding, not sure how this might behave with the > pg_output plugin. > > Test 1: > A transaction that is immediately rollbacked after the prepare. > > SET synchronous_commit = on; > SELECT 'init' FROM > pg_create_logical_replication_slot('regression_slot', > 'test_decoding'); > CREATE TABLE stream_test(data text); > -- consume DDL > SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, > NULL, 'include-xids', '0', 'skip-empty-xacts', '1'); > > BEGIN; > INSERT INTO stream_test SELECT repeat('a', 10) || g.i FROM > generate_series(1, 20) g(i); > PREPARE TRANSACTION 'test1'; > ROLLBACK PREPARED 'test1'; > SELECT data FROM pg_logical_slot_get_changes('regression_slot', > NULL,NULL, 'two-phase-commit', '1', 'include-xids', '0', > 'skip-empty-xacts', '1', 'stream-changes', '1'); > ================== > > Here, what is seen is that while the transaction was not decoded at > all since it was rollbacked before it could get decoded, the ROLLBACK > PREPARED is actually decoded. > The result being that the standby could get a spurious ROLLBACK > PREPARED. The current code in worker.c does handle this silently. So, > this might not be an issue. >
Yeah, this seems okay because it is quite possible that such a Rollback would have encountered after processing few records in which case sending the Rollback is required. This can happen when rollback has been issues concurrently when we are decoding prepare. If the Output plugin wants, then can detect that transaction has not written any data and ignore rollback and we already do something similar in test_decoding. So, I think this should be fine. -- With Regards, Amit Kapila.