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 1mnC7N-0002FN-BT for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Nov 2021 04:00:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mnC7L-0000bm-O3 for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Nov 2021 04:00:15 +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 1mnC7L-0000bd-CK for pgsql-hackers@lists.postgresql.org; Wed, 17 Nov 2021 04:00:15 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mnC7E-0006iZ-Jg for pgsql-hackers@lists.postgresql.org; Wed, 17 Nov 2021 04:00:14 +0000 Received: by mail-ed1-x52c.google.com with SMTP id x15so4695612edv.1 for ; Tue, 16 Nov 2021 20:00:08 -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; bh=Xj6m12NuxPik/HQhTTYfrYyAsjVKlgPqlfrg17Vam6U=; b=oxkSvu6dmApRkNj+JWHeW3Y1v3MWt6bScDTnjEiuhhXlcF/3Un/aTvD6wFoulSKQ3g qBcFJOYghmAUgQoh4APV+ZhqyZr9D2jeaZ58ZNGL6pIp2h1n52OoLEGSs7GJe2UTBZCc MJe9fNpjDxaBbb2xiGVGsPeCQP0sERzKFTLSkgfwNjLia6vufkMdnf+fuXjusYwaBrop NzdtGGBSU6gdsgYTLMpfWVbEczCtDLKFQTZTyQZzCAUpSlJj90xU3yI8pOl28HkTpaIy sq3tXWSl7WAvCNDWaPp7XJ1c2tU2B0MiUyYcEXhEJqZFuWOmOVMVGJzTDYEA7uLvtTUa 1VcQ== 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; bh=Xj6m12NuxPik/HQhTTYfrYyAsjVKlgPqlfrg17Vam6U=; b=sXOVmKakLED/7CO2H1zxJCLg2ZSSDcmK3iHArsgUHueJjZCrK3feo89HsF6mzS/gEw ZSSBSGrRIzgvLhx083yb677uqCJViiy4722AQeDTlrKV22Ue8ZXvQcmUb5tfYe0tBRqU LhfFElnGtbxFlX0MjVBRFFAbsXWzFDHEwiappW9MrIIPlIvuNuunnKLmcW4VgC725QPr 9g78QXiWFn1XjDJhXUiw9fMTMr6M07A8eiMxjabX7pAVutFjtq4GcuoNVnJdJfXSg/IB bIy916yjOp5YlaWxlMZi2f7tIyybRQhHjuP6DS5AyEMB+c1KNz88EQweWcIGeSLVLHKL uqjw== X-Gm-Message-State: AOAM5323r6RuF0jka9MmfAnID6ZYMUEHHF+HoopH9s54A15+DZgjQOgt EpvgsQiCt2t3HbRc5JMkkQASMF9sbBa5bMB8dbI= X-Google-Smtp-Source: ABdhPJyYxGiQ1gXbvB1xuHYbhnEeZcxACB19P+tpWqb0tCWyRLCetPZDjiwlhAVYWmwRT3JnaA2oyzh4PiiQFnLqV3Y= X-Received: by 2002:a05:6402:11cb:: with SMTP id j11mr18274921edw.38.1637121606089; Tue, 16 Nov 2021 20:00:06 -0800 (PST) MIME-Version: 1.0 References: <65af8fb4-4c45-9cc3-c6ec-80f3ac488e07@oss.nttdata.com> <95066202-c7e6-e4be-05cc-bdceb45b68c7@oss.nttdata.com> In-Reply-To: From: Etsuro Fujita Date: Wed, 17 Nov 2021 13:00:04 +0900 Message-ID: Subject: Re: postgres_fdw: commit remote (sub)transactions in parallel during pre-commit To: "kuroda.hayato@fujitsu.com" Cc: PostgreSQL Hackers , Fujii Masao Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Kuroda-san, On Thu, Nov 11, 2021 at 11:27 AM kuroda.hayato@fujitsu.com wrote: > I love your proposal because it will remove a bottleneck > for PostgreSQL build-in sharding. > > I read your patch briefly and I think basically it's good. Great! Thanks for reviewing! > Currently I have only one comment. > > In your patch, postgres_fdw sends a COMMIT command to all entries in the hash table > and waits for the result without a timeout from the first entry. > I think this specification is good because it's very simple, > but if a COMMIT for a particular foreign server could take some time, > I thought it might be more efficient to stop waiting for results and look at the next entry. > This is how it works. First, we define a function similar to pgfdw_get_result() > so that we can specify the timeout time as an argument to WaitLatchOrSocket(). > Then change the function called by do_sql_command_end () to the new one, > and change the callback function to skip if the result has not yet arrived > > How is it? Is it an unnecessary assumption that COMMIT takes time? Or is this the next step? > I will put a PoC if needed. Hmm, I'm not sure the cost-effectiveness of this optimization is really high, because if the timeout expired, it means that something unusual would have happened, and that it would take a long time for the COMMIT command to complete (or abort at worst). So even if we processed the rest of the entries while waiting for the command result, we cannot reduce the total time very much. Maybe I'm missing something, though. Best regards, Etsuro Fujita