change_to_ms.diffs

application/octet-stream

Filename: change_to_ms.diffs
Type: application/octet-stream
Part: 1
Message: RE: Conflict detection for update_deleted in logical replication
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index e0c8325a39..f211ad5a1d 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -5007,7 +5007,7 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
        or when <varname>synchronous_commit</varname> is set to
        <literal>remote_apply</literal>.
        Thus, the apply position may lag slightly behind the true position.
-       If this value is specified without units, it is taken as seconds.
+       If this value is specified without units, it is taken as milliseconds.
        The default value is 10 seconds. This parameter can only be set in
        the <filename>postgresql.conf</filename> file or on the server
        command line.
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 4657612a2f..494d69dc24 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -3981,7 +3981,7 @@ send_feedback(XLogRecPtr recvpos, bool force, bool requestReply)
 		writepos == last_writepos &&
 		flushpos == last_flushpos &&
 		!TimestampDifferenceExceeds(send_time, now,
-									wal_receiver_status_interval * 1000))
+									wal_receiver_status_interval))
 		return;
 	send_time = now;
 
@@ -4134,7 +4134,7 @@ get_candidate_xid(RetainConflictInfoData *data)
 	 * consider the other interval or a separate GUC if the need arises.
 	 */
 	if (!TimestampDifferenceExceeds(data->candidate_xid_time, now,
-									wal_receiver_status_interval * 1000))
+									wal_receiver_status_interval))
 		return;
 
 	data->candidate_xid_time = now;
@@ -4310,7 +4310,7 @@ can_advance_nonremovable_xid(RetainConflictInfoData *data, TimestampTz now)
 	return MySubscription->detectupdatedeleted &&
 		   data->phase == RCI_GET_CANDIDATE_XID &&
 		   TimestampDifferenceExceeds(data->candidate_xid_time, now,
-									  wal_receiver_status_interval * 1000);
+									  wal_receiver_status_interval);
 }
 
 /*
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 5f641d2790..678118f076 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -1335,13 +1335,13 @@ WalRcvComputeNextWakeup(WalRcvWakeupReason reason, TimestampTz now)
 			if (!hot_standby_feedback || wal_receiver_status_interval <= 0)
 				wakeup[reason] = TIMESTAMP_INFINITY;
 			else
-				wakeup[reason] = TimestampTzPlusSeconds(now, wal_receiver_status_interval);
+				wakeup[reason] = TimestampTzPlusMilliseconds(now, wal_receiver_status_interval);
 			break;
 		case WALRCV_WAKEUP_REPLY:
 			if (wal_receiver_status_interval <= 0)
 				wakeup[reason] = TIMESTAMP_INFINITY;
 			else
-				wakeup[reason] = TimestampTzPlusSeconds(now, wal_receiver_status_interval);
+				wakeup[reason] = TimestampTzPlusMilliseconds(now, wal_receiver_status_interval);
 			break;
 			/* there's intentionally no default: here */
 	}
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 8cf1afbad2..4774e06415 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2252,10 +2252,10 @@ struct config_int ConfigureNamesInt[] =
 		{"wal_receiver_status_interval", PGC_SIGHUP, REPLICATION_STANDBY,
 			gettext_noop("Sets the maximum interval between WAL receiver status reports to the sending server."),
 			NULL,
-			GUC_UNIT_S
+			GUC_UNIT_MS
 		},
 		&wal_receiver_status_interval,
-		10, 0, INT_MAX / 1000,
+		10 * 1000, 0, INT_MAX,
 		NULL, NULL, NULL
 	},
 
diff --git a/src/test/recovery/t/001_stream_rep.pl b/src/test/recovery/t/001_stream_rep.pl
index f3ea45ac4a..ec57b5fde1 100644
--- a/src/test/recovery/t/001_stream_rep.pl
+++ b/src/test/recovery/t/001_stream_rep.pl
@@ -344,7 +344,7 @@ is( $node_primary->psql(
 $node_standby_1->append_conf('postgresql.conf',
 	"primary_slot_name = $slotname_1");
 $node_standby_1->append_conf('postgresql.conf',
-	"wal_receiver_status_interval = 1");
+	"wal_receiver_status_interval = 1s");
 $node_standby_1->append_conf('postgresql.conf', "max_replication_slots = 4");
 $node_standby_1->restart;
 is( $node_standby_1->psql(
@@ -355,7 +355,7 @@ is( $node_standby_1->psql(
 $node_standby_2->append_conf('postgresql.conf',
 	"primary_slot_name = $slotname_2");
 $node_standby_2->append_conf('postgresql.conf',
-	"wal_receiver_status_interval = 1");
+	"wal_receiver_status_interval = 1s");
 # should be able change primary_slot_name without restart
 # will wait effect in get_slot_xmins above
 $node_standby_2->reload;
diff --git a/src/test/recovery/t/010_logical_decoding_timelines.pl b/src/test/recovery/t/010_logical_decoding_timelines.pl
index afcd5241aa..ab9a403aeb 100644
--- a/src/test/recovery/t/010_logical_decoding_timelines.pl
+++ b/src/test/recovery/t/010_logical_decoding_timelines.pl
@@ -42,7 +42,7 @@ max_replication_slots = 3
 max_wal_senders = 2
 log_min_messages = 'debug2'
 hot_standby_feedback = on
-wal_receiver_status_interval = 1
+wal_receiver_status_interval = 1s
 ]);
 $node_primary->dump_info;
 $node_primary->start;