Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYNZN-0004ZY-8s for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2013 22:03:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VYNZM-0003Ne-PJ for pgsql-bugs@arkaria.postgresql.org; Mon, 21 Oct 2013 22:03:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGWR-00039J-M2 for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:31:55 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGWI-0008Bt-C9 for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:31:55 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VYGWG-0006SZ-Tb for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:31:45 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VYGWB-00056v-Dj for pgsql-bugs@postgresql.org; Mon, 21 Oct 2013 14:31:39 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8543: Standby recovery use incorrect timeline to determine WAL length To: pgsql-bugs@postgresql.org From: alfonso.vicente@logos.com.uy Message-Id: Date: Mon, 21 Oct 2013 14:31:39 +0000 X-Pg-Spam-Score: -2.3 (--) 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: 8543 Logged by: Alfonso Vicente Email address: alfonso.vicente@logos.com.uy PostgreSQL version: 9.1.3 Operating system: OpenSUSE 11 Description: Environment: PostgreSQL 9.1.3 / OpenSUSE 11 The use case is a switchover and switchback test, using a standby cluster with Streaming Replication. We have 2 datacenters: main-site and backup-site The cluster in main-site has timeline ID 1, and we perform the switchover to backup-site without any trouble. When we execute the pg_ctl promote, the cluster sets the new timeline ID 2 (OK). But... we don't stop the cluster in main-site. So, the cluster in main-site continue to archive logs in /archlogs directory, and archives the WAL 00000001000000FE00000002 of 16MB. Immediately, we perform a backup in the backup-site, to prepare for switchback. The pg_stop_backup() force a WAL switch, and generate a WAL 00000002000000FE00000002 of 2MB. Then, the archive_command script perform the log shipping to the main-site and store the 00000002000000FE00000002 in the same /archlogs directory When we execute the pg_ctl promote in the main-site, the postgresql.log show the following error: 2013-10-19 22:39:59 UYST LOG: database system was shut down in recovery at 2013-10-19 21:47:07 UYST sh: /home/postgres/9.1/backups/archlogs/00000002.history.gz: No existe el fichero o el directorio 2013-10-19 22:39:59 UYST LOG: starting archive recovery 2013-10-19 22:39:59 UYST FATAL: archive file "00000002000000FE00000002" has wrong size: 2293760 instead of 16777216 2013-10-19 22:39:59 UYST LOG: startup process (PID 10636) exited with exit code 1 2013-10-19 22:39:59 UYST LOG: aborting startup due to startup process failure The WAL 00000002000000FE00000002 is of 2293760 bytes, this is not an error. Why PostgreSQL think WAL 00000002000000FE00000002 should be of 16MB ? ... I think the cause can be the WAL 00000001000000FE00000002 (timeline ID 1) stored in the /archlogs directory If we drop all the timeline ID 1 archived WALs, the failback executes succesfully There is an easy workaround, but please, confirm if this is a bug. The documentation says: "The default behavior of recovery is to recover along the same timeline that was current when the base backup was taken". The base backup in backup-site was timeline ID 2 Thanks in advance -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs