Re: PATCH: add pg_current_xlog_flush_location function - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: PATCH: add pg_current_xlog_flush_location function
Date
Msg-id 5692D447.2040300@2ndquadrant.com
Whole thread Raw
In response to Re: PATCH: add pg_current_xlog_flush_location function  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: PATCH: add pg_current_xlog_flush_location function  (Amit Kapila <amit.kapila16@gmail.com>)
List pgsql-hackers
Hi,

On 12/13/2015 08:38 PM, Tomas Vondra wrote:
> Hi,
>
> On 12/13/2015 06:13 AM, Amit Kapila wrote:
>  >
>> ...
>  >
>> Is there a reason why you can't use existing function
>> GetFlushRecPtr() in xlog.c?
>
> No, not really. I think I somehow missed that function when writing
> the initial version of the patch. Will fix in v2 of the patch.

Hmm, so I've been looking at this, and I've realized that I've written 
it like this because that's pretty much what pg_current_xlog_location() 
does. It calls GetXLogWriteRecPtr which does this:

/* * Get latest WAL write pointer */
XLogRecPtr
GetXLogWriteRecPtr(void)
{SpinLockAcquire(&XLogCtl->info_lck);LogwrtResult = XLogCtl->LogwrtResult;SpinLockRelease(&XLogCtl->info_lck);
return LogwrtResult.Write;
}

so the patch does the same thing, except that I've returned "Flush".

OTOH GetFlushRecPtr does this:

XLogRecPtr
GetFlushRecPtr(void)
{XLogRecPtr    recptr;
SpinLockAcquire(&XLogCtl->info_lck);recptr = XLogCtl->LogwrtResult.Flush;SpinLockRelease(&XLogCtl->info_lck);
return recptr;
}

i.e. it does not update LogwrtResult, the local private copy. Not sure 
what's appropriate here ...

regards

--
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: ExecGather() + nworkers
Next
From: "Dickson S. Guedes"
Date:
Subject: Apparently deprecated code in planner.c