pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-docs@postgresql.org
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Date: Sat, 15 Apr 2006 12:24:45 -0400 (EDT)
Message-ID: <200604151624.k3FGOj525540@candle.pha.pa.us> (raw)
In-Reply-To: <9932.1145030835@sss.pgh.pa.us>

Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.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. +



view thread (27+ messages)  latest in thread

Message-ID: <200604151624.k3FGOj525540@candle.pha.pa.us>
Permalink:  ../200604151624.k3FGOj525540@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200604151624.k3FGOj525540@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: pgman@candle.pha.pa.us, tgl@sss.pgh.pa.us, dev@archonet.com
  Subject: Re: Proposed doc-patch: Identifying the Current WAL file
  In-Reply-To: <200604151624.k3FGOj525540@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox