postgres_fdw: commit remote (sub)transactions in parallel during pre-commit
Etsuro Fujita <etsuro.fujita@gmail.com>
From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Date: 2021-10-31T09:05:44Z
Lists: pgsql-hackers
Attachments
- postgres-fdw-parallel-commit-1.patch (application/octet-stream) patch
Hi, As I said before [1], I’m working on $SUBJECT. Attached is a WIP patch for that. The patch is pretty simple: if a server option added by the patch “parallel_commit” is enabled, 1) asynchronously send COMMIT TRANSACTION (RELEASE SAVEPOINT) to all remote servers involved in a local (sub)transaction, then 2) wait for the results from the remote servers in the order that the command was sent to the remote servers, when called from pgfdw_xact_callback (pgfdw_subxact_callback) during pre-commit. The patch also parallelizes clearing prepared statements the same way during pre-commit. (The option is false by default.) I evaluated the effectiveness of the patch using a simple multi-statement transaction: BEGIN; SAVEPOINT s; INSERT INTO ft1 VALUES (10, 10); INSERT INTO ft2 VALUES (20, 20); RELEASE SAVEPOINT s; COMMIT; where ft1 and ft2 are foreign tables created on different foreign servers hosted on different machines. I ran the transaction five times using the patch with the option enabled/disabled, and measured the latencies for the RELEASE and COMMIT commands in each run. The average latencies for these commands over the five runs are: * RELEASE parallel_commit=0: 0.385 ms parallel_commit=1: 0.221 ms * COMMIT parallel_commit=0: 1.660 ms parallel_commit=1: 0.861 ms With the option enabled, the average latencies for both commands are reduced significantly! I think we could extend this to abort cleanup of remote (sub)transactions during post-abort. Anyway, I think this is useful, so I’ll add this to the upcoming commitfest. Best regards, Etsuro Fujita [1] https://www.postgresql.org/message-id/CAPmGK177E6HPcCQB4-s%2Bm9AcCZDHCC2drZy%2BFKnnvEXw9kXoXQ%40mail.gmail.com
Commits
-
postgres_fdw: Add support for parallel abort.
- 983ec23007bd 16.0 landed
-
Refine the definition of page-level freezing.
- b37a08323964 16.0 cited
-
postgres_fdw: Update comments in make_new_connection().
- 4036bcbbb928 15.0 landed
-
postgres_fdw: Minor cleanup for pgfdw_abort_cleanup().
- 56566835039a 15.0 landed
-
postgres_fdw: Add support for parallel commit.
- 04e706d4238f 15.0 landed
-
Fix ruleutils.c's dumping of whole-row Vars in more contexts.
- 43c2175121c8 15.0 cited
-
postgres_fdw: Refactor transaction rollback code to avoid code duplication.
- 85c69611288f 15.0 cited