## Not patched 2020-12-07 17:03:45.237 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:03:46.237 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:03:46.238 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:03:47.240 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:03:47.240 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:03:47.818 AEDT [27247] LOG: logical decoding found consistent point at 0/1624870 2020-12-07 17:03:47.818 AEDT [27247] DETAIL: There are no running transactions. 2020-12-07 17:03:47.818 AEDT [27247] STATEMENT: CREATE_REPLICATION_SLOT "tap_sub_16433_sync_16385" TEMPORARY LOGICAL pgoutput USE_SNAPSHOT 2020-12-07 17:03:47.820 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:03:47.821 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:03:47.832 AEDT [26333] LOG: !!>> tablesync worker: wait for CATCHUP state notification 2020-12-07 17:03:47.832 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:03:47.832 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 16:59:21.501 AEDT [19106] LOG: !!>> apply worker: called process_syncing_tables ## Attached and paused in debugger where the "tablesync" is told to CATCHUP. ### At this point we might execute any number of SQL commands e.g 10 inserts psql -d test_pub -c "INSERT INTO test_tab VALUES(1, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(2, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(3, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(4, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(5, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(6, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(7, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(8, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(9, 'foo');" psql -d test_pub -c "INSERT INTO test_tab VALUES(10, 'foo');" ## Now continue in the "tablesync" worker 2020-12-07 17:06:25.315 AEDT [26333] LOG: !!>> tablesync worker: LogicalRepApplyLoop 2020-12-07 17:06:52.606 AEDT [26333] LOG: !!>> tablesync worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:12.815 AEDT [26333] LOG: !!>> tablesync worker: apply_dispatch for message kind 'R' 2020-12-07 17:07:29.047 AEDT [26333] LOG: !!>> tablesync worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:33.650 AEDT [26333] LOG: !!>> tablesync worker: should_apply_changes_for_rel: true rel->state == READY: false rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:38.874 AEDT [26333] LOG: !!>> tablesync worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:41.018 AEDT [26333] LOG: !!>> tablesync worker: called process_syncing_tables ## Here the "tablesync" finds that it CATCHUP stat and current_lsn >= MyLogicalRepWorker->relstate_lsn ## so it sets SYNCDONE assigned true and finishes. So "apply worker" handles all the other messages of the other 9 inserts 2020-12-07 17:07:42.192 AEDT [26333] LOG: logical replication table synchronization worker for subscription "tap_sub", table "test_tab" has finished 2020-12-07 17:07:42.193 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:07:42.193 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.193 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'R' 2020-12-07 17:07:42.193 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.194 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: false rel->state == READY: false rel->state == SYNCDONE: true rel->statelsn <= remote_final_lsn: false 2020-12-07 17:07:42.194 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.194 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.194 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.194 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.195 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'B' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'I' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: should_apply_changes_for_rel: true rel->state == READY: true rel->state == SYNCDONE: false rel->statelsn <= remote_final_lsn: true 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: apply_dispatch for message kind 'C' 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.196 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.197 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:07:42.197 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:42.397 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:07:42.397 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables 2020-12-07 17:07:43.398 AEDT [26325] LOG: !!>> apply worker: LogicalRepApplyLoop 2020-12-07 17:07:43.398 AEDT [26325] LOG: !!>> apply worker: called process_syncing_tables