From 3a1be9b246439a5259d5c4d3586de113ccb23560 Mon Sep 17 00:00:00 2001 From: Arthur Petukhovsky Date: Wed, 12 Jul 2023 17:48:20 +0100 Subject: [PATCH] Broadcast before exiting sync safekeepers (#4700) Recently we started doing sync-safekeepers before exiting compute_ctl, expecting that it will make next sync faster by skipping recovery. But recovery is still running in some cases (https://github.com/neondatabase/neon/pull/4574#issuecomment-1629256166) because of the lagging truncateLsn. This PR should help with updating truncateLsn. --- pgxn/neon/walproposer.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pgxn/neon/walproposer.c b/pgxn/neon/walproposer.c index 8d82de6dc4..765966092d 100644 --- a/pgxn/neon/walproposer.c +++ b/pgxn/neon/walproposer.c @@ -2231,6 +2231,18 @@ HandleSafekeeperResponse(void) if (n_synced >= quorum) { /* All safekeepers synced! */ + + /* + * Send empty message to broadcast latest truncateLsn to all safekeepers. + * This helps to finish next sync-safekeepers eailier, by skipping recovery + * step. + * + * We don't need to wait for response because it doesn't affect correctness, + * and TCP should be able to deliver the message to safekeepers in case of + * network working properly. + */ + BroadcastAppendRequest(); + fprintf(stdout, "%X/%X\n", LSN_FORMAT_ARGS(propEpochStartLsn)); exit(0); }