Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKC0n-00043i-2F for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Nov 2017 23:43:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKC0l-0005LK-TP for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Nov 2017 23:43:27 +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 1eKBy6-0007rX-OR for pgsql-hackers@lists.postgresql.org; Wed, 29 Nov 2017 23:40:42 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eKBy3-0008Im-QF for pgsql-hackers@postgresql.org; Wed, 29 Nov 2017 23:40:41 +0000 Received: by mail-wr0-x241.google.com with SMTP id v105so4986968wrc.3 for ; Wed, 29 Nov 2017 15:40:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=1Qh18P7jvDXttH/STwvF+FugED6I+gkNFzwGrD/Br/Q=; b=s3n8n4B5aaED82HfKPsRX2LJnnqrcprQdq+1xgisEcjFX9sbI0irwuRfBj1kg5LTE0 OYPsnIR9sSZb2SP388ENy7sfaqb8CmzKSzRiIRgOGHdmIt+swak3FZgx/HG7bOi+FCCX y/A3EYeX1ggHY7XhHVPEmCtL4wU/bLi50uYqLzT9kJJpCE7TXH/LtMvmESYLbPe8U5os Rfxa0sHN5PVWfIeP7MYAyVrkTmdNaLfqfspDeH34KRc7i8YX3klgOyE7zpf3BosE3OEF d3Gkx5FIZUQe9KfUkKqjCDGcHUJ365Pg2/2sHWagLdIBbOS9oYM3Z3CITNdN1CpZ81WJ wr/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1Qh18P7jvDXttH/STwvF+FugED6I+gkNFzwGrD/Br/Q=; b=P8tnnywD38UZpi580p6y9ajjMCzt33uOTLJL3iCIjYi1ABkEAy4+l2D8yBJ5IWbzH+ k9oPatscU8HrAqHDuI7iGyRj+RSrgP0MVGx9op12RuFBhqM25+UjF+sov9osRGnHQX/s m8QiidTlhv+JcQaXQOaO5mZ1d3+Y2KRJom73B//lfhWlQat+rvmVc8Y9JuGCfSiIJC/V lk6hRPeq541n/6jUXD4krF0IWfNYrBWxWW82jEyWu8RG6Crw4ByPIvh8Yiq8clcx/F1V LRptSPx7IZwLbdTGjDCqHtEUU+toUdOm/TDSWnMFKJzHqTYchmpdXDocH4orN6d4CU0k 8J9g== X-Gm-Message-State: AJaThX5eYULzdAb4Mwwq1k6B/PFoX+iBnIp3HyKN4akEGTcNOUpahIZ4 Lp4iNzEabtn/+lKrAMifLPUG+w== X-Google-Smtp-Source: AGs4zMbhI1Fys+qyEAiFeOog7/GvAJxt4QBVOUsCb7v8/ik4WDxH92jvo25hHJiiiuISyititOhhHg== X-Received: by 10.223.198.3 with SMTP id n3mr385676wrg.73.1511998838176; Wed, 29 Nov 2017 15:40:38 -0800 (PST) Received: from [192.168.0.105] (150.123.broadband11.iol.cz. [90.178.123.150]) by smtp.gmail.com with ESMTPSA id o80sm2163058wmg.6.2017.11.29.15.40.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Nov 2017 15:40:37 -0800 (PST) Subject: Re: [HACKERS] logical decoding of two-phase transactions To: Craig Ringer , Nikhil Sontakke Cc: Sokolov Yura , Stas Kelvich , Andres Freund , Dmitry Dolgov <9erthalion6@gmail.com>, Tom Lane , Masahiko Sawada , Simon Riggs , PostgreSQL Hackers , Robert Haas References: <9CD693AF-51BE-4A19-9D26-16031CDAD9C9@postgrespro.ru> <20170404173133.olo7keeh3dzhriay@alap3.anarazel.de> <19307.1494706954@sss.pgh.pa.us> <0e46521cbbca66c3298d1a9d672c9af0@postgrespro.ru> From: Petr Jelinek Message-ID: Date: Thu, 30 Nov 2017 00:40:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 24/11/17 07:41, Craig Ringer wrote: > On 24 November 2017 at 13:44, Nikhil Sontakke   > > > How practical is adding a lock class? > > Am open to suggestions. This looks like it could work decently. > > > It looks amazingly simple from here. Which probably means there's more > to it that I haven't seen yet. I could use advice from someone who knows > the locking subsystem better. >   Hmm, I don't like the interaction that would have with ROLLBACK, meaning that ROLLBACK has to wait for decoding to finish which may take longer than the transaction took itself (given potential network calls, it's practically unbounded time). I also think that if we'll want to add streaming of transactions in the future, we'll face similar problem and the locking approach will not work there as the transaction may still be locked by the owning backend while we are decoding it. From my perspective this patch changes the assumption in HeapTupleSatisfiesVacuum() that changes done by aborted transaction can't be seen by anybody else. That's clearly not true here as the decoding can see it. So perhaps better approach would be to not return HEAPTUPLE_DEAD if the transaction id is newer than the OldestXmin (same logic we use for deleted tuples of committed transactions) in the HeapTupleSatisfiesVacuum() even for aborted transactions. I also briefly checked HOT pruning and AFAICS the normal HOT pruning (the one not called by vacuum) also uses the xmin as authoritative even for aborted txes so nothing needs to be done there probably. In case we are worried that this affects cleanups of for example large aborted COPY transactions and we think it's worth worrying about then we could limit the new OldestXmin based logic only to catalog tuples as those are the only ones we need available in decoding. -- Petr Jelinek http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services