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 1nM1VY-0007pq-1y for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Feb 2022 05:45:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nM1VW-0004lc-ET for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Feb 2022 05:45:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nM1VW-0004lT-3E for pgsql-hackers@lists.postgresql.org; Mon, 21 Feb 2022 05:45:10 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nM1VT-00005R-DN for pgsql-hackers@lists.postgresql.org; Mon, 21 Feb 2022 05:45:09 +0000 Received: by mail-ej1-x631.google.com with SMTP id qk11so30289242ejb.2 for ; Sun, 20 Feb 2022 21:45:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=3nMt1M5gAYJ1nXbSaZEyV6SmFNHAkAm6DkQmEt/SS4k=; b=ki4+Fon104n8PHmDGSwx58BTsKHwLtKvUZhecj+/Gxn0K//OKk2G4JZayTFJNApEX5 iJSnUDszvJe86cOCVrs/P6PQpOnJtFtj8lazRbRTHgYlXTG9t+kgk3qhO0j7uxfo9Guc 8BEEEav09khVpwiM0qP0fINF0avLccb9c96sGnHNMwLMXUfojHo6Ib8hRnfVAaoaZe9G MvMSRl7/GNfSqK7RCICKNakw0idKci37xrpTuHemFN1xKBq4Gbiei907UvqKOWavHH+A 0FH3Yj9WpuaXizU8ZYvIzvyQhBAuFdpjGZpl/+6d2P5YmZX37WcrqMkj7+gqZhA7gRYF 2z/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=3nMt1M5gAYJ1nXbSaZEyV6SmFNHAkAm6DkQmEt/SS4k=; b=BJnCGURYVYZa3gFqL+p6kUkoONIqN08k/X1PXx8y/UdbNOcrYrnZbeP3Pi2tlOsmix EkzIDZ1gSasOZF82tBGUowjrHP4TsD7y8vOZRRX1ASGsuHFcujKlOmEPtPRnLqtYCztI nHtauUHlnmAoOU15m4o/bCxlgRoBD5UbdQAk5PY482Fz9OwlpVuTkg+ByZbJn+KWnuzX CD2A2BkHHwu1E+b0p05XVfRuReWJvCgvvtAV58ODe/MdcJqd02BukZk3Jihj2tVZwVFZ XrTNgieGJJm3JI3tFuBsFzIOGqlTWEvGilHG2Rn7bDR5/VYZlfX2Syy8F9GT+osinaIZ Iyjw== X-Gm-Message-State: AOAM533N0KVYtmmfpz/hiVLe8/2uCvCF0CeEh/7iHJAphDZTKFFhThfe 6YGwLkq9IggxHuHmJeDYsb/X+zgtyM5RCK6XFAESzfaSMGS5Ag== X-Google-Smtp-Source: ABdhPJyWEfao/satT4rmGVE+8begLhIEUH8ikk6Bsz7XrxgmAeXEKJgdk7t5rS9FQQvcUBbJXmKctH5ciU7xiu5J/28= X-Received: by 2002:a17:906:b04:b0:6bd:bf71:ed08 with SMTP id u4-20020a1709060b0400b006bdbf71ed08mr14846744ejg.585.1645422305038; Sun, 20 Feb 2022 21:45:05 -0800 (PST) MIME-Version: 1.0 References: <65af8fb4-4c45-9cc3-c6ec-80f3ac488e07@oss.nttdata.com> <95066202-c7e6-e4be-05cc-bdceb45b68c7@oss.nttdata.com> <2d7c480a-63c8-a244-0f2a-361e5097764f@oss.nttdata.com> <3e57ebd7-b536-333e-c877-49a3ebb57079@oss.nttdata.com> <2a2519b5-0c1f-87c8-5461-a4d8be0728e0@oss.nttdata.com> In-Reply-To: <2a2519b5-0c1f-87c8-5461-a4d8be0728e0@oss.nttdata.com> From: Etsuro Fujita Date: Mon, 21 Feb 2022 14:45:10 +0900 Message-ID: Subject: Re: postgres_fdw: commit remote (sub)transactions in parallel during pre-commit To: Fujii Masao Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Feb 18, 2022 at 1:46 AM Fujii Masao w= rote: > I reviewed 0001 patch. It looks good to me except the following minor thi= ngs. If these are addressed, I think that the 001 patch can be marked as re= ady for committer. OK > + * Also determine to commit (sub)transactions opened on the remot= e server > + * in parallel at (sub)transaction end. > > Like the comment "Determine whether to keep the connection ...", "determi= ne to commit" should be "determine whether to commit"? Agreed. I=E2=80=99ll change it as such. > "remote server" should be "remote servers"? Maybe I=E2=80=99m missing something, but we determine this for the given remote server, so it seems to me correct to say =E2=80=9Cthe remote server= =E2=80=9D, not =E2=80=9Cthe remote servers=E2=80=9C. > + curlevel =3D GetCurrentTransactionNestLevel(); > + snprintf(sql, sizeof(sql), "RELEASE SAVEPOINT s%d", curlevel); > > Why does pgfdw_finish_pre_subcommit_cleanup() need to call GetCurrentTran= sactionNestLevel() and construct the "RELEASE SAVEPOINT" query string again= ? pgfdw_subxact_callback() already does them and probably we can make it pa= ss either of them to pgfdw_finish_pre_subcommit_cleanup() as its argument. Yeah, that would save cycles, but I think that that makes code a bit unclean IMO. (To save cycles, I think we could also modify pgfdw_subxact_callback() to reuse the query in the while loop in that function when processing multiple open remote subtransactions there, but that would make code a bit complicated, so I don=E2=80=99t think it=E2= =80=99s a good idea to do so, either.) So I=E2=80=99d vote for reconstructing the qu= ery in pgfdw_finish_pre_subcommit_cleanup() as we do in pgfdw_subxact_callback(). To avoid calling GetCurrentTransactionNestLevel() again, I think we could pass the curlevel variable to that function. > + This option controls whether postgres_fdw co= mmits > + remote (sub)transactions opened on a foreign server in a local > + (sub)transaction in parallel when the local (sub)transaction comm= its. > > "a foreign server" should be "foreign servers"? I thought it would be good to say =E2=80=9Ca foreign server=E2=80=9D, not = =E2=80=9Cforeign servers=E2=80=9D, because it makes clear that even remote transactions open= ed on a single foreign server are committed in parallel. (To say that this option is not for a specific foreign server, I added to the documentation =E2=80=9CThis option can only be specified for foreign servers=E2=80=9D.) > "in a local (sub)transaction" part seems not to be necessary. And I thought adding it would make clear which remote transactions are committed in parallel. But maybe I=E2=80=99m missing something, so could y= ou elaborate a bit more on these? Thanks for reviewing! Best regards, Etsuro Fujita