Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y7Tvp-0007we-Iv for pgsql-committers@arkaria.postgresql.org; Sat, 03 Jan 2015 19:00:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Y7Tvn-0004G4-Og for pgsql-committers@arkaria.postgresql.org; Sat, 03 Jan 2015 19:00:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Y7Tvl-0004FJ-Oq for pgsql-committers@postgresql.org; Sat, 03 Jan 2015 19:00:09 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Y7Tvc-0003ue-Jv for pgsql-committers@postgresql.org; Sat, 03 Jan 2015 19:00:08 +0000 Received: from intern.anarazel.de (p54895B8F.dip0.t-ipconnect.de [84.137.91.143]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 96A6D460001; Sat, 3 Jan 2015 19:59:57 +0100 (CET) Date: Sat, 3 Jan 2015 19:59:57 +0100 From: Andres Freund To: Heikki Linnakangas Cc: pgsql-committers@postgresql.org Subject: Re: pgsql: Change how first WAL segment on new timeline after promotion is Message-ID: <20150103185957.GB15316@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="hHWLQfXTYDoKhP50" Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-committers Precedence: bulk Sender: pgsql-committers-owner@postgresql.org --hHWLQfXTYDoKhP50 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Heikki, While writing a test script for http://archives.postgresql.org/message-id/20141205002854.GE21964%40awork2.anarazel.de I noticed that this commit broke starting a pg_basebackup -X * without a recovery.conf present. Which might not be the best idea, but imo is a perfectly valid thing to do. To me the changes to StartupXLOG() in that commit look a bit bogus. The new startLogSegNo is initialized to XLByteToSeg(EndOfLog)? Which points to the end of the record +1? Which thus isn't guaranteed to exist as a segment (e.g. never if the last record was a XLOG_SWITCH). Did you perhaps intend to use XLogFileInit(use_existing = true) instead of XLogFileOpen()? That works for me. I've attached my preliminary testscript (note it's really not that interesting at this point) that reliably reproduces the problem for me. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --hHWLQfXTYDoKhP50 Content-Type: application/x-sh Content-Disposition: attachment; filename="basebackup_test.sh" Content-Transfer-Encoding: quoted-printable #!env bash=0A= =0A= set -e=0A= #set -x=0A= # show used binaries=0A= type pg_ctl=0A= type pg_basebackup=0A= type initdb=0A= type pgbench=0A= =0A= export PGHOST=3D/tmp/=0A= export PGUSER=3Dpostgres=0A= =0A= #cleanup=0A= rm -rf /tmp/pgbt-master=0A= rm -rf /tmp/pgbt-standby=0A= rm -rf /tmp/pgbt-standby-standby=0A= =0A= # create primary data directory=0A= initdb -U postgres /tmp/pgbt-master > /dev/null=0A= mkdir /tmp/pgbt-master/archive=0A= =0A= cat > /tmp/pgbt-master/pg_hba.conf <