Re: Transactions involving multiple postgres foreign servers, take 2 - Mailing list pgsql-hackers
From | Amit Kapila |
---|---|
Subject | Re: Transactions involving multiple postgres foreign servers, take 2 |
Date | |
Msg-id | CAA4eK1L+=xqJPgA7vGkyDuUZubgXLaUV+0uBS4CTzYM5vr7fhA@mail.gmail.com Whole thread Raw |
In response to | Re: Transactions involving multiple postgres foreign servers, take 2 (Masahiko Sawada <masahiko.sawada@2ndquadrant.com>) |
Responses |
Re: Transactions involving multiple postgres foreign servers, take 2
|
List | pgsql-hackers |
On Fri, Jun 5, 2020 at 3:16 PM Masahiko Sawada <masahiko.sawada@2ndquadrant.com> wrote: > > On Thu, 4 Jun 2020 at 12:46, Amit Kapila <amit.kapila16@gmail.com> wrote: > > > > > > + <para> > > + This parameter can be changed at any time; the behavior for any one > > + transaction is determined by the setting in effect when it commits. > > + </para> > > > > This is written w.r.t foreign_twophase_commit. If one changes this > > between prepare and commit, will it have any impact? > > Since the distributed transaction commit automatically uses 2pc when > executing COMMIT, it's not possible to change foreign_twophase_commit > between prepare and commit. So I'd like to explain the case where a > user executes PREPARE and then COMMIT PREPARED while changing > foreign_twophase_commit. > > PREPARE can run only when foreign_twophase_commit is 'required' (or > 'prefer') and all foreign servers involved with the transaction > support 2pc. We prepare all foreign transactions no matter what the > number of servers and modified or not. If either > foreign_twophase_commit is 'disabled' or the transaction modifies data > on a foreign server that doesn't support 2pc, it raises an error. At > COMMIT (or ROLLBACK) PREPARED, similarly foreign_twophase_commit needs > to be set to 'required'. It raises an error if the distributed > transaction has a foreign transaction and foreign_twophase_commit is > 'disabled'. > So, IIUC, it will raise an error if foreign_twophase_commit is 'disabled' (or one of the foreign server involved doesn't support 2PC) and the error can be raised both when user issues PREPARE or COMMIT (or ROLLBACK) PREPARED. If so, isn't it strange that we raise such an error after PREPARE? What kind of use-case required this? > > > > > 4. > > + <entry><structfield>in_doubt</structfield></entry> > > + <entry><type>boolean</type></entry> > > + <entry></entry> > > + <entry> > > + If <literal>true</literal> this foreign transaction is > > in-doubt status and > > + needs to be resolved by calling <function>pg_resolve_fdwxact</function> > > + function. > > + </entry> > > > > It would be better if you can add an additional sentence to say when > > and or how can foreign transactions reach in-doubt state. > > + If <literal>true</literal> this foreign transaction is in-doubt status. + A foreign transaction becomes in-doubt status when user canceled the + query during transaction commit or the server crashed during transaction + commit. Can we reword the second sentence as: "A foreign transaction can have this status when the user has cancelled the statement or the server crashes during transaction commit."? I have another question about this field, why can't it be one of the status ('preparing', 'prepared', 'committing', 'aborting', 'in-doubt') rather than having a separate field? Also, isn't it more suitable to name 'status' field as 'state' because these appear to be more like different states of transaction? -- With Regards, Amit Kapila. EnterpriseDB: http://www.enterprisedb.com
pgsql-hackers by date: