Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zfg4o-00012V-29 for pgsql-bugs@arkaria.postgresql.org; Sat, 26 Sep 2015 03:23:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zfg4n-0008NU-1g for pgsql-bugs@arkaria.postgresql.org; Sat, 26 Sep 2015 03:23:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1Zfg4m-0008NO-Nv for pgsql-bugs@postgresql.org; Sat, 26 Sep 2015 03:23:04 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1Zfg4k-0004MI-Bf for pgsql-bugs@postgresql.org; Sat, 26 Sep 2015 03:23:04 +0000 MIME-Version: 1.0 Subject: BUG #13644: 2xRecovery without new writes, causes archiving failure To: pgsql-bugs@postgresql.org From: amir.rohan@mail.com Date: Sat, 26 Sep 2015 03:22:47 +0000 Message-ID: <20150926032247.3022.98224@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.9 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13644 Logged by: Amir Rohan Email address: amir.rohan@mail.com PostgreSQL version: 9.5alpha2 Operating system: Linux Description: Summary: recovering from backup, when the archive directory is shared between primary/new primary/newnew primary, each shutting down before the next is started, causes the last primary to fail during archiving, because it tries to overwrite existing files. Walkthrough: 1. create a server, with wal_level=archive and archive_command copying files to ARCHIVE_DIR 2. load some data 3. create a tar backup with pg_basebackup --format=t -x 4. shut down server with `pg_ctl stop` 5. delete the PGDATA directory, and replace it by untarring the backup file place a recovery.conf with only "recovery_target_timeline='latest'" and a restore_command set to copy from ARCHIVE_DIR. 6. use the same postgresql.conf file, archiving to ARCHIVE_DIR again. 7. start the server, recovery completes. 8. a new timeline is created: # ls -l archive/ -rw-------. 1 postgres postgres 16777216 Sep 26 06:07 /var/lib/pgsql/archive/000000010000000000000001 -rw-------. 1 postgres postgres 16777216 Sep 26 06:07 /var/lib/pgsql/archive/000000010000000000000002 -rw-------. 1 postgres postgres 302 Sep 26 06:07 /var/lib/pgsql/archive/000000010000000000000002.00000028.backup -rw-------. 1 postgres postgres 41 Sep 26 06:07 /var/lib/pgsql/archive/00000002.history 8. without writing any data, shut down the server and repeat 5-7 9. no new timeline appears in ARCHIVE_DIR: # ls -l archive/ -rw-------. 1 postgres postgres 16777216 Sep 26 06:10 000000010000000000000001 -rw-------. 1 postgres postgres 16777216 Sep 26 06:10 000000010000000000000002 -rw-------. 1 postgres postgres 302 Sep 26 06:10 000000010000000000000002.00000028.backup -rw-------. 1 postgres postgres 16777216 Sep 26 06:10 000000020000000000000002 -rw-------. 1 postgres postgres 16777216 Sep 26 06:10 000000020000000000000003 -rw-------. 1 postgres postgres 41 Sep 26 06:10 00000002.history and the log fills up with: DETAIL: The failed archive command was: test ! -f /var/lib/pgsql/archive/00000002.history && cp pg_xlog/00000002.history /var/lib/pgsql/archive/00000002.history I expected the last server to create timeline 3, but it looks as if it thinks it's timeline2. While in terms of data it's at the same WAL point, in terms of events, it should be at timeline 3. That's what I make of it anyway. I happen to be testing with 9.5, but I have no reason to think this is particular to it. Amir -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs