From 588cb289d5a00bc5b13a6ef4b737578a963406d4 Mon Sep 17 00:00:00 2001 From: Kosntantin Knizhnik Date: Mon, 21 Jul 2025 13:29:38 +0300 Subject: [PATCH] Do flush only iof there are no in-glight prefetch requests --- pgxn/neon/communicator.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/pgxn/neon/communicator.c b/pgxn/neon/communicator.c index 6675695e9b..025445a166 100644 --- a/pgxn/neon/communicator.c +++ b/pgxn/neon/communicator.c @@ -470,14 +470,18 @@ communicator_prefetch_pump_state(void) { START_PREFETCH_RECEIVE_WORK(); - /* - * Flush request to avoid requests pending for arbitrary long time, - * pinning LSN and holding GC at PS. - */ - if (!prefetch_flush_requests()) + if (MyPState->ring_receive == MyPState->ring_flush && MyPState->ring_flush < MyPState->ring_unused) { - END_PREFETCH_RECEIVE_WORK(); - return; + /* + * Flush request to avoid requests pending for arbitrary long time, + * pinning LSN and holding GC at PS. + */ + if (!prefetch_flush_requests()) + { + END_PREFETCH_RECEIVE_WORK(); + return; + } + MyPState->ring_flush = MyPState->ring_unused; } while (MyPState->ring_receive != MyPState->ring_flush) {