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

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

From: Jeff Frost <jeff(at)frostconsultingllc(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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 17:47:12
Message-ID: Pine.LNX.4.64.0604151029490.9581@discord.dyndns.org (view raw or flat)
Thread:
Lists: pgsql-docspgsql-patches
On Sat, 15 Apr 2006, Bruce Momjian wrote:

>> ls -tp /pg_xlog/ | grep -v "backup\|/" | head -1
>>
>> which seems to work fairly well.  Looks like that thread is here:
>>
>> http://archives.postgresql.org/pgsql-admin/2005-10/msg00173.php
>
> What does the -p and \| pipe check do?  We don't have named pipes in
> that directory, do we?
>
> Also, what happens if the log switch happens, and some data change is
> written to the new WAL file in the first second, but nothing happens to
> the database after that for a minute?  Your test would still show the
> old log file.

The -p shows forward slashes after directories and the \| acts as an or and 
the / following that just lets us filter directories out.  I added that 
because I used to find the archive_status directory winning the ls -t from 
time to time.

Now about your what if question.  I don't know if there is a way to get past 
the mtime granularity.  If I understand your scenario correctly, you indicate 
that the previous log is written to and the new log is switched in during the 
same mtime second.  I did a quick test on linux to see how that operates:

touch AA AB

This yields both files with the same mtime.

ls -tp |head -1

yields AA as you suggested it would.

The following seems to do the trick if we can rely on alphabetizing to 
properly decide the winner of a tie:

ls -tp | head -2 | sort -r | head -1

So, with my previous example, it would look like:

ls -tp /pg_xlog/ | grep -v "backup\|/" | head -2 | sort -r | head -1



-- 
Jeff Frost, Owner 	<jeff(at)frostconsultingllc(dot)com>
Frost Consulting, LLC 	http://www.frostconsultingllc.com/
Phone: 650-780-7908	FAX: 650-649-1954

In response to

Responses

pgsql-docs by date

Next:From: Tom LaneDate: 2006-04-15 17:56:32
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Previous:From: Bruce MomjianDate: 2006-04-15 17:26:57
Subject: Re: Proposed doc-patch: Identifying the Current WAL file

pgsql-patches by date

Next:From: Tom LaneDate: 2006-04-15 17:56:32
Subject: Re: Proposed doc-patch: Identifying the Current WAL file
Previous:From: Bruce MomjianDate: 2006-04-15 17:26:57
Subject: Re: Proposed doc-patch: Identifying the Current WAL file

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