v12_diff_amit_1.patch.txt

text/plain

Filename: v12_diff_amit_1.patch.txt
Type: text/plain
Part: 0
Message: Re: Conflict detection for update_deleted in logical replication
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 07e9916a1b..75fd3a5f7f 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -280,8 +280,8 @@ typedef enum
 /*
  * The phases involved in advancing the non-removable transaction ID.
  *
- * Refer to maybe_advance_nonremovable_xid() for details on how the function
- * transitions between these phases.
+ * See maybe_advance_nonremovable_xid() for details of the transition
+ * between these phases.
  */
 typedef enum
 {
@@ -385,7 +385,7 @@ static BufFile *stream_fd = NULL;
  */
 static XLogRecPtr last_flushpos = InvalidXLogRecPtr;
 
-/* Buffers for constructing outgoing messages. */
+/* Buffer for constructing outgoing messages. */
 static StringInfo reply_message = NULL;
 
 typedef struct SubXactInfo
@@ -4082,8 +4082,12 @@ get_candidate_xid(RetainConflictInfoData *data)
 	now = GetCurrentTimestamp();
 
 	/*
-	 * Compute the candidate_xid and send a message at most once per
-	 * wal_receiver_status_interval.
+	 * Compute the candidate_xid and request the publisher status at most once
+	 * per wal_receiver_status_interval. This is to avoid using CPU and network
+	 * resources without making much progress.
+	 *
+	 * XXX The use of wal_receiver_status_interval is a bit arbitrary so we can
+	 * consider the other interval or a separate GUC if the need arises.
 	 */
 	if (!TimestampDifferenceExceeds(data->xid_advance_attempt_time, now,
 									wal_receiver_status_interval * 1000))