Corner case in xlog stuff: what happens exactly at a seg boundary? - Mailing list pgsql-hackers

From Tom Lane
Subject Corner case in xlog stuff: what happens exactly at a seg boundary?
Date
Msg-id 15952.1154827205@sss.pgh.pa.us
Whole thread Raw
Responses Re: Corner case in xlog stuff: what happens exactly at a seg boundary?
List pgsql-hackers
I'm noticing that if the current XLOG offset is exactly at a segment
boundary (ie, the last wal record just filled the segment) then the
various user-level functions return offsets that could be interpreted
as the start of the next segment, eg

regression=# select pg_switch_xlog();pg_switch_xlog 
----------------0/14000000
(1 row)

regression=# select pg_xlogfile_from_wal_location(pg_switch_xlog());pg_xlogfile_from_wal_location 
-------------------------------000000010000000000000014
(1 row)

regression=# 

Actually, the last segment file that needs to be archived in this
scenario is 0013; it's possible 0014 doesn't even exist yet.

Rather than expecting user-level scripts to get this corner case
right, I suggest that we ought to modify pg_stop_backup and friends
so that what they return is the last used byte address of WAL, not
the first unused byte address as now.  Then, blindly extracting
the filename will give the right answer about which file to archive,
even in the boundary case.

Comments?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Ron Mayer
Date:
Subject: Re: 8.2 features status
Next
From: andrew@dunslane.net
Date:
Subject: Re: 8.2 features status