Hi,
On 12/13/23 3:33 PM, Michael Paquier wrote:
On Tue, Dec 12, 2023 at 04:54:32PM -0300, Euler Taveira wrote:
Couldn't it give up before starting if you apply your patch? My main concern is
due to a slow system, the walrcv_connect() took to long in WalReceiverMain()
and the code above kills the walreceiver while in the process to start it.
Since you cannot control the hardcoded WALRCV_STARTUP_TIMEOUT value, you might
have issues during overload periods.
Sounds like a fair point to me,
Thanks for looking at it! I'm not sure about it, see my comment in [1].
Another thing that I'm a bit surprised with is why it would be OK to
switch the status to STREAMING only we first_stream is set, discarding
the restart case.
Yeah, that looks like a miss on my side. Thanks for pointing out!
Please find attached v2 addressing this remark.
[1]:
https://www.postgresql.org/message-id/c76c0a65-f754-4614-b616-1d48f9195745%40gmail.com
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
From 12da1b3c6295e2369b3a65c8f4ee40882def310f Mon Sep 17 00:00:00 2001
From: Bertrand Drouvot <bertranddrouvot...@gmail.com>
Date: Mon, 11 Dec 2023 20:05:25 +0000
Subject: [PATCH v2] move walrcv->walRcvState assignment to WALRCV_STREAMING
walrcv->walRcvState = WALRCV_STREAMING was set to early. Move the assignement
to a more appropriate place.
---
src/backend/replication/walreceiver.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
100.0% src/backend/replication/
diff --git a/src/backend/replication/walreceiver.c
b/src/backend/replication/walreceiver.c
index 26ded928a7..5f612d354e 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -242,7 +242,6 @@ WalReceiverMain(void)
}
/* Advertise our PID so that the startup process can kill us */
walrcv->pid = MyProcPid;
- walrcv->walRcvState = WALRCV_STREAMING;
/* Fetch information required to start streaming */
walrcv->ready_to_display = false;
@@ -412,6 +411,9 @@ WalReceiverMain(void)
options.proto.physical.startpointTLI = startpointTLI;
if (walrcv_startstreaming(wrconn, &options))
{
+ SpinLockAcquire(&walrcv->mutex);
+ walrcv->walRcvState = WALRCV_STREAMING;
+ SpinLockRelease(&walrcv->mutex);
if (first_stream)
ereport(LOG,
(errmsg("started streaming WAL
from primary at %X/%X on timeline %u",
--
2.34.1