Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgUei-0007vf-Hz for pgsql-committers@arkaria.postgresql.org; Sat, 12 Aug 2017 11:32:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dgUeh-0005Li-6G for pgsql-committers@arkaria.postgresql.org; Sat, 12 Aug 2017 11:32:35 +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 1dgUeg-0005K3-6i for pgsql-committers@postgresql.org; Sat, 12 Aug 2017 11:32:34 +0000 Received: from mail-wr0-x22e.google.com ([2a00:1450:400c:c0c::22e]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1dgUeb-00008C-8f for pgsql-committers@postgresql.org; Sat, 12 Aug 2017 11:32:32 +0000 Received: by mail-wr0-x22e.google.com with SMTP id g28so2023097wrg.1 for ; Sat, 12 Aug 2017 04:32:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=2uyTiSsYSl7rB5hHa8BIjZfxZI9rRM64kuYj8hy6x28=; b=YydCt7v0FvpEvb/1AYHyw82tZDAgoOIyy09OkuWaMekCIytvIPXr+Y3vqHzvS0C6Gd 19NFwzMCiLw1qHx5LoogTKuxg+AMFM/iCs435QI9ryKknRaTd1YTpxLt91LlgsCA2Xhz kXr2k/qbDPpB4rrL8ozUrSRpBaj6ePjB5Gx9OAZl7bXfjZxpCTiNSEhK98mkcjyrUtjd hBpnT1CtNVYBJMST32HSQqnlZW4IKZhzJNl3N5BcyUqKm9alJtwYLAGYCERxdg3FFgs9 w+ngD1fD10laXVENjD/temgv0OokfeHvAVv5GIQ2dxk81d+PFPZAzYV5LqAeL2LLI1G7 FyJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=2uyTiSsYSl7rB5hHa8BIjZfxZI9rRM64kuYj8hy6x28=; b=kWla17T2jfIdtJnS7hV9RYkGEGxKJuhppP9sf/fr+GTQAG/RXAA8LnR/rZqoL0dOVm TiMF7dCLuhUAOdvWoZm1N8jdNOVK1/o2UMmuKu5qjdsajcSgqwmJr1O1bUYj/1EPiMnp B7z1FddPlRFaJXo/nNQsTOYc//H6S/Qg3pCYbGr+lXEvQ/lXxrYqGge3ob+iday44dFQ Bhp42eu3I59Zci1Xvds4G5DMx9S+o8+C+oJSXH9LkpCa4+e+gWr9uCWSXJ2hnsuFem7S 4hYYKO+pMhJQFtDqPc27lrlyXmyj/DQaBmEbqzkubbcKk4IPako2rfzK+gQDTigIcepg 1klQ== X-Gm-Message-State: AHYfb5iNcsu5ItuoDpxIMSl5fW7Ht5UEAnYTh7e80qAkLL7VKxxpMzIJ i1HjQlq6BXWckHrb X-Received: by 10.223.166.184 with SMTP id t53mr14919453wrc.265.1502537546513; Sat, 12 Aug 2017 04:32:26 -0700 (PDT) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id p68sm4254852wmf.0.2017.08.12.04.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Aug 2017 04:32:25 -0700 (PDT) Subject: Re: pgsql: Don't force-assign transaction id when exporting a snapshot. To: Andres Freund , pgsql-committers@postgresql.org References: Cc: PostgreSQL-development From: Petr Jelinek Message-ID: <7aed5039-7bc5-764b-b6d5-114d835f1e9a@2ndquadrant.com> Date: Sat, 12 Aug 2017 13:32:24 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------00B51D7A1F9466201D27E5AD" Content-Language: en-US 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 This is a multi-part message in MIME format. --------------00B51D7A1F9466201D27E5AD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 14/06/17 20:57, Andres Freund wrote: > Don't force-assign transaction id when exporting a snapshot. > > Previously we required every exported transaction to have an xid > assigned. That was used to check that the exporting transaction is > still running, which in turn is needed to guarantee that that > necessary rows haven't been removed in between exporting and importing > the snapshot. > > The exported xid caused unnecessary problems with logical decoding, > because slot creation has to wait for all concurrent xid to finish, > which in turn serializes concurrent slot creation. It also > prohibited snapshots to be exported on hot-standby replicas. > > Instead export the virtual transactionid, which avoids the unnecessary > serialization and the inability to export snapshots on standbys. This > changes the file name of the exported snapshot, but since we never > documented what that one means, that seems ok. > This commit has side effect that it makes it possible to export snapshots on the standbys. This makes it possible to do pg_dump -j on standby with consistent snapshot. Here is one line patch (+ doc update) which allows doing that when pg_dumping from PG10+. I also wonder if it should be mentioned in release notes. If the attached patch would make it into PG10 it would be no brainer to mention it as feature under pg_dump section, but exporting snapshots alone I am not sure about. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services --------------00B51D7A1F9466201D27E5AD Content-Type: text/x-patch; name="0001-Allow-pg_dump-j-on-standby-when-dumping-from-PG10.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-Allow-pg_dump-j-on-standby-when-dumping-from-PG10.patch" =46rom e2bca9b5271dbf29e5ab68d99c409c4f7dd752db Mon Sep 17 00:00:00 2001 From: Petr Jelinek Date: Sat, 12 Aug 2017 13:16:48 +0200 Subject: [PATCH] Allow pg_dump -j on standby when dumping from PG10+ PG10 adds support for exporting snapthots on standby, allow pg_dump to use this feature when consistent parallel dump has been requested. --- doc/src/sgml/ref/pg_dump.sgml | 18 ++++++++++-------- src/bin/pg_dump/pg_dump.c | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml index bafa031..3c088f3 100644 --- a/doc/src/sgml/ref/pg_dump.sgml +++ b/doc/src/sgml/ref/pg_dump.sgml @@ -337,14 +337,16 @@ PostgreSQL documentation but to abort the dump. - For a consistent backup, the database server needs to support sync= hronized snapshots, - a feature that was introduced in PostgreSQL 9.2. With this - feature, database clients can ensure they see the same data set ev= en though they use - different connections. pg_dump -j uses multiple= database - connections; it connects to the database once with the master proc= ess and - once again for each worker job. Without the synchronized snapshot = feature, the - different worker jobs wouldn't be guaranteed to see the same data = in each connection, - which could lead to an inconsistent backup. + For a consistent backup, the database server needs to support + synchronized snapshots, a feature that was introduced in + PostgreSQL 9.2 for primary servers and = 10 + for standbys. With this feature, database clients can ensure they = see + the same data set even though they use different connections. + pg_dump -j uses multiple database connections; = it + connects to the database once with the master process and once aga= in + for each worker job. Without the synchronized snapshot feature, the + different worker jobs wouldn't be guaranteed to see the same data = in + each connection, which could lead to an inconsistent backup. If you want to run a parallel dump of a pre-9.2 server, you need t= o make sure that the diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 37cb7cd..8ad9773 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -1131,7 +1131,7 @@ setup_connection(Archive *AH, const char *dumpencodin= g, AH->remoteVersion >=3D 90200 && !dopt->no_synchronized_snapshots) { - if (AH->isStandby) + if (AH->isStandby && AH->remoteVersion < 100000) exit_horribly(NULL, "Synchronized snapshots are not supported on standby servers.\n" "Run with --no-synchronized-snapshots instead if you do not need\n" --=20 2.7.4 --------------00B51D7A1F9466201D27E5AD Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers --------------00B51D7A1F9466201D27E5AD--