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.92) (envelope-from ) id 1jIMIK-0001PZ-B2 for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 00:59:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jIMII-0005Fo-QG for pgsql-hackers@arkaria.postgresql.org; Sun, 29 Mar 2020 00:59:18 +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 1jIMII-0005Ew-Au for pgsql-hackers@lists.postgresql.org; Sun, 29 Mar 2020 00:59:18 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jIMIB-0004oM-5T for pgsql-hackers@postgresql.org; Sun, 29 Mar 2020 00:59:16 +0000 Received: by mail-wr1-x444.google.com with SMTP id p10so16616759wrt.6 for ; Sat, 28 Mar 2020 17:59:10 -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=o7HjYjQ1vN+fPwTeqCuo6gEd5ewRAKN6lG22NbnM5ZM=; b=TOKRYXgZoMH1Yoo/fAMtUQr7siIaw+YHs/cj/CHM0qRzAN6arF4QddnrZ+wSSCnyDA NRTWMpcn6PJCbddLxDuEfBcwV1uU1ueURvORiGy0GitLty0eKKn6Ii5SoHojarWl/Mwm 4aeOc++2mXdNw7FJaOrHOAWiZYiXDMJyZXZQMOsl3ur3qisObssn9M2ysKeB/B9sUooe eEicf7D74SVF0p+AfzIBWrtWuhLnpZ9vfkZDheDwVGBUyY9o4FSwT6BFHmfnErNwm9Kg UlTmrcEeSGATBuIuUZLs1t2y1Cm4u3sY03wNoPfZRhkV238yppdLI3nYaXhFUxKNww6G yi6A== 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=o7HjYjQ1vN+fPwTeqCuo6gEd5ewRAKN6lG22NbnM5ZM=; b=rF3or2qFrl+Pj3Dq98crVxl3K4FucJoB0PnmuYFOTD0ZENtvSHTSrSueiuzD/WQqE2 350jD97KagvTjUQDQ3+EAp6C2Q65RalwmvAlNFDqaJOseJxMqTOgBiqkSbMkt/9rcO8/ 4AIQ1pUj1flx6xg2kpMx/Hrq439ev3BL1zR/OJYGrK11Z+zK/Di+XvYYeUZq9aKP+8cg vSpZS8s9jPddHDpb/csf6UMWTmpXHyMOUbUpGQmm8zGtsK8ZeTay1P1XFKHSceraJb5y e28odmwnVtN/HeiRGS4tH2WISOMsgZ+qNp4uJ9tsy+GRoFV9fSMf3RHdYVGLkTAols82 Xd4w== X-Gm-Message-State: ANhLgQ0m7xpstLsmPeBXIIU8YdqMNbLYA5iw1LbAJ4lQOdSg3h/dKCb+ F0mFRG8Su1lRPxJ1d+AqyXxjUQ== X-Google-Smtp-Source: ADFU+vtddtyRhY6QoIJOpCpLttrnDBDwZTCPxlW+tYhKk8tDSDRifF8wS0khGLuq0m2epJT7LiodAQ== X-Received: by 2002:a5d:498f:: with SMTP id r15mr7700482wrq.81.1585443549327; Sat, 28 Mar 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 v8sm15277067wrp.84.2020.03.28.17.59.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 17:59:08 -0700 (PDT) Date: Sun, 29 Mar 2020 01:59:05 +0100 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: <20200329005905.ooxq25qyjwn2mvxz@development> References: <20200303214646.6adway2z5wnapjem@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 Sat, Mar 28, 2020 at 03:29:34PM +0530, Amit Kapila wrote: >On Sat, Mar 28, 2020 at 2:19 PM Dilip Kumar wrote: >> >> On Sat, Mar 28, 2020 at 11:56 AM Amit Kapila wrote: >> > >> > >> > I have looked at the solution proposed and I would like to share my >> > findings. I think calling ProcArrayApplyXidAssignment for each >> > subtransaction is not a good idea for a couple of reasons: >> > (a) It will just beat the purpose of maintaining KnowAssignedXids >> > array which is to avoid looking at pg_subtrans in >> > TransactionIdIsInProgress() on standby. Basically, if we remove it >> > for each subXid, it will consider the KnowAssignedXids to be >> > overflowed and check pg_subtrans frequently. >> >> Right, I also think this is a problem with this solution. I think we >> may try to avoid this by caching this information. But, then we will >> have to maintain this in some dimensional array which stores >> sub-transaction ids per top transaction or we can maintain a list of >> sub-transaction for each transaction. I haven't thought about how >> much complexity this solution will add. >> > >How about if instead of writing an XLOG_XACT_ASSIGNMENT WAL, we set a >flag in TransactionStateData and then log that as special information >whenever we write next WAL record for a new subtransaction? Then >during recovery, we can only call ProcArrayApplyXidAssignment when we >find that special flag is set in a WAL record. One idea could be to >use a flag bit in XLogRecord.xl_info. If that is feasible then the >solution can work as it is now, without any overhead or change in the >way we maintain KnownAssignedXids. > Ummm, how is that different from what the patch is doing now? I mean, we only write the top-level XID for the first WAL record in each subxact, right? Or what would be the difference with your approach? Anyway, I think you're right the ProcArrayApplyXidAssignment call was done too early, but I think that can be fixed by moving it until after the RecordKnownAssignedTransactionIds call, no? Essentially, right before rm_redo(). You're right calling ProcArrayApplyXidAssignment() may be an issue, because it exclusively acquires the ProcArrayLock. I've actually hinted that might be an issue in my original message, suggesting we might add a local cache of assigned XIDs (a small static array, doing essentially the same thing we used to do on the upstream node). I haven't done that in my WIP patch to keep it simple, but AFACS it'd work. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services