diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 740ec89e070..fe558f0a81c 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -4961,8 +4961,8 @@ ANY num_sync ( The name of the slot to create. Must be a valid replication slot name (see ). - The name cannot be pg_conflict_detection, as it - is reserved for logical replication conflict detection. + The name cannot be pg_conflict_detection as it + is reserved for the conflict detection. diff --git a/doc/src/sgml/ref/create_subscription.sgml b/doc/src/sgml/ref/create_subscription.sgml index 739161df715..dba0f541ac5 100644 --- a/doc/src/sgml/ref/create_subscription.sgml +++ b/doc/src/sgml/ref/create_subscription.sgml @@ -170,8 +170,8 @@ CREATE SUBSCRIPTION subscription_name Name of the publisher's replication slot to use. The default is to use the name of the subscription for the slot name. The name cannot - be pg_conflict_detection, as it is reserved for - logical replication conflict detection. + be pg_conflict_detection as it is reserved for the + conflict detection. diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 6a59db47583..17963486795 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -3862,8 +3862,8 @@ LogicalRepApplyLoop(XLogRecPtr last_received) wait_time = NAPTIME_PER_CYCLE; /* - * Ensure to wake up when it's possible to attempt to advance the - * non-removable transaction ID. + * Ensure to wake up when it's possible to advance the non-removable + * transaction ID. */ if (data.phase == RCI_GET_CANDIDATE_XID && data.xid_advance_interval) wait_time = Min(wait_time, data.xid_advance_interval); @@ -4103,11 +4103,13 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply) * WALs that are being replicated from the primary and those WALs could have * earlier commit timestamp. * - * XXX It might seem feasible to track the latest commit timestamp on the - * publisher and send the WAL position once the timestamp exceeds that on the - * subscriber. However, commit timestamps can regress since a commit with a - * later LSN is not guaranteed to have a later timestamp than those with - * earlier LSNs. + * XXX It seems feasible to get the latest commit's WAL location from the + * publisher and wait till that is applied. However, we can't do that + * because commit timestamps can regress as a commit with a later LSN is not + * guaranteed to have a later timestamp than those with earlier LSNs. Having + * said that, even if that is possible, it won't improve performance much as + * the apply always lag and moves slowly as compared with the transactions + * on the publisher. */ static void maybe_advance_nonremovable_xid(RetainConflictInfoData *rci_data, @@ -4211,6 +4213,10 @@ get_candidate_xid(RetainConflictInfoData *rci_data) */ full_xid = FullTransactionIdFromAllowableAt(next_full_xid, oldest_running_xid); + /* + * Oldest active transaction ID (full_xid) can't be behind any of its + * previously computed value. + */ Assert(FullTransactionIdPrecedesOrEquals(MyLogicalRepWorker->oldest_nonremovable_xid, full_xid)); @@ -4294,12 +4300,12 @@ wait_for_publisher_status(RetainConflictInfoData *rci_data, * * It's possible that transactions in the commit phase during the last * cycle have now finished committing, but remote_oldestxid remains older - * than last_phase_at. This can happen if some old transaction was in the + * than last_phase_at. This can happen if some old transaction came in the * commit phase when we requested status in this cycle. We do not handle * this case explicitly as it's rare and the benefit doesn't justify the * required complexity. Tracking would require either caching all xids at * the publisher or sending them to subscribers. The condition will - * resolve naturally once the remaining transaction finishes. + * resolve naturally once the remaining transactions are finished. * * Directly advancing the non-removable transaction ID is possible if * there are no activities on the publisher since the last advancement