-3

Many DBMS use a special 2PC protocol called "XA" for distributed transaction. Why would someone use XA? To me, XA cannot guarantee any thing in case of failure:

In XA, the Transaction Manager (TM) will tell all the DBMS to prepare in the first phase, and if all are prepared, TM will tell all of them to commit in the second phase, otherwise if any of them fail, TM will tell the others to roll back.

If all the DBMS are prepared in the first phase, what if someone fail to commit in the second phase? In this case the whole transaction will fail and all the other will have to roll back (the 3rd phase?), rendering the first phase meaningless. That is to say, the first phase cannot make any guarantee even if all the DBMS are said to be prepared (it does increase some possibility of success, though).

walkerlala
  • 1,599
  • 1
  • 19
  • 32
  • Please focus your question on one thing only. Your current question is a bit vague and too broad; also the title of your question doesn't seem to cover the body of your question: bring them in line. – Mark Rotteveel Nov 03 '18 at 12:23
  • 2
    In any case, your premise is wrong, distributed transactions require that the prepare is sufficient for the commit to succeed, if it isn't then the resource cannot properly participate in distributed transactions. Only resource unavailability may be a problem (but then there must be a way to recover so the commit can be done eventually). – Mark Rotteveel Nov 03 '18 at 12:26
  • @MarkRotteveel Edited. – walkerlala Nov 03 '18 at 12:31

1 Answers1

0

Though your question seems to be more theoretical than practical, but

you're right (from https://dev.mysql.com/doc/refman/8.0/en/xa-restrictions.html)

If there is an unexpected halt while the server is in the middle of executing an XA PREPARE, XA COMMIT, XA ROLLBACK, or XA COMMIT ... ONE PHASE statement, the server might not be able to recover to a correct state, leaving the server and the binary log in an inconsistent state.

But - that's about MySQL and tagged this question with this one:)

If you want to dig deeper, I think you should jump to https://dba.stackexchange.com/

Anton
  • 919
  • 7
  • 22