Re: Regardign RecentFlushPtr in WalSndWaitForWal()

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: shveta malik <shveta(dot)malik(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: Regardign RecentFlushPtr in WalSndWaitForWal()
Date: 2024-03-01 10:35:52
Message-ID: ZeGviMr3RE8nybfI@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Mon, Feb 26, 2024 at 05:16:39PM +0530, shveta malik wrote:
> Hi hackers,
>
> I would like to understand why we have code [1] that retrieves
> RecentFlushPtr in WalSndWaitForWal() outside of the loop. We utilize
> RecentFlushPtr later within the loop, but prior to that, we already
> have [2]. Wouldn't [2] alone be sufficient?
>
> Just to check the impact, I ran 'make check-world' after removing [1],
> and did not see any issue exposed by the test at-least.
>
> Any thoughts?
>
> [1]:
> /* Get a more recent flush pointer. */
> if (!RecoveryInProgress())
> RecentFlushPtr = GetFlushRecPtr(NULL);
> else
> RecentFlushPtr = GetXLogReplayRecPtr(NULL);
>
> [2]:
> /* Update our idea of the currently flushed position. */
> else if (!RecoveryInProgress())
> RecentFlushPtr = GetFlushRecPtr(NULL);
> else
> RecentFlushPtr = GetXLogReplayRecPtr(NULL);
>

It seems to me that [2] alone could be sufficient.

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-03-01 11:04:32 Re: Volatile write caches on macOS and Windows, redux
Previous Message Bertrand Drouvot 2024-03-01 10:15:48 Missing LWLock protection in pgstat_reset_replslot()