Remove redundant fetch of the recent flush pointer in WalSndWaitForWal.
authorAmit Kapila <akapila@postgresql.org>
Tue, 12 Mar 2024 04:55:27 +0000 (10:25 +0530)
committerAmit Kapila <akapila@postgresql.org>
Tue, 12 Mar 2024 04:55:27 +0000 (10:25 +0530)
In WalSndWaitForWal(), we fetch a recent flush pointer both outside the
loop and inside the loop. But we start using RecentFlushPtr only after we
fetch it inside the loop. So we can remove one outside the loop.

Author: Shveta Malik
Reviewed-by: Bertrand Drouvot, Matthias van de Meent, Amit Kapila
Discussion: https://postgr.es/m/CAJpy0uBSCQz1yMD-WiEthzEe23dti2-Kr_pitVb7vAPFbFKm=A@mail.gmail.com

src/backend/replication/walsender.c

index 25edb5e141205c3ff9b5c69bc33067e4ffd0c31a..bc40c454de4ff1df50dbc01f33e69a5d52f71f3a 100644 (file)
@@ -1831,12 +1831,6 @@ WalSndWaitForWal(XLogRecPtr loc)
        !NeedToWaitForWal(loc, RecentFlushPtr, &wait_event))
        return RecentFlushPtr;
 
-   /* Get a more recent flush pointer. */
-   if (!RecoveryInProgress())
-       RecentFlushPtr = GetFlushRecPtr(NULL);
-   else
-       RecentFlushPtr = GetXLogReplayRecPtr(NULL);
-
    /*
     * Within the loop, we wait for the necessary WALs to be flushed to disk
     * first, followed by waiting for standbys to catch up if there are enough