Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brnc7-0000P6-P3 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2016 14:56:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1brnc7-0005qc-8j for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2016 14:56:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1brnc6-0005pc-Eu for pgsql-hackers@postgresql.org; Wed, 05 Oct 2016 14:56:06 +0000 Received: from mout.gmx.net ([212.227.17.22]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.84_2) (envelope-from ) id 1brnc3-0000tW-8M for pgsql-hackers@postgresql.org; Wed, 05 Oct 2016 14:56:05 +0000 Received: from nighthawk.chemicalconnection.dyndns.org ([46.244.161.100]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0Me5Q2-1bXVZ33jFW-00PxwB; Wed, 05 Oct 2016 16:56:00 +0200 Received: from mbanck by nighthawk.chemicalconnection.dyndns.org with local (Exim 4.84) (envelope-from ) id 1brnZu-00060r-9n; Wed, 05 Oct 2016 16:53:50 +0200 Date: Wed, 5 Oct 2016 16:53:50 +0200 From: Michael Banck To: pgsql-hackers@postgresql.org Cc: Christoph Berg Subject: Re: pg_rewind hangs if --source-server is used and syncrep is enabled Message-ID: <20161005145349.GB12247@nighthawk.caipicrew.dd-dns.de> References: <20161005143938.GA12247@nighthawk.caipicrew.dd-dns.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161005143938.GA12247@nighthawk.caipicrew.dd-d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6KD1RCaccAX28iVjmrM6ZKzlC67ckXEQ0Xv77uWDkvB90E= X-Pg-Spam-Score: -5.2 (-----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Oct 05, 2016 at 04:39:39PM +0200, Michael Banck wrote: > if pg_rewind is told to fetch data via a libpq connection > (--source-server), synchronous replication is enabled and there is only > one sync standby (pilot error, but sill); pg_rewinding the old master > hangs at the CREATE TEMPORARY TABLE step (CREATE TABLE waiting for > X/XXXXXXXX). At least this happened to one of our clients while > evaluating pg_rewind. > > To the user, the last thing printed is "need to copy XXXX MB [...]". If > the user cancels the pg_rewind command with ^C, the backend keeps > hanging around even in --dry-run mode. That won't hurt too much as it > does not seem to block future pg_rewind runs after synchronous_commit > has been set to a different value, but looks surprising to me. > > Not sure whether pg_rewind could error out gracefully without hanging in > this case, My colleague Christoph Berg pointed out that pg_rewind could just set synchronous_commit = local before creating the temporary table, which indeed works, proof-of-concept patch attached Michael -- Michael Banck Projektleiter / Senior Berater Tel.: +49 2166 9901-171 Fax: +49 2166 9901-100 Email: michael.banck@credativ.de credativ GmbH, HRB Mönchengladbach 12080 USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer --Qxx1br4bt0+wmkIi Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="pg_rewind.diff" diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index 9239009..a5cb426 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -406,7 +406,7 @@ libpq_executeFileMap(filemap_t *map) * First create a temporary table, and load it with the blocks that we * need to fetch. */ - sql = "CREATE TEMPORARY TABLE fetchchunks(path text, begin int4, len int4);"; + sql = "SET synchronous_commit = local; CREATE TEMPORARY TABLE fetchchunks(path text, begin int4, len int4);"; res = PQexec(conn, sql); if (PQresultStatus(res) != PGRES_COMMAND_OK) --Qxx1br4bt0+wmkIi Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers --Qxx1br4bt0+wmkIi--