XA Transactions
1122
Some examples of distributed transactions:
• An application may act as an integration tool that combines a messaging service with an RDBMS.
The application makes sure that transactions dealing with message sending, retrieval, and
processing that also involve a transactional database all happen in a global transaction. You can
think of this as “transactional email.”
• An application performs actions that involve different database servers, such as a MySQL server
and an Oracle server (or multiple MySQL servers), where actions that involve multiple servers must
happen as part of a global transaction, rather than as separate transactions local to each server.
• A bank keeps account information in an RDBMS and distributes and receives money through
automated teller machines (ATMs). It is necessary to ensure that ATM actions are correctly reflected
in the accounts, but this cannot be done with the RDBMS alone. A global transaction manager
integrates the ATM and database resources to ensure overall consistency of financial transactions.
Applications that use global transactions involve one or more Resource Managers and a Transaction
Manager:
• A Resource Manager (RM) provides access to transactional resources. A database server is one
kind of resource manager. It must be possible to either commit or roll back transactions managed by
the RM.
• A Transaction Manager (TM) coordinates the transactions that are part of a global transaction. It
communicates with the RMs that handle each of these transactions. The individual transactions
within a global transaction are “branches” of the global transaction. Global transactions and their
branches are identified by a naming scheme described later.
The MySQL implementation of XA MySQL enables a MySQL server to act as a Resource Manager
that handles XA transactions within a global transaction. A client program that connects to the MySQL
server acts as the Transaction Manager.
To carry out a global transaction, it is necessary to know which components are involved, and
bring each component to a point when it can be committed or rolled back. Depending on what each
component reports about its ability to succeed, they must all commit or roll back as an atomic group.
That is, either all components must commit, or all components must roll back. To manage a global
transaction, it is necessary to take into account that any component or the connecting network might
fail.
The process for executing a global transaction uses two-phase commit (2PC). This takes place after
the actions performed by the branches of the global transaction have been executed.
1. In the first phase, all branches are prepared. That is, they are told by the TM to get ready to
commit. Typically, this means each RM that manages a branch records the actions for the branch in
stable storage. The branches indicate whether they are able to do this, and these results are used
for the second phase.
2. In the second phase, the TM tells the RMs whether to commit or roll back. If all branches indicated
when they were prepared that they will be able to commit, all branches are told to commit. If any
branch indicated when it was prepared that it will not be able to commit, all branches are told to roll
back.
In some cases, a global transaction might use one-phase commit (1PC). For example, when a
Transaction Manager finds that a global transaction consists of only one transactional resource (that is,
a single branch), that resource can be told to prepare and commit at the same time.
13.3.7.1. XA Transaction SQL Syntax
To perform XA transactions in MySQL, use the following statements:
XA {START|BEGIN}
xid
[JOIN|RESUME]
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...