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 1nH95M-0000NV-Ek for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Feb 2022 18:50:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nH95L-0007vF-0b for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Feb 2022 18:49:59 +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 1nH95K-0007uz-IZ for pgsql-hackers@lists.postgresql.org; Mon, 07 Feb 2022 18:49:58 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nH95E-0005E2-MY for pgsql-hackers@lists.postgresql.org; Mon, 07 Feb 2022 18:49:57 +0000 Received: from [192.168.11.9] (p2019072-ipbf2307funabasi.chiba.ocn.ne.jp [122.30.130.72]) by oss.nttdata.com (Postfix) with ESMTPSA id 7A969604CB; Tue, 8 Feb 2022 03:49:48 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.5 at oss.nttdata.com Message-ID: <3e57ebd7-b536-333e-c877-49a3ebb57079@oss.nttdata.com> Date: Tue, 8 Feb 2022 03:49:47 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: postgres_fdw: commit remote (sub)transactions in parallel during pre-commit Content-Language: en-US To: Etsuro Fujita Cc: PostgreSQL Hackers 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> From: Fujii Masao In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022/02/07 14:35, Etsuro Fujita wrote: >> 0001 patch failed to be applied. Could you rebase the patch? > > Done. Attached is an updated version of the patch set. Thanks for updating the patch! Here are the review comments for 0001 patch. I got the following compiler warning. [16:58:07.120] connection.c: In function ‘pgfdw_finish_pre_commit_cleanup’: [16:58:07.120] connection.c:1726:4: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] [16:58:07.120] 1726 | PGresult *res; [16:58:07.120] | ^~~~~~~~ + /* Ignore errors in the DEALLOCATE (see note above) */ + if ((res = PQgetResult(entry->conn)) != NULL) Doesn't PQgetResult() need to be called repeatedly until it returns NULL or the connection is lost because there can be more than one messages to receive? + if (pending_deallocs) + { + foreach(lc, pending_deallocs) If pending_deallocs is NIL, we don't enter this foreach loop. So probably "if (pending_deallocs)" seems not necessary. entry->keep_connections = defGetBoolean(def); + if (strcmp(def->defname, "parallel_commit") == 0) + entry->parallel_commit = defGetBoolean(def); Isn't it better to use "else if" here, instead? +static void do_sql_command_begin(PGconn *conn, const char *sql); +static void do_sql_command_end(PGconn *conn, const char *sql); To simplify the code more, I'm tempted to change do_sql_command() so that it just calls the above two functions, instead of calling PQsendQuery() and pgfw_get_result() directly. Thought? If we do this, probably we also need to change do_sql_command_end() so that it accepts boolean flag which specifies whether PQconsumeInput() is called or not, as follows. do_sql_command_end(PGconn *conn, const char *sql, bool consumeInput) { /* * If any data is expected to be available from the socket, consume it. * ... * When parallel_commit is enabled, since there can be a time window between * sending query and receiving result, we can expect data is already available * from the socket. In this case we try to consume it at first.... Otherwise.. */ if (consumeInput && !PQconsumeInput(conn)) ... Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION