Re: How to find the latest (partial) WAL file

Lists: pgsql-general
From: "Just Someone" <just(dot)some(at)gmail(dot)com>
To: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: How to find the latest (partial) WAL file
Date: 2006-04-10 22:41:23
Message-ID: 36932f270604101541h588faeaanc5d294a27dda50a2@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

What is the best way to find the latest partial WAL file?

Based on my tests, using the mtime isn't 100% accurate, as if a
pg_start_backup/pg_stop_backup() operation is run, the .backup file
created might be newer than the last WAL file. It also seems that the
WAL file related to the backup is being updated according to the
mtime. Using a file name is also not 100% accurate, as it seems that
postgres will recycle the archived files, giving them "future" names
before they are used, leaving the directory with files that are older
by name, but not yet with relevant data.

Is there a way to discover what is the real current WAL file? I've
read that one of the todo's for 8.2 is to handle partial files
archiving, but I'm looking for something I can use now.

Regards,

Guy.

--
Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Just Someone" <just(dot)some(at)gmail(dot)com>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find the latest (partial) WAL file
Date: 2006-04-10 23:24:39
Message-ID: 1681.1144711479@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"Just Someone" <just(dot)some(at)gmail(dot)com> writes:
> Is there a way to discover what is the real current WAL file?

If you sort first by mtime and second by file name you should find the
right one in all cases, ie, take the latest mtime among the
properly-named files, breaking ties by taking the higher filename.

It'd probably be better if we had a function to report this, but
you can get along without one.

regards, tom lane


From: "Just Someone" <just(dot)some(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find the latest (partial) WAL file
Date: 2006-04-11 00:10:20
Message-ID: 36932f270604101710t7a401676ue118a3d11e8a9060@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi Tom,

> If you sort first by mtime and second by file name you should find the
> right one in all cases, ie, take the latest mtime among the
> properly-named files, breaking ties by taking the higher filename.
>
> It'd probably be better if we had a function to report this, but
> you can get along without one.

For now I'm using ls with grep:
LAST_WAL=$(/bin/ls -t1p $WAL_DIR | /bin/grep -v / | /bin/grep -v
backup | /usr/bin/head -1)

But a pg function for that would be great.

Regards,

Guy Naor.

--
Family management on rails: http://www.famundo.com - coming soon!
My development related blog: http://devblog.famundo.com


From: "Thomas F(dot) O'Connell" <tfo(at)sitening(dot)com>
To: Postgresql-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to find the latest (partial) WAL file
Date: 2006-04-11 01:08:30
Message-ID: 6D547613-6F66-46A9-BA97-8688171A8723@sitening.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general


On Apr 10, 2006, at 6:24 PM, Tom Lane wrote:

> "Just Someone" <just(dot)some(at)gmail(dot)com> writes:
>> Is there a way to discover what is the real current WAL file?
>
> If you sort first by mtime and second by file name you should find the
> right one in all cases, ie, take the latest mtime among the
> properly-named files, breaking ties by taking the higher filename.
>
> It'd probably be better if we had a function to report this, but
> you can get along without one.

Seems like a natural candidate for a TODO item. I'm not familiar with
the relevant internals, but on the surface it seems like it might
even be a % item?

--
Thomas F. O'Connell
Database Architecture and Programming
Co-Founder
Sitening, LLC

http://www.sitening.com/
3004 B Poston Avenue
Nashville, TN 37203-1314
615-260-0005 (cell)
615-469-5150 (office)
615-469-5151 (fax)