Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9FR-0003QX-1r for pgsql-general@arkaria.postgresql.org; Mon, 11 Feb 2019 10:55:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gt9FP-0006er-QL for pgsql-general@arkaria.postgresql.org; Mon, 11 Feb 2019 10:55:35 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9FP-0006e9-E3 for pgsql-general@lists.postgresql.org; Mon, 11 Feb 2019 10:55:35 +0000 Received: from mx2.mailbox.org ([80.241.60.215]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gt9FM-0006Vr-Bo for pgsql-general@lists.postgresql.org; Mon, 11 Feb 2019 10:55:34 +0000 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 86434A173D; Mon, 11 Feb 2019 11:55:28 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp1.mailbox.org ([80.241.60.240]) by gerste.heinlein-support.de (gerste.heinlein-support.de [91.198.250.173]) (amavisd-new, port 10030) with ESMTP id jEnc6klVzFGk; Mon, 11 Feb 2019 11:55:25 +0100 (CET) Message-ID: <950236c827942575381949675e8ad709a38ca771.camel@cybertec.at> Subject: Re: Promote replica before being able to accept connections From: Laurenz Albe To: =?ISO-8859-1?Q?Mart=EDn_Fern=E1ndez?= , "pgsql-generallists.postgresql.org" Date: Mon, 11 Feb 2019 11:55:24 +0100 In-Reply-To: References: Organization: Cybertec Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Martín Fernández wrote: > We have a 9.2 pg cluster and we are in the process of rebuilding a master database in our staging environment. > In order to achieve the latter goal, we are restoring our staging database using pg_basebackup against one > of our production replicas. > > pg_basebackup has completed and the staging database is configured in hot_standby mode, recovering from > the WAL archive. The database has not reached the point were it can accept connections yet, still > investing WAL files. > > What we are not sure about is, can we attempt promoting the database as a master instance before it can > accept connections ? We don´t care if the staging database is a few days behind the production environment, > that is something acceptable in our use case, we just want to promote it as soon as we can. The earliest time to which you can recover is the end of the backup. Until recovery has reached that point, the database is not consistent (that's the "consistent recovery state" the logs are talking about). You cannot connect to the recovering database or promote it before you reach that point, so you have to wait until you can connectio to the database before you can promote it. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com