On Fri, Mar 5, 2021 at 7:11 AM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Thu, Mar 4, 2021 at 8:03 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > > > I have just checked via code coverage that we don't seem to have tests > for recovery of replication origin advance for commit [1], see > function xact_redo_commit. Similarly, a similar code is not covered > for prepare [2], see EndPrepare. I think overall the test cases for > replication origins are not very many. Now, I think if we want to have > more tests in this area then we need to look at it more broadly. I > think it could be that currently only subscriber-side covers some part > of origins testing, otherwise, we don't have a detailed test suite by > using replication origin APIs and second is probably it might be > tricky to write a reliable recovery test case. One idea could be to > just write a test for the non-recovery code path (the code added in > function RecordTransactionAbortPrepared) and leave recovery testing > for now. >
For non-recovery, I have to write a test like below: SELECT pg_replication_origin_create('regress'); SELECT pg_replication_origin_session_setup('regress'); Begin; SELECT pg_replication_origin_xact_setup('0/aabbccdd', '2013-01-01 00:00'); Insert into t1 values(1); Prepare Transaction 'foo'; SELECT pg_replication_origin_xact_setup('0/aabbccee', '2013-01-01 00:00'); Rollback Prepared 'foo'; SELECT pg_replication_origin_session_progress(true); The thing which bothers me about such a test would be to call pg_replication_origin_xact_setup after 'Prepare Transaction', it seems like I am exploiting this API for this test. This API is not meant for this purpose, so not sure if I should go ahead with this test or not. What do you think? If you can think of any other alternative then let me know? We don't have a very good infrastructure to test origins and its progress except for the subscriber-side code. -- With Regards, Amit Kapila.