BUG #2488: backup history file is archived doubly

Started by Fujii Masaoalmost 20 years ago2 messagesbugs
Jump to latest
#1Fujii Masao
masao.fujii@gmail.com

The following bug has been logged online:

Bug reference: 2488
Logged by: Masao Fujii
Email address: fujii.masao@oss.ntt.co.jp
PostgreSQL version: 8.1.4
Operating system: Fedora Core 5
Description: backup history file is archived doubly
Details:

Hi, My name is Masao Fujii.

I found an error that backup history file is archived doubly.

postgresql.conf that I changed from the default is as follow.

archive_command = 'cp %p /home/postgres/pg_archive/%f'

The sequence of steps to reproduce the problem is as follow.
NOTE: it is very rare that the problem reproduces.

---
[postgres@excalibur pgsql-8.1.4]$ bin/psql sampledb
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit

sampledb=# SELECT pg_start_backup('test1');
pg_start_backup
-----------------
0/33ACB4
(1 row)

sampledb=# SELECT pg_stop_backup();
pg_stop_backup
----------------
0/33ACF8
(1 row)
---

The server log is as follow.

---
[postgres@excalibur pgsql-8.1.4]$ bin/postmaster -D ./data
LOG: database system was shut down at 2006-06-21 21:40:26 JST
LOG: checkpoint record is at 0/33A6AC
LOG: redo record is at 0/33A6AC; undo record is at 0/0; shutdown TRUE
LOG: next transaction ID: 565; next OID: 10794
LOG: next MultiXactId: 1; next MultiXactOffset: 0
LOG: database system is ready
LOG: transaction ID wrap limit is 2147484146, limited by database
"postgres"
LOG: transaction ID wrap limit is 2147484146, limited by database
"postgres"
LOG: archived transaction log file
"000000010000000000000000.0033ACB4.backup"
LOG: archived transaction log file
"000000010000000000000000.0033ACB4.backup"
---

The cause of the problem is that pg_stop_backup creates two *.ready files.
One file is created by pg_stop_backup > RemoveOldBackupHistory >
XLogArchiveIsDone > XLogArchiveNotify.
Another is created by pg_stop_backup > XLogArchiveNotify.

The problem occurs if archiver process executes archive_command during the
creation of two files.

I'll be pleased if you cope with the trouble.

Thanks in advance,

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Fujii Masao (#1)
Re: BUG #2488: backup history file is archived doubly

"Masao Fujii" <fujii.masao@oss.ntt.co.jp> writes:

The cause of the problem is that pg_stop_backup creates two *.ready files.
One file is created by pg_stop_backup > RemoveOldBackupHistory >
XLogArchiveIsDone > XLogArchiveNotify.
Another is created by pg_stop_backup > XLogArchiveNotify.

Oooh, good catch. The cleanest solution would be to modify
RemoveOldBackupHistory so that it explicitly skips the current entry.
But I'm strongly tempted to just remove the code in pg_stop_backup,
and document that RemoveOldBackupHistory gets the job done (perhaps
renaming it).

regards, tom lane