Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLz3i-0005Kl-Tl for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 00:59:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jLz3h-0002oS-Me for pgsql-hackers@arkaria.postgresql.org; Wed, 08 Apr 2020 00:59:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLz3h-0002oL-Bj for pgsql-hackers@lists.postgresql.org; Wed, 08 Apr 2020 00:59:13 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jLz3e-00031w-As for pgsql-hackers@postgresql.org; Wed, 08 Apr 2020 00:59:12 +0000 Received: by mail-wr1-x442.google.com with SMTP id a25so5949897wrd.0 for ; Tue, 07 Apr 2020 17:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yi6Ic+NAF7290Sn1LfNx8v4ujf2+k2LmCMoLovZWzb4=; b=BKOw+mUYdaX1Pns1/Jm3xYEch8GyhCupzUg4B8bf7Q+fXbR3iPavU8us6iRQEZzfIZ Qk/n/PaSTkvSB7go8v0NqUkvNbp9nKjA+QSq2muQYc8D7lolpw7ycHWP2fv6cOxGq4Sa yvYe+8DnLBfC5h2vni1Wcx+LF1rosFNwVUNZvsFrZ9nWz8AxHsKCcmKPHoqJDAF5Za41 sR2DwGOlSk+qTcFXlqkhBqykMlZ1RnaZDmHgt2CmcohJOPzSXYGvxvRn5oYZPsAiDBWc cmKopgHP3k2O60u03pnIUHT4iQ8DxMwGlFlDExgVB4zdLVKcSZDXdYjhEKbxz8WyQIqb MZHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yi6Ic+NAF7290Sn1LfNx8v4ujf2+k2LmCMoLovZWzb4=; b=U2ezka9pCZ+cexCkL+R7yR+aQH0zCEwB+6HVHlfanaWjlpE2K8x/Ib7FaDdKvvcLTQ 5ULxfiRO800Bc4Nybyq5hupqyd2Mghu5Dc3ZFNMmObqyzV3HtfQF2u6GLRHpYr+9+Pti 2WNcOo3OE4ivSL9RjfksdJ89U7aQXQU9zIbR0+yOVmzxsWpgacpts4mZoJoqT4FD4Eg9 fXowLE0cjIIlc6nLyXga051Ma4DVoncnD1ldpEjLupeRJ5HgzYBjttYd6zno8ZaTBMT/ fYVJfg2j5MEZ/ejPo+Ia+PKcz5CygVemkMlZvqJ+5pnxHzcH+B/ZCxjK0qSC3C6crpu7 /Rbw== X-Gm-Message-State: AGi0PuaX8P86KqwYizewdPW4dNdabugWuoX6jmJFIP9wITBpMpheC3fg 6E0CYJCXvxo+zNexG4pDRwNRUA== X-Google-Smtp-Source: APiQypIiRcQkFRV62flJ2+51hfUstLD3qMM6fx2EXmx5T7AEpqvwx5sqtbPDLWcU2yWsL8lHvp15+g== X-Received: by 2002:adf:ef8f:: with SMTP id d15mr5229367wro.315.1586307549099; Tue, 07 Apr 2020 17:59:09 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id a2sm33221707wrp.13.2020.04.07.17.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2020 17:59:08 -0700 (PDT) Date: Wed, 8 Apr 2020 02:59:05 +0200 From: Tomas Vondra To: Amit Kapila Cc: Dilip Kumar , Michael Paquier , Peter Eisentraut , PostgreSQL Hackers Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions Message-ID: <20200408005905.misvqmjk5c7wd5vr@development> References: <20200329005905.ooxq25qyjwn2mvxz@development> <20200329153105.mdryxzz562tg65pk@development> <20200330152758.fgp62lwb2ug7cl2a@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Apr 07, 2020 at 12:17:44PM +0530, Amit Kapila wrote: >On Mon, Mar 30, 2020 at 8:58 PM Tomas Vondra > wrote: >> >> On Mon, Mar 30, 2020 at 11:47:57AM +0530, Amit Kapila wrote: >> > >> >I think we need to cache the subxids on the replica somehow but I >> >don't have a very good idea for it. Basically, there are two ways to >> >do it (a) Change the KnownAssignedXids in some way so that we can >> >easily find this information without losing on the current benefits of >> >it. I can't think of a good way to do that and even if we come up >> >with something, it could easily be a lot of work, (b) Cache the >> >subxids for a particular transaction in local memory along with >> >KnownAssignedXids. This is doable but now we have two data-structures >> >(one in shared memory and other in local memory) managing the same >> >information in different ways. >> > >> >Do you have any other ideas? >> >> I don't follow. Why couldn't we have a simple cache on the standby? It >> could be either a simple array or a hash table (with the top-level xid >> as hash key)? >> > >I think having something like we discussed or what you have in the >patch won't be sufficient to clean the KnownAssignedXid array. The >point is that we won't write a WAL for xid-subxid association for >unlogged relations in the "Immediately WAL-log assignments" patch, >however, the KnownAssignedXid would have both kinds of Xids as we >autofill it with gaps (see RecordKnownAssignedTransactionIds). I >think if my understanding is correct to make it work we might need >major surgery in the code or have to maintain KnownAssignedXid array >differently. Hmm, that's a good point. If I understand correctly, the issue is that if we create new subxact, write something into an unlogged table, and then create new subxact, the XID of the first subxact will be "known assigned" but we won't know it's a subxact or to which parent xact it belongs (because there will be no WAL records that could encode it). I wonder if there's a simple solution (e.g. when creating the second subxact we might notice the xid-subxid assignment was not logged, and write some "dummy" WAL record). But I admit it seems a bit ugly. >> >> I don't think this is particularly complicated or a lot of code, and I >> don't see why would it require data structures in shared memory. Only >> the walreceiver on standby needs to worry about this, no? >> > >Not a new data structure in shared memory, but we already have a >KnownTransactionId structure in shared memory. So, after having a >local cache, we will have xidAssignmentsHash and KnownTransactionId >maintaining the same information in different ways. And, we need to >ensure both are cleaned up properly. That was what I was pointing >above related to maintaining two structures. However, I think before >discussing more on this, we need to think about the above problem. > Sure. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services