Information Technology Reference
In-Depth Information
Thus, each participant of a distributed transaction stores permanently at least the
identifiers of the coordinating server and the parent transaction.
Algorithm 13.1
Procedure
process-
SQL
-request
.T
0
;R/, executed at s
0
if
no transaction identifier T
0
was given
then
create a new transaction identifier T
0
log
.n;hT
0
;Bi/
insert record .T
0
;;; forward-rolling;n/to the active-transaction table
end if
transform R into an equivalent statement with arguments R
0
;:::;R
k
, where each R
i
touches
onlydatastoredatservers
i
, i D 1;:::;k (s
0
being the coordinator)
execute R
0
locally in the name of T
0
for
i D 1;:::;k
do
send a request .s
0
;T
0
;R
i
/ to s
i
to execute R
i
for T
0
if
s
i
is not yet in the list of participants of T
0
then
add s
i
to the list of participants of T
0
log
.n;hT
0
;
add-participant
;s
i
i/
end if
end for
wait for the requests to be serviced
compute the result of R from the results received for R
0
;:::;R
k
return the result of R with the transaction identifier T
0
Algorithm 13.2
Procedure
service-remote-
SQL
-request
.s
0
;T
0
;R
i
/, executed at s
i
if
the local active-transaction table contains no record for a subtransaction of T
0
coordinated by
server s
0
then
create a new transaction identifier T
i
log
.n;hT
i
;s
0
;T
0
;Bi/
insert record .T
i
;s
0
;T
0
;;; forward-rolling;n/to the active-transaction table
else
let T
i
be the active subtransaction of T
0
coordinated by s
0
end if
execute the SQL statement R
i
in the name of T
i
return the result of R
i
Example 13.1
Consider the transaction generated by the following fragment of an
application program:
exec sql update
r
set
V = 2
V ;
exec sql select sum
(V )
into
:
new_sum
from
r ;
exec sql commit
.
The execution of this transaction on a centralized database system was considered
in Example
1.1
.