Thread: Waiting for archive to complete

Waiting for archive to complete

From
"Simon Riggs"
Date:
A number of people have complained that it is possible to make a base
backup and then shutdown the server before the last xlog file has been
archived. Others say they would like to be able to make a backup and
know it is complete.

Making the archiver continue while the file is archived can cause
problems when we do a restart, which has prevented some possible
solutions.

A simple solution is to introduce a new function:

pg_archive_wait(integer maxwait);
maxwait = 0 means wait forever, otherwise time measured in seconds.

This will get the current xlog position and wait for all files prior to
that point to be shown as archive done. Code to do this is very similar
to XLogArchiveCheckDone() in a wait loop, testing once per second.

Simple enough for this release?

Comments?

--  Simon Riggs              EnterpriseDB   http://www.enterprisedb.com




libpq protocol version 2

From
"Chuck McDevitt"
Date:
Is protocol version 2 still used by anything?  Is there a reason why
this is still supported?



Re: Waiting for archive to complete

From
Tom Lane
Date:
"Simon Riggs" <simon@2ndquadrant.com> writes:
> A simple solution is to introduce a new function:

> pg_archive_wait(integer maxwait);
> maxwait = 0 means wait forever, otherwise time measured in seconds.

maxwait is redundant; people who want a timeout should use
statement_timeout.

> This will get the current xlog position and wait for all files prior to
> that point to be shown as archive done.

Including the current one?  If so, it'll wait longer than necessary;
if not, ISTM it's a gotcha waiting to trap the unwary.

Perhaps better is a variant of pg_stop_backup that includes a wait for
the pushed-out xlog segment to be archived.
        regards, tom lane


Re: libpq protocol version 2

From
Tom Lane
Date:
"Chuck McDevitt" <cmcdevitt@greenplum.com> writes:
> Is protocol version 2 still used by anything?  Is there a reason why
> this is still supported?

Even if you're not concerned about breaking old clients, I believe that
the JDBC folk are still giving out advice to use ProtocolVersion=2 as
a workaround for various arcane portability issues for Java clients.

In any case, AFAICS there's no very good reason to remove it.  The
amount of backend code involved is pretty trivial.
        regards, tom lane


Re: Waiting for archive to complete

From
"Simon Riggs"
Date:
On Mon, 2007-06-25 at 18:14 -0400, Tom Lane wrote:
> "Simon Riggs" <simon@2ndquadrant.com> writes:
> > A simple solution is to introduce a new function:
> 
> > pg_archive_wait(integer maxwait);
> > maxwait = 0 means wait forever, otherwise time measured in seconds.
> 
> maxwait is redundant; people who want a timeout should use
> statement_timeout.

> > This will get the current xlog position and wait for all files prior to
> > that point to be shown as archive done.
> 
> Including the current one?  If so, it'll wait longer than necessary;
> if not, ISTM it's a gotcha waiting to trap the unwary.
> 
> Perhaps better is a variant of pg_stop_backup that includes a wait for
> the pushed-out xlog segment to be archived.

OK, will do.


For a timeout, I think you are suggesting this:

SET statement_timeout = X;
pg_stop_backup_wait();

So no need to include a function parameter for the wait time?
If thats what you are thinking, OK to that also.

--  Simon Riggs              EnterpriseDB   http://www.enterprisedb.com