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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

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



On Sat, 15 Apr 2006, Tom Lane wrote:

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
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.

You seem to be assuming that ls will sort on the basis of the truncated
mtime that it displays, which is not the actual behavior of ls AFAIK.

I believe you're correct, at least with the ls I have here on my linux system. I created two files quickly with touch. Here is the stat output:

  File: `AA'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 2736263     Links: 1
Access: (0644/-rw-r--r--)  Uid: (   26/postgres)   Gid: (   26/postgres)
Access: 2006-04-15 11:02:46.000000000 -0700
Modify: 2006-04-15 11:02:46.000000000 -0700
Change: 2006-04-15 11:02:46.000000000 -0700
  File: `AB'
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 2736264     Links: 1
Access: (0644/-rw-r--r--)  Uid: (   26/postgres)   Gid: (   26/postgres)
Access: 2006-04-15 11:02:48.000000000 -0700
Modify: 2006-04-15 11:02:48.000000000 -0700
Change: 2006-04-15 11:02:48.000000000 -0700

ls -t | head -1
AB

So it looks like the original was correct all along, but with Tom's regex it's much cleaner. Too bad grep's regex engine doesn't support {24}.

I'll change all my scripts to use the following:

ls -t /pg_xlog/ | grep '^[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]$' | head -1

Thanks Tom!

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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group