Skip site navigation (1) Skip section navigation (2)

Re: Proposed doc-patch: Identifying the Current WAL file

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Richard Huxton <dev(at)archonet(dot)com>, pgsql-docs(at)postgresql(dot)org
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Date: 2006-04-15 16:24:45
Message-ID: 200604151624.k3FGOj525540@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-docspgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Richard Huxton wrote:
> >> To identify the current, partially-filled WAL segment, sort first by
> >> mtime and second by file name. That is, take the latest mtime among the
> >> properly-named files, breaking ties by taking the higher filename.
> 
> > I am confused by this.  Why do both mtime and file name need to be
> > checked?
> 
> Because recycled WAL segments are renamed to have higher file names than
> the currently-in-use segment.  So you can't depend on file name first.
> However, shortly after a segment switch two WAL segments could have the
> same mtime (to within whatever the mtime granularity is, typ. 1 second).
> 
> The proposed rule should be OK as long as checkpoints (and ensuing
> renames) can't occur oftener than the mtime granularity.  If you're
> checkpointing more than once a second, well, you need help ...

I am trying to figure out how this could even be done in a shell script.
'ls -lt' is going to show:

	-rw-r--r--  1 root  postgres  0 Apr 15 11:56 x1
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56 x2
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56 x3

but this might be with second resolution:

	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:47 x1
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:47 x2
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:34 x3

or it might be:

	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:47 x1
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:34 x2
	-rw-r--r--  1 root  postgres  0 Apr 15 11:56:25 x3

In the first case, x2 is current, having be just switched to from x1,
while in the second case, x1 is current.  In BSD, you can use ls -ltT to
see the seconds, but in Linux it is something different, and I am sure
there are some operating systems that don't allow you to see the seconds
at all.  What general command-line solution can we propose for this
process?  And if we can't provide one, should we supply an SQL function
to return the current WAL name?

-- 
  Bruce Momjian   http://candle.pha.pa.us
  EnterpriseDB    http://www.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

Responses

pgsql-docs by date

Next:From: Tom LaneDate: 2006-04-15 16:40:11
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Previous:From: Tom LaneDate: 2006-04-14 16:07:15
Subject: Re: Proposed doc-patch: Identifying the Current WAL file

pgsql-patches by date

Next:From: Tom LaneDate: 2006-04-15 16:40:11
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Previous:From: Tom LaneDate: 2006-04-15 16:12:53
Subject: Re: [PATCH] Reduce noise from tsort

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group