Обсуждение: odd pg_start_backup() issue

Поиск
Список
Период
Сортировка

odd pg_start_backup() issue

От
CS DBA
Дата:
Hi All;

I'm setting up PITR based backups on a production db server.
When the script runs the pg_start_backup it takes forever, like 30minutes+

I can run a checkpoint while waiting for it to complete and it finishes
almost immediately

For now we're executing the start backup like this (in the automated
base backup script:
echo "checkpoint; select pg_start_backup('$tag'); checkpoint;" | psql

we tried it like this and id did not help:
echo "checkpoint; select pg_start_backup('$tag');" | psql
so we added the checkpoint after the pg_start_backup command

Next I'll try this (I assume the first checkpoint is simply un-needed):
echo "select pg_start_backup('$tag'); checkpoint;" | psql

However, this  works well and the pg_start_backup finishes in less than
1minute,
but if I leave the checkpoint command(s) out then we're back to
30minutes or more for the pg_start_backup...

We're running version 9.2.4 on a Centos 6 server

Thoughts?

Thanks in advance


Re: odd pg_start_backup() issue

От
Sergey Konoplev
Дата:
On Fri, Jan 31, 2014 at 9:55 AM, CS DBA <cs_dba@consistentstate.com> wrote:
[...]
> Next I'll try this (I assume the first checkpoint is simply un-needed):
> echo "select pg_start_backup('$tag'); checkpoint;" | psql
> However, this  works well and the pg_start_backup finishes in less than
> 1minute,

I wonder how it helped at all, because it should not. Probably it was
some kind of a coincidence.

[...]
> Thoughts?

The note below is from the docs for pg_start_backup().

"pg_start_backup(label text [, fast boolean ])
...
There is an optional second parameter of type boolean. If true, it
specifies executing pg_start_backup as quickly as possible. This
forces an immediate checkpoint which will cause a spike in I/O
operations, slowing any concurrently executing queries."

So all you need is to specify 'true' as a second parameter.

select pg_start_backup('$tag', true)

--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
gray.ru@gmail.com