From 1cf257bc4ae224dbd5b411c3ea8675bb1a188ba4 Mon Sep 17 00:00:00 2001 From: andres Date: Fri, 4 Nov 2022 09:58:35 +0100 Subject: [PATCH] feedback --- compute_tools/src/pg_helpers.rs | 2 +- pgxn/neon/walproposer.c | 16 +++++++++------- pgxn/neon/walproposer.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/compute_tools/src/pg_helpers.rs b/compute_tools/src/pg_helpers.rs index 42aa00af01..289f223bda 100644 --- a/compute_tools/src/pg_helpers.rs +++ b/compute_tools/src/pg_helpers.rs @@ -65,7 +65,7 @@ impl GenericOption { let name = match self.name.as_str() { "safekeepers" => "neon.safekeepers", "wal_acceptor_reconnect" => "neon.safekeeper_reconnect_timeout", - "wal_acceptor_connect_timeout" => "neon.safekeeper_connect_timeout", + "wal_acceptor_connection_timeout" => "neon.safekeeper_connection_timeout", it => it, }; diff --git a/pgxn/neon/walproposer.c b/pgxn/neon/walproposer.c index c5f283aa22..c24142dca1 100644 --- a/pgxn/neon/walproposer.c +++ b/pgxn/neon/walproposer.c @@ -75,7 +75,7 @@ static bool syncSafekeepers = false; char *wal_acceptors_list; int wal_acceptor_reconnect_timeout; -int wal_acceptor_connect_timeout; +int wal_acceptor_connection_timeout; bool am_wal_proposer; char *neon_timeline_walproposer = NULL; @@ -266,9 +266,9 @@ nwp_register_gucs(void) DefineCustomIntVariable( "neon.safekeeper_connect_timeout", - "Timeout after which give up connection attempt to safekeeper.", + "Timeout for connection establishement and it's maintenance against safekeeper", NULL, - &wal_acceptor_connect_timeout, + &wal_acceptor_connection_timeout, 5000, 0, INT_MAX, PGC_SIGHUP, GUC_UNIT_MS, @@ -417,7 +417,9 @@ WalProposerPoll(void) ResetLatch(MyLatch); break; } - if (rc == 0) /* timeout expired: poll state */ + + now = GetCurrentTimestamp(); + if (rc == 0 || TimeToReconnect(now) <= 0) /* timeout expired: poll state */ { TimestampTz now; @@ -439,10 +441,10 @@ WalProposerPoll(void) Safekeeper *sk = &safekeeper[i]; if (TimestampDifferenceExceeds(sk->latestMsgReceivedAt, now, - wal_acceptor_connect_timeout)) + wal_acceptor_connection_timeout)) { - elog(WARNING, "failed to connect to node '%s:%s': exceeded connection timeout %dms", - sk->host, sk->port, wal_acceptor_connect_timeout); + elog(WARNING, "failed to connect to node '%s:%s' in '%s' state: exceeded connection timeout %dms", + sk->host, sk->port, FormatSafekeeperState(sk->state), wal_acceptor_connection_timeout); ShutdownConnection(sk); } } diff --git a/pgxn/neon/walproposer.h b/pgxn/neon/walproposer.h index 0d3af54a68..3c4f080353 100644 --- a/pgxn/neon/walproposer.h +++ b/pgxn/neon/walproposer.h @@ -30,7 +30,7 @@ extern char *wal_acceptors_list; extern int wal_acceptor_reconnect_timeout; -extern int wal_acceptor_connect_timeout; +extern int wal_acceptor_connection_timeout; extern bool am_wal_proposer; struct WalProposerConn; /* Defined in libpqwalproposer */