Re: Transactions involving multiple postgres foreign servers, take 2 - Mailing list pgsql-hackers
From | Masahiko Sawada |
---|---|
Subject | Re: Transactions involving multiple postgres foreign servers, take 2 |
Date | |
Msg-id | CAD21AoDOfJiedTh3QuD2uNrS-913nRXN_qyosXH5-=+6GHJ=sg@mail.gmail.com Whole thread Raw |
In response to | Re: Transactions involving multiple postgres foreign servers, take 2 (Masahiro Ikeda <ikedamsh@oss.nttdata.com>) |
Responses |
Re: Transactions involving multiple postgres foreign servers, take 2
|
List | pgsql-hackers |
On Thu, May 20, 2021 at 1:26 PM Masahiro Ikeda <ikedamsh@oss.nttdata.com> wrote: > > > On 2021/05/11 13:37, Masahiko Sawada wrote: > > I've attached the updated patches that incorporated comments from > > Zhihong and Ikeda-san. > > Thanks for updating the patches! > > > I have other comments including trivial things. > > > a. about "foreign_transaction_resolver_timeout" parameter > > Now, the default value of "foreign_transaction_resolver_timeout" is 60 secs. > Is there any reason? Although the following is minor case, it may confuse some > users. > > Example case is that > > 1. a client executes transaction with 2PC when the resolver is processing > FdwXactResolverProcessInDoubtXacts(). > > 2. the resolution of 1st transaction must be waited until the other > transactions for 2pc are executed or timeout. > > 3. if the client check the 1st result value, it should wait until resolution > is finished for atomic visibility (although it depends on the way how to > realize atomic visibility.) The clients may be waited > foreign_transaction_resolver_timeout". Users may think it's stale. > > Like this situation can be observed after testing with pgbench. Some > unresolved transaction remains after benchmarking. > > I assume that this default value refers to wal_sender, archiver, and so on. > But, I think this parameter is more like "commit_delay". If so, 60 seconds > seems to be big value. IIUC this situation seems like the foreign transaction resolution is bottle-neck and doesn’t catch up to incoming resolution requests. But how foreignt_transaction_resolver_timeout relates to this situation? foreign_transaction_resolver_timeout controls when to terminate the resolver process that doesn't have any foreign transactions to resolve. So if we set it several milliseconds, resolver processes are terminated immediately after each resolution, imposing the cost of launching resolver processes on the next resolution. > > > b. about performance bottleneck (just share my simple benchmark results) > > The resolver process can be performance bottleneck easily although I think > some users want this feature even if the performance is not so good. > > I tested with very simple workload in my laptop. > > The test condition is > * two remote foreign partitions and one transaction inserts an entry in each > partitions. > * local connection only. If NW latency became higher, the performance became > worse. > * pgbench with 8 clients. > > The test results is the following. The performance of 2PC is only 10% > performance of the one of without 2PC. > > * with foreign_twophase_commit = requried > -> If load with more than 10TPS, the number of unresolved foreign transactions > is increasing and stop with the warning "Increase > max_prepared_foreign_transactions". What was the value of max_prepared_foreign_transactions? To speed up the foreign transaction resolution, some ideas have been discussed. As another idea, how about launching resolvers for each foreign server? That way, we resolve foreign transactions on each foreign server in parallel. If foreign transactions are concentrated on the particular server, we can have multiple resolvers for the one foreign server. It doesn’t change the fact that all foreign transaction resolutions are processed by resolver processes. Apart from that, we also might want to improve foreign transaction management so that transaction doesn’t end up with an error if the foreign transaction resolution doesn’t catch up with incoming transactions that require 2PC. Maybe we can evict and serialize a state file when FdwXactCtl->xacts[] is full. I’d like to leave it as a future improvement. > * with foreign_twophase_commit = disabled > -> 122TPS in my environments. How much is the performance without those 2PC patches and with the same workload? i.e., how fast is the current postgres_fdw that uses XactCallback? > > > c. v36-0001-Introduce-transaction-manager-for-foreign-transa.patch > > * typo: s/tranasction/transaction/ > > * Is it better to move AtEOXact_FdwXact() in AbortTransaction() to before "if > (IsInParallelMode())" because make them in the same order as CommitTransaction()? I'd prefer to move AtEOXact_FdwXact() in CommitTransaction after "if (IsInParallelMode())" since other pre-commit works are done after cleaning parallel contexts. What do you think? > > * functions name of fdwxact.c > > Although this depends on my feeling, xact means transaction. If this feeling > same as you, the function names of FdwXactRegisterXact and so on are odd to > me. FdwXactRegisterEntry or FdwXactRegisterParticipant is better? > FdwXactRegisterEntry sounds good to me. Thanks. > * Are the following better? > > - s/to register the foreign transaction by/to register the foreign transaction > participant by/ > > - s/The registered foreign transactions/The registered participants/ > > - s/given foreign transaction/given foreign transaction participant/ > > - s/Foreign transactions involved in the current transaction/Foreign > transaction participants involved in the current transaction/ Agreed with the above suggestions. Regards, -- Masahiko Sawada EDB: https://www.enterprisedb.com/
pgsql-hackers by date: