What is an XA transaction
Distributed transaction processing refers to a transaction that may involve multiple database operations
The key to distributed transaction processing is that there must be a way to know all the actions that a transaction makes anywhere, and committing or rolling back a transaction must produce consistent results (commit all or roll back all).
xa is a two-phase commit protocol defined by the X/open DTP Organization (x/open DTP Group), and XA is a tool (such as CICS and Tuxedo) for many databases such as Oracle, DB2, SQL Server, MySQL, and middleware. Local support.
The X/open DTP Model (1994) includes the application (AP), transaction manager (TM), Resource Manager (RM), Communications Explorer (CRM) four section.
In this model, the transaction manager (TM) is usually the transaction middleware, the Resource Manager (RM) is the database, and the Communication Resource Manager (CRM) is the message middleware.
In general, a database cannot know what other databases are doing, so in a DTP environment, transactional middleware is required to notify and coordinate the submission or rollback of related databases. A database only alludes its own operations (recoverable) to global transactions.
XA is the interface specification (i.e. interface function) between the transaction middleware defined by the X/open DTP and the database, which is used by the transaction middleware to inform the start, end, and commit, rollback, etc. of the database transaction.
Xa interface functions are provided by the database vendor. Usually, the transaction middleware and database through the XA interface specification, using two-phase commit to complete a global transaction, the basis of the XA specification is a two-phase commit protocol.
In the first phase: The transaction middleware requests that all relevant databases prepare to submit (pre-commit) their respective branch of the transaction to confirm that all related databases can submit their own transaction branches. When a database receives a pre-commit, if it can commit its own branch of the transaction, then the operation of its own in the branch of the transaction is fixed record and give the transaction middleware a consent to commit the answer, the database will no longer be able to add any operations in the transaction branch, but the database does not actually commit the transaction, The operation of the database on the shared resource has not been released (in a locked state). If for some reason the database cannot submit its own transaction branch, it will roll back all its operations, release the lock on the shared resource, and return the failed response to the transactional middleware.
In the second stage: Transaction middleware Review the pre-commit results returned by all databases, such as all databases can be submitted, the transaction middleware will require all databases to be formally committed, so that the global transaction is committed. If any of the database pre-commit returns fail, the transaction middleware will require all other databases to roll back their operations so that the global transaction is rolled back.
Setting the Enable XA transaction in the DTC property in Windows, SQL Server can be used with Windows distributed transactions
Related article: http://www.sqldbadiaries.com/2014/09/24/no-transaction-is-active-message-when-accessing-linked-server/
If there is a wrong place, welcome everyone to shoot brick O (∩_∩) o
What is an XA transaction