Corner case in xlog stuff: what happens exactly at a seg boundary?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Corner case in xlog stuff: what happens exactly at a seg boundary?
Date: 2006-08-06 01:20:05
Message-ID: 15952.1154827205@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message andrew 2006-08-06 01:41:39 Re: 8.2 features status
Previous Message Ron Mayer 2006-08-05 22:55:17 Re: 8.2 features status