Re: PATCH: add pg_current_xlog_flush_location function

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PATCH: add pg_current_xlog_flush_location function
Date: 2016-01-10 21:59:35
Message-ID: 5692D447.2040300@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dickson S. Guedes 2016-01-10 22:28:16 Apparently deprecated code in planner.c
Previous Message Peter Geoghegan 2016-01-10 21:57:44 Re: ExecGather() + nworkers