Information Technology Reference
In-Depth Information
is always the case and that s
0
is the identifier of the coordinator. The subtransaction
T
0
at s
0
, which hence is the first of the subtransactions created, is called the
parent
transaction
, and the other subtransactions T
1
;:::;T
k
are called
child transactions
.
We identify a distributed transaction with its parent transaction.
Assume that an application starts a transaction at server s
0
.Itisgivena
transaction identifier T
0
, the start is logged at s
0
, and an entry for the forward-rolling
transaction T
0
is inserted into the active-transaction table at s
0
. Any read and update
actions on data items stored at s
0
are executed in the name of T
0
as in a centralized
database system. That is, any locks needed to protect the action are registered in the
lock table at s
0
as locks owned by T
0
, and, in the case of an update action, a log
record for T
0
is written to the log at s
0
.
The first action on a remote data item, that is, one stored at server s
i
different
from s
0
, starts a new transaction at s
i
, where it is given a transaction identifier T
i
and marked as a subtransaction of T
0
at s
0
;thestartofT
i
is logged at s
i
,andan
entry for T
i
is inserted into the active-transaction table at s
i
.Servers
0
is informed
about this new subtransaction. The action is now executed and (if an update) logged
at s
i
in the name of T
i
, with appropriate locks registered in the lock table at s
i
.Any
further actions requested to be executed for the distributed transaction T
0
on data
items at s
i
are executed there in the name of the already existent subtransaction T
i
.
In Fig.
13.1
, a request to execute an
SQL
query or update statement R starts a
transaction T
0
at server s
0
.AsR is found to touch remote data,
SQL
statements
R
1
and R
2
are formed and send to the servers, s
1
and s
2
, that store the remote
data. Statement R
1
is executed at s
1
in the name of a new subtransaction, T
1
,and
statement R
2
is executed at s
2
in the name of a new subtransaction, T
2
.Theresult
for R is formed at s
0
from the results returned from s
1
and s
2
for R
1
and R
2
.
We assume that requests to execute
SQL
statements sent by client application
processes are processed in the coordinating server s
0
by the call
process-
SQL
-
request
.T
0
;R/ (Algorithm
13.1
), where R is the
SQL
statement to be executed and
T
0
is the identifier of the transaction in whose name the statement is to be executed.
The transaction identifier T
0
is not given as input when this is the first request for a
new transaction, because it is not yet known. In this case the coordinating server
s
0
creates a new transaction identifier T
0
, logs the begin-transaction log record,
and inserts a record for the new transaction in the active-transaction table. The
transaction identifier T
0
is returned to the requesting client and must be included
in subsequent requests for the same transaction.
If the
SQL
statement R touches remotely stored data, then in the procedure
process-
SQL
-request
, requests of the form .s
0
;T
0
;R
i
/ are sent to remote servers
s
i
to execute
SQL
statements R
i
that only touch data stored at s
i
. Such a request
is serviced at server s
i
with the procedure call
service-remote-
SQL
-request
.s;T;R
0
/
(Algorithm
13.2
). The result of the original statement R is computed from the results
returned for statements R
i
by these calls.
A distributed transaction T
0
is represented in the active-transaction table at the
coordinator with a transaction record
.T
0
;L;S;n/;