I have created a replication slot:
SELECT * FROM pg_create_logical_replication_slot('boxoffice_slot', 'test_decoding');
Each step in a transaction has its own row in a replication slot. Here is an example:
lsn | xid | data
-------------+---------+---------------
34A/7000028 | 1311904 | BEGIN 1311904
34A/70020E0 | 1311904 | table cad.purchases: INSERT: id[integer]:754862
34A/70020E1 | 1311904 | table cad.purchases: INSERT: id[integer]:754863
34A/7000028 | 1311904 | COMMIT 1311904
Questions:
At what point in the transaction lifecycle do transaction steps start getting written to the replication slot?
Is it possible that transaction steps are written to a replication slot before the transaction is committed?
In other words, is it possible that only half a transaction is written to a replication slot at any given time like so:
lsn | xid | data
-------------+---------+---------------
34A/7000028 | 1311904 | BEGIN 1311904
34A/70020E0 | 1311904 | table cad.purchases: INSERT: id[integer]:754862
Thanks very much for an insight on this.
Based on the following test I conclude that a transaction is inserted into a replication slot only after it is committed.