
In general there 1s no solution that ehm-
mates the problems of LLTs Even d we use a
mechanism different from locking to ensure atom-
lclty of the LLTs, the long delays and/or the high
abort rate ~111 remam No matter how the
mechanism operates, a transactlon that needs to
access the objects that were accessed by a LLT
cannot commit until the LLT commits
However, for specific applreatsons lt may be
possible to alleviate the problems by relaxing the
requirement that an LLT be executed as an
atormc actlon
In other words, without sacrlficmg
the consistency of the database, it may be possl-
ble for certain LLTs to release their resources
before they complete, thus permitting other walt-
mg transactions to proceed
To illustrate this idea, consider an alrhne
reservation apphcatlon The database (or actu-
ally a collection of databases from different air-
lines) contams reservations for flights, and a tran-
saction
T
wishes to make a number of reserva-
tions, For this dlscusslon, let us assume that
T IS
a LLT (say It pauses for customer input after
each reservation) In this apphcatlon It may not
be necessary for
T
to hold on to all of its
resources until it completes For instance, after
T
reserves a seat on flight Fl, it could lmmedl-
ately allow other transactions to reserve seats on
the same flight In other words, we can view
T
as a collection of “sub-transactions”
T1, Tz,
,
T,,
that reserve the mdlvldual seats
However, we do not wish to submit
T
to the
database management system (DBMS) simply as
a collection of independent transactions because
we still want
T
to be a unit that IS either suc-
cessfully completed or not done at all
We would
not be satisfied with a DBMS that would allow
T
to reserve three out of five seats and then (due to
a crash) do nothmg more
On the other hand, we
would be satisfied with a DBMS that guaranteed
that
T
would make all of its reservations, or
would cancel any reservations made If
T
had to
be suspended
This example shows that a control mechan-
ism that 1s less rlgld than the conventional
atomic-transaction ones but still offers some
guarantees regardmg the execution of the com-
ponents of an LLT would be useful
In this paper
we will present such a mechamsm
Let us use the term eaga to refer to a LLT
that can be broken up mto a collection of sub-
transactions that can be mterleaved m any way
with other transactlons Each sub-transactlon m
this case 1s a real transaction m the sense that it,
preserves database consistency However, unlike
other transactions, the transactions m a saga are
related to each other and should be executed as a
(non-atomic) unit any partial executions of the
saga are undesirable, and if they occur, must be
compensated for
To amend partial executions, each saga
transaction
T,
should be provided with a com-
pensating transaction C, The compensatmg
transaction undoes, from a semantic point of
view, any of the actions performed by
T,,
but
does not necessarily return the database to the
state that existed when the execution of
T,
began In our airline example, if
T,
reserves a
seat on a flight, then C, can cancel the resewa-
tlon (say by subtracting one from the number of
reservations and performing some other checks)
But C, cannot simply store m the database the
number of seats that existed when
T,
ran because
other transactions could have run between the
time
T,
reserved the seat and C, canceled the
reservation, and could have changed the number
of reservations for this flight
Once compensating transactions Cl, Cs,
c
n-1 are defined for saga
T1, Tz, T,,,
then
the system can make the followmg guarantee
Either the sequence
Tl,
T2,
T?8
(which 1s the preferable one) or the sequence
TI,
T29
T,, C,,
c2,
Cl
for some 0 < J < 12 ~111 be executed
(Note that
other transactions might see the effects of a par-
tial saga execution When a compensatmg tran-
saction C, 1s run, no effort 1s made to notify or
abort transactions that nught have seen the
results of
T,
before they were compensated for by
c, 1
Sagas appear to be a relatively common
type of LLT
They occur when a LLT consists of
a sequence of relatively independent steps, where
each step does not have to observe the eame con-
sistent database state
For Instance, m a bank It
1s common to perform a fixed operation (e g ,
compute interest) on all accounts, and there 1s
very little interaction between the computations
for one account and the next In an office mfor-
matlon system, It IS also common to have LLTs
with independent steps that can be Interleaved
with those of other transactions For example,
receiving a purchase order mvolves entering the
250
评论