SlideShare ist ein Scribd-Unternehmen logo
1 von 93
Models of Transactions

       Chapter 19
Structuring Applications

• Many applications involve long transactions that
  make many database accesses

• To deal with such complex applications many
  transaction processing systems provide
  mechanisms for imposing some structure on
  transactions



                                                 2
Flat Transaction
• Consists of:
  – Computation on local variables          begin transaction
     • not seen by DBMS; hence will be
       ignored in most future discussion
                                             EXEC SQL …..
  – Access to DBMS using call or
    statement level interface
     • This is transaction schedule;         EXEC SQL …..
       commit applies to these operations
• No internal structure
                                            commit
• Accesses a single DBMS
• Adequate for simple applications
                                                            3
Flat Transaction

•   Abort causes the          begin transaction
    execution of a program
    that restores the          EXEC SQL …..
    variables updated by
    the transaction to the     EXEC SQL …..
    state they had when the
    transaction first           if condition then abort
    accessed them.
                              commit


                                                    4
Limitations of Flat Transactions
• Only total rollback (abort) is possible
   – Partial rollback not possible
• All work lost in case of crash
• Limited to accessing a single DBMS
• Entire transaction takes place at a single point in time




                                                         5
Providing Structure Within a
    Single Transaction




                               6
Savepoints
• Problem: Transaction detects condition that
  requires rollback of recent database changes
  that it has made
• Solution 1: Transaction reverses changes itself
• Solution 2: Transaction uses the rollback facility
  within DBMS to undo the changes




                                                    7
Savepoints              begin transaction
                             S1;
         Call to DBMS        sp1 := create_savepoint();
                             S2;
                             sp2 := create_savepoint();
                             S3;
                             if (condition) {rollback (sp1); S5};
                             S4;
                           commit
• Rollback to spi causes database updates subsequent to
  creation of spi to be undone
   – S2 and S3 updated the database (else there is no point
     rolling back over them)
• Program counter and local variables are not rolled back
• Savepoint creation does not make prior database changes
  durable (abort rolls all changes back)                  8
Example of Savepoints

• Suppose we are making airplane reservations
  for a long trip
   – London-NY NY-Chicago Chicago-Des Moines
• We might put savepoints after the code that made
  the London-NY and NY-Chicago reservations
• If we cannot get a reservation from Chicago to
  Des Moines, we would rollback to the savepoint
  after the London-NY reservation and then
  perhaps try to get a reservation through St Louis


                                                      9
Distributed Systems: Integration of
             Legacy Applications
• Problem: Many enterprises support multiple
  legacy systems doing separate tasks
    – Increasing automation requires that these
      systems be integrated

withdraw part
return part          Inventory          DBMS 1    Site B
stock level          Application

order part             Billing
payment                                 DBMS 2    Site C
                     Application

                                                     10
Distributed Transactions
• Incorporate transactions at multiple servers into a
  single (distributed) transaction
   – Not all distributed applications are legacy systems;
     some are built from scratch as distributed systems

tx_begin;                Inventory
                                            DBMS 1 Site B
  order_part;            Application
  withdraw_part;
  payment;               Billing
tx_commit;                                  DBMS 2 Site C
                         Application

   Site A

                                                       11
Distributed Transactions
• Goal: distributed transaction should be ACID
  – Each subtransaction is locally ACID (e.g., local
    constraints maintained, locally serializable)
  – In addition the transaction should be globally ACID
     • A: Either all subtransactions commit or all abort
     • C: Global integrity constraints are maintained
     • I: Concurrently executing distributed transactions are
       globally serializable
     • D: Each subtransaction is durable


                                                           12
Banking Example

• Global atomicity - funds transfer
  – Either both subtransactions commit
    or neither does
    tx_begin;
      withdraw(acct1);
      deposit(acct2);
    tx_commit;




                                         13
Banking Example (con’t)

• Global consistency -
  – Sum of all account balances at bank branches =
    total assets recorded at main office




                                                     14
Banking Example (con’t)
• Global isolation - local serializability at each site
  does not guarantee global serializability
   – post_interest subtransaction is serialized after
     audit subtransaction in DBMS at branch 1 and
     before audit in DBMS at branch 2 (local isolation),
     but
   – there is no global order
      post_interest                 audit
time
 ↓                               sum balances at branch 1;
    post interest at branch 1;
    post interest at branch 2;
                                 sum balances at branch 2;
                                                             15
Exported Interfaces
  Local system might export an interface for
  executing individual SQL statements.
              subtransaction
tx_begin;                           DBMS 1      site B
  EXEC SQL SELECT..
  EXEC SQL INSERT..
  EXEC SQL SELECT..                 DBMS 2      site C
tx_commit;
  site A         subtransaction

 Alternatively, the local system might export an interface
       for executing subtransactions.
                                                         16
Multidatabase
• Multidatabase (or federated database): set of
  databases accessed by a distributed transaction
  – Each database retains its autonomy and might
    support local (non-distributed) transactions
• Might have global integrity constraints
  – e.g., Sum of balances of individual bank accounts
    at all branch offices = total assets stored at main
    office



                                                      17
Transaction Hierarchy
• Subtransactions: invoked by a distributed transaction
• General model: one distributed transaction might
  invoke another as a subtransaction, yielding a
  hierarchical structure


                                   Distributed transactions




                                                         18
Models of Distributed Transactions

              • Can siblings execute concurrently?
              • Can parent execute concurrently
                with children?
              • Who initiates commit?



Hierarchical Model: No concurrency among
subtransactions, root initiates commit
Peer Model: Concurrency among siblings & between
parent and children, any of them can initiate commit
                                                  19
Distributed Transactions

• Transaction designer has little control over the
  structure.
  – Decomposition fixed by distribution of data
    and/or exported interfaces (legacy environment)


• Essentially a bottom-up design




                                                  20
Nested Transactions
• Problem: Lack of mechanisms that allow:
   – a top-down, functional decomposition of a
     transaction into subtransactions
   – individual subtransactions to abort without
     aborting the entire transaction
• Although a nested transaction looks similar to a
  distributed transaction, it is not conceived of as
  a tool for accessing a multidatabase


                                                   21
Characteristics of Nested Transactions
                 Parent:
                 • creates children to perform subtasks
                 • either sequentially or concurrently
                 • waits until all children complete
                 • no comm between parent and children.

Each subtransaction (together with its descendants):
• is isolated w.r.t. each sibling (and its descendants).
• hence, siblings are serializable,
• but order is not determined i.e. NT is non-deterministic.

Concurrent nested transactions are serializable.
                                                           22
Characteristics of Nested Transactions
              A subtransaction is atomic:
              • It can abort or commit independently of other
                subtransactions.
              • Commit is conditional on commit of parent
                (since child task is a subtask of parent task).
              • Abort causes abort of all subtransaction’s
                children.

 Nested transaction commits when root commits:
 • At that point updates of committed subtransactions
  are made durable.

                                                           23
Nested Transaction - Example
                                             Booking a flight from
            L -- DM C                        London to Des Moines
                             concurrent
                                                        C = commit
                                                        A = abort
     C L -- NY          C   NY -- DM
                                     sequential


  NY -- Chic -- DM A                concurrent    C
stop in Chicago             concurrent                NY -- StL -- DM
                                                         stop in St. Louis
                  C/A       A                C            C
           NY -- Chic   Chic -- DM        NY -- StL   StL -- DM
                                                                     24
Nested Transactions
                                         parent of all
                                         nested transactions


concurrent




     isolation
                 isolation
                             isolation
                                                         25
Characteristics of Nested Transactions

           Consistency:
           • Individual subtransactions are not
             necessarily consistent,
           • But nested transaction as a whole is
             consistent




                                                  26
Structuring to Increase
            Transaction Performance
• Problem: In models previously discussed, transactions
  generally lock items they accesses and hold locks until
  commit time to guarantee serializabiltiy
  acquire lock on x            release lock on x
        ↓                                 ↓
  T1: r(x:12) .. compute .. w(x:13) commit
  T2:       request read(x)            r(x:13) ..compute.. w(x:14) ..
                         ↑                    ↑

                      (wait)            acquire lock on x
• Eliminates bad interleavings, but limits concurrency
  and hence performance
                                                                  27
Example - Switch Sections
                                                     transaction moves
                                                     student from section
                                                     s1 to section s2,
                    Move(s1, s2)                     uses TestInc, Dec

Section abstr.

 L2 TestInc(s2)                                      Dec(s1)
Tuple abstr.
                               enrollments
 L1 Sel(t2)      Upd(t2)       stored in tuples         Upd(t1)
                               t1 and t2
Page abstr.

 L0     Rd(p2)    Rd(p2) Wr(p2)                      Rd(p1)        Wr(p1)
                                     tuples stored
                                     in pages
                    time             p1 and p2                              28
Structuring Applications into
    Multiple Transactions




                                29
Chained Transactions

• Problem 1 (trivial): Invoking begin_transaction at
  the start of each transaction involves
  communication overhead
• With chaining: a new transaction is started
  automatically for an application program when the
  program commits or aborts the previous one
  – This is the approach taken in SQL



                                                       30
Chained Transactions
                                                         transaction
                                                         starts
  begin transaction    begin transaction                 implicitly
   S1                   S1                   S1
  commit               commit               commit
   S2                  begin transaction     S2
  begin transaction     S2                   S3
   S3                   S3                  commit
  commit               commit

S2 not included in a   Equivalent since     Chaining
transaction since it   S2 does not access   equivalent
has no db operations   the database


                                                                 31
Chained Transactions
• Problem 2: If the system crashes during the
  execution of a long-running transaction,
  considerable work can be lost

• Chaining allows a transaction
  to be decomposed into sub-                       S1;
                                       S1         commit;
  transactions with intermediate       S2    =>    S2;
  commit points                        S3         commit;
                                      commit       S3;
•    Database updates are made                    commit;
    durable at intermediate points
    => less work is lost in a crash


                                                        32
Example
                     S1;   -- update recs 1 - 1000
                     commit;
                     S2;   -- update recs 1001 - 2000
                     commit;
                     S3;   -- update recs 2001 - 3000
                     commit;

Chaining compared with savepoints:
• Savepoint: explicit rollback to arbitrary savepoint; all
  updates lost in a crash
• Chaining: abort rolls back to last commit; only the
  updates of the most recent transaction lost in a crash

                                                        33
Atomicity and Chaining

• Transaction as a whole is not atomic. If crash
  occurs
  – DBMS cannot roll the entire transaction back
     • Initial subtransactions have committed,
        – Their updates are durable
        – The updates might have been accessed by other
          transactions (locks have been released)
  – Hence, the application must roll itself forward




                                                          34
Atomicity and Chaining
• Roll forward requires that on recovery the application
  can determine how much work has been committed
   – Each subtransaction must tell successor where it left off
• Communication between successive subtransactions
  cannot use local variables (they are lost in a crash)
   – Use database to communicate between subtransactions
          r(rec_index:0);
          S1;                  -- update records 1 - 1000
          w(rec_index:1000);    -- save index of last record updated
          commit;
          r(rec_index:1000);    -- get index of last record updated
          S2;                  -- update records 1001 – 2000
          w(rec_index:2000);
          commit;
                                                                       35
Isolation, Consistency and Chaining
• Transaction as a whole is not isolated.
  – Database state between successive subtransactions
    might change since locks are released
    (but performance improves)

       subtransaction 1                       subtransaction 2
T1: r(x:15)..w(x:24)..commit                 r(x:30)..
T2:                        ..w(x:30)..commit

• Subtransactions might not be consistent
  – Inconsistent intermediate states visible to concurrent
    transactions during execution or after a crash

                                                             36
Alternative Semantics for Chaining
      S1;
      chain;
      S2;
      chain;
      S3;
      commit;

• Chain commits the transaction (makes it durable) and starts
  a new transaction, but does not release locks
   – Individual transactions do not have to be consistent
   – Recovery is complicated (as before); rollforward required
   – No performance gain

                                                                 37
A Problem with Obtaining Atomicity
            with Chaining
• Suppose we use the first semantics for chaining
   – Subtransactions give up locks when they commit

• Suppose that after a subtransaction of a transaction T
  makes its changes to some item and commits
   – Another transaction changes the same item and commits
   – T would then like to abort
   – Based on our usual definition of chained transactions,
     atomicity cannot be achieved because of the committed
     subtransactions

                                                          38
Partial Atomicity
• Suppose we want to: achieve some measure of
  atomicity by undoing the effects of all the
  committed subtransactions when the overall
  transaction wants to abort
• We might think we can: undo the updates made
  by T by just restoring the values each item had
  when T started (physical logging)
  – This will not work



                                                    39
An Example

T1: Update(x)1,1 commit1,1      …          abort1
T2:                          Update(x) commit


If, when T1 aborts:
• we just restore the value of x to the value it had
  before T1 updated it,

• T2’s update would be lost


                                                       40
Compensation
• Compensation: is approach to this problem
• Intuition : instead of restoring a value physically,
  we restore it logically by executing a compensating
  transaction
   – In the student registration system, a Deregistration
     subtransaction compensates for a successful
     Registration subtransaction
   – Thus Registration increments the Enrollment attribute
     and Deregistration decrements that same attribute
      • Compensation works even if some other concurrent
        Registration subtransaction has also incremented
        Enrollment

                                                            41
Sagas
 An Extension To Chained Transactions That
         Achieves Partial Atomicity

• For each subtransaction, STi,j in a chained
  transaction Ti a compensating transaction,
  CTi,j is designed

• Thus if a transaction T1 consisting of 5 chained
  subtransactions aborts after the first 3
  subtransactions have committed, then
                   CT1,3CT1,2CT1,1
   ST1,1ST1,2ST1,3

will perform the desired compensation
                                                     42
Sagas and Atomicity
• With this type of compensation: when a
  transaction aborts, the value of every item it
  changed is eventually restored to the value it
  had before that transaction started
• However, complete atomicity is not guaranteed
  – Some other concurrent transaction might have
    read the changed value before it was restored to
    its original value




                                                       43
Declarative Transaction
              Demarcation

• We have already talked about two ways in which
  procedures can execute within a transaction
  – As a part of the transaction
     • Stored procedure
  – As a child in a nested transaction




                                               44
Declarative Transaction
          Demarcation (con’t)
• Two other possible ways
  – The calling transaction is suspended, and a new
    transaction is started. When it completes the
    first transaction continues
     • Example: The called procedure is at a site that charges
       for its services and wants to be paid even if the calling
       transaction aborts
  – The calling transaction is suspended, and the
    called procedure executes outside of any
    transaction. When it completes the first
    transaction continues
     • Example: The called procedure accesses a non-
       transactional file system

                                                                   45
Declarative Transaction
        Demarcation (con’t)
• One way to implement such alternatives is
  through declarative transaction demarcation
  – Declare in some data structure, outside of any
    transaction, the desired transactional behavior
  – When the procedure is called, the system
    intercepts the call and provides the desired
    behavior




                                                      46
Implementation of Declarative
      Transaction Demarcation

• Declarative transaction demarcation is
  implemented within J2EE and .NET
  – We discuss J2EE (.NET is similar)
• The desired transactional behavior of each
  procedure is declared as an attributed in a
  separate file called the deployment descriptor




                                                   47
Transaction Attributes
• Possible attributes (in J2EE) are
  –   Required
  –   RequiresNew
  –   Mandatory
  –   NotSupported
  –   Supports
  –   Never
• The behavior for each attribute depends on
  whether or not the procedure is called from
  within a procedure
  – All possibilities are on the next slide
                                                48
Status of Calling Method
Attribute of Called   Not in a          In a Transaction
Method                Transaction
Required              Starts a New      Executes Within
                      Transaction       the Transaction
RequiresNew           Starts a New      Starts a New
                      Transaction       Transaction

Mandatory             Exception         Executes Within
                      Thrown            the Transaction
NotSupported          Transaction Not   Transaction
                      Started           Suspended

Supports              Transaction Not   Executes Within
                      Started           the Transaction
Never                 Transaction Not   Exception
                      Started           Thrown


                      All Possibilities                    49
Description of Each Attribute
• Required:
  – The procedure must execute within a transaction
     • If called from outside a transaction, a new
       transaction is started
     • If called from within a transaction, it executes
       within that transaction




                                                          50
Description (con’t)
• RequiresNew:
  – Must execute within a new transaction
     • If called from outside a transaction, a new
       transaction is started
     • If called from within a transaction, that transaction
       is suspended and a new transaction is started.
       When that transaction completes, the first
       transaction resumes
        – Note that this semantics is different from nested
          transactions. In this case the commit of the new
          transaction is not conditional.


                                                               51
Description (con’t)
• Mandatory:
  – Must execute within an existing transaction
     • If called from outside a transaction, an exception is
       thrown
     • If called from within a transaction, it executes
       within that transaction




                                                           52
Description (con’t)
• NotSupported:
  – Does not support transaction
     • If called from outside a transaction, a transaction is
       not started
     • If called from inside a transaction, that transaction
       is suspended until the procedure completes after
       which the transaction resumes




                                                            53
Description (con’t)
• Supports:
  – Can execute within or not within a transaction,
    but cannot start a new transaction
     • If called from outside a transaction, a transaction is
       not started
     • If called from inside a transaction, it executes
       within that transaction




                                                            54
Description (con’t)
• Never:
  – Can never execute within a transaction
     • If called from outside a transaction, a new
       transaction is not started
     • If called from within a transaction, an exception is
       thrown




                                                              55
Example
• The Deposit and Withdraw transactions in a banking
  application would have attribute Required.
  – If called to perform a deposit, a new transaction
    would be started
  – If called from within a Transfer transaction to transfer
    money between accounts, they would execute within
    that transaction




                                                         56
Advantages
• Designer of individual procedures does not have to know
  the transactional context in which the procedure will be
  used
• The same procedure can be used in different transaction
  contexts
   – Different attributes are specified for each different context
• We discuss J2EE in more detail and how declarative
  transaction demarcation is implemented in J2EE in the
  Architecture chapter.



                                                                     57
Multilevel Transactions

• A multilevel transaction is a nested set of
  subtransactions.
   – The commitment of a subtransaction is
     unconditional, causing it to release its locks, but
   – Multilevel transactions are atomic and their
     concurrent execution is serializable




                                                      58
Multilevel Transactions

• Data is viewed as a sequence of increasing,
  application oriented, levels of abstraction
• Each level supports a set of abstract objects
  and abstract operations (methods) for
  accessing those objects
• Each abstract operation is implemented as a
  transaction using the abstractions at the next
  lower level


                                                   59
Example - Switch Sections
                                   transaction (sequential),
                                   moves student from one
                                   section to another,
                    Move(s1, s2)   uses TestInc, Dec
Section abstr.

 L2 TestInc(s2)                    Dec(s1)
Tuple abstr.

 L1 Sel(t2)      Upd(t2)             Upd(t1)
Page abstr.

 L0     Rd(p2)    Rd(p2) Wr(p2)    Rd(p1)       Wr(p1)

                    time                                60
Multilevel Transactions
• Parent initiates a single subtransaction at a time
  and waits for its completion.
   – Hence a multilevel transaction is sequential.
• All leaf subtransactions in the tree are at the
  same level
• Only leaf transactions access the database.
• Compare with distributed and nested models



                                                     61
Multilevel Transactions
• When a subtransaction (at any level) completes:
  – it commits unconditionally and
  – releases locks it has acquired on items at the
    next lower level.
  – TestInc(s2) locks t2; unlocks t2 when it commits
• Changes made to the locked item become visible to
  subtransactions of other transactions
  – Incremented value of t2 is visible to a subsequent
    execution of TestInc or Dec by conc. transactions
• Creates problems maintaining isolation & atomicity.
                                                         62
Maintaining Isolation

             p2 is unlocked
             when Sel commits
                       ↓
       TestInc1: Sel(t2)                 Upd(t2)
       TestInc2:         Sel(t2) Upd(t2)
                         ↑
                   Sel2 can lock p2

• Problem: Interleaved execution of two TestInc’s
  results in error (we will return to this later)

                                                   63
Maintaining Atomicity

Move1: TestInc(s2) Dec(s1)                            abort
Move2:                     TestInc(s3) Dec(s1) commit

• When T1 aborts, the value of s1 that existed prior to its
  access cannot simply be restored (physical restoration)
• Logical restoration must be done using compensating
  transactions
   – Inc compensates for Dec; Dec compensates for a successful
     TestInc; no compensation needed for unsuccessful TestInc




                                                          64
Compensating Transactions
• Multilevel model uses compensating transaction



                                                  logical restoration
                                                  (using compensation)
                                                  caused by abort


  T1: TestInc(s2) Dec(s1)                            Inc(s1) Dec(s2)
  T2:                     TestInc(s3) Dec(s1) commit



                                                                       65
Correctness of Multilevel
           Transactions
• As we shall see later:
  – Multilevel transactions are atomic
     • In contrast with Sagas, which also use
       compensation, but do not guarantee atomicity
  – Concurrent execution of multilevel transactions is
    serializable




                                                      66
Recoverable Queues
• Immediate: distributed model assumes that the
  subtransactions of a transaction follow one
  another immediately (or are concurrent).
• Eventually: some applications require that a
  subtransaction be eventually executed, but not
  necessarily immediately.
• Recoverable queue: a transactional data structure
  in which information about transactions to be
  executed later can be durably stored.


                                                   67
Transactional Features
T1: begin transaction;                      T2: begin transaction;
     compute;                                    dequeue(item);
     item := service       recoverable    perform requested
             description      queue                      service;
     enqueue(item);                      commit;
    commit;


    • Item is enqueued if T1 commits (deleted if it
      aborts); item is deleted if T2 commits
      (restored if it aborts)
    • An item enqueued by T1 cannot be dequeued
      by T2 until T1 commits
    • Queue is durable
                                                              68
Pipeline Queue for Billing Application


                shipping                 billing
                 queue                   queue



  order entry                shipping                 billing
  transaction              transaction             transaction




                                                                 69
Concurrent Implemention of the
      Same Application

                shipping      shipping
                 queue      transaction



  order entry
  transaction



                  billing      billing
                  queue     transaction

                                          70
Recoverable Queue
• Queue could be implemented within database, but
  performance suffers
  – A transaction should not hold long duration locks
    on a heavily used data structure


  acquire lock on queue in db                  release lock on queue
    ↓                                               ↓
  T1: enq(I1) …………..compute………………commit
  T2:      request enq(I2) (wait)                         enq(I2)
  T3:         request enq(I3) (wait)
  T4:                     request enq(I4) (wait) acquire lock on queue
                                                                       71
Recoverable Queue
• Separate implementation: takes advantage
  of semantics to improve performance
     – enqueue and dequeue are atomic and
       isolated, but some queue locks are released
       immediately
acquire lock on queue and entry I1
         release lock on queue       release lock on I 1



T1: enq(I1) …………..compute………………commit
T2:        enq(I2) …………….compute…………..
     acquire lock
T3: on queue and enq(I3) ………………..compute …………
                  I2
T4:                     enq(I4)…………….compute …..           72
Recoverable Queue
begin transaction
  select                             DBMS
  update
  enqueue
  select                          recoverable
  dequeue                            queue
commit

• Queue and DBMS are two separate systems
  – Transaction must be committed at both but
       • isolation is implemented at the DBMS and applies to
         the schedule of requests made to the DBMS only


                                                         73
Scheduling
• As a result, any scheduling policy for
  accessing the queue might be enforced
  – but a FIFO queue might not behave in a FIFO
    manner



T1: enq(I1) …commit                            restore I1
T2:             enq(I2) …commit
T3:                         deq(I1) …            abort
T4:                                 deq(I2) …commit

                                                       74
Performing Real-World Actions
• Roll-back?: A real-world action performed from
  within a transaction, T, cannot be rolled back if
  crash occurs before commit.
                 T: begin_transaction;
                      compute;
                                         crash
                      update database;
                      activate device;
                    commit;

• On recovery after a crash: how can we tell if
  the action has occurred?
   – ATM example: We do not want to
     dispense cash twice.
                                                      75
Performing Real-World Actions
 • Solution (part 1): T enqueues entry. If T aborts, item is
   dequeued; if T commits action executed later


   T               queue              TD          device

T: begin_transaction;         TD: begin_transaction;
     compute;                        dequeue entry;
     update database;                activate device;
     enqueue entry;                commit;
   commit;
  • Server executes TD in a loop
       – but problem still exists within TD
                                                               76
Performing Real-World Actions

 T            queue          TD              counter

                                              device
• Solution (part 2):
     – Device maintains read-only counter (hardware) that
       is automatically incremented with each action
        • Action and increment are assumed to occur
          atomically
     – Server performs:      TD: begin_transaction;
                                   dequeue;
                                   activate device;
                                   record counter in db;
                                 commit;                   77
Performing Real-World Actions

• On recovery:

     Restore queue and database
     if (device value > recorded value)
           then discard head entry;
     Restart server;



                                          78
Example of Real World Action
• Suppose the hardware counter and the database counter
  were both at 100 before the transaction started
   – When the hardware performs its action, it increments its
     counter to 101
   – TD would then increment the database counter to 101
• If the system crashed after the hardware performed its
  action the database increment (if it had occurred) would
  be rolled back to 100
• Thus when the system recovered
   – If the hardware counter was 101 and the database counter
     was 100, we would know that the action had been
     performed.
   – If both counters were the same (100), we would know that
     the action had not taken place.
                                                                79
Forwarding Agent
  • Implementing deferred service:

             enqueue                      invoke
                        dequeue
    client                        agent            server
                                          reply

                  Request
                   queue

                  Response
       dequeue     queue     enqueue

• In general: there are multiple clients (producers) and
multiple servers (consumers)                             80
Workflows

• Flexibility: None of the previous models are
  sufficiently flexible to describe complex, long-
  running enterprise processes involving
  computational and non-computational tasks in
  distributed, heterogeneous systems over
  extended periods of time




                                                     81
Workflow Task
• Self-contained job performed by an agent
  – Inventory transaction (agent = database server)
  – Packing task (agent = human)
• Has an associated role that defines type of job
  – An agent can perform specified roles
• Accepts input from other tasks, produces output
• Has physical status: committed, aborted, ...
  – Committed task has logical status: success, failure




                                                      82
Workflow
• Task execution precedence specified
  separately from task itself
  – using control flow language:
      initiate T2, T3 when T1 committed
  – or using graphical tool:

                          T2
             T1

                          T3       AND condition
           concurrency

                                                   83
Workflow

• Conditional alternatives can be specified:
    if (condition) execute T1 else execute T2
• Conditions:
  – Logical/physical status of a task
  – Time of day
  – Value of a variable output by a task
• Alternative paths can be specified in case of
  task failure

                                                  84
Workflow
• Specifies flow of data between tasks




                         T2
               T1

                         T3



                                         85
Execution Precedence in a
         Catalog Ordering System

                                           O
                           bill            R
           AND                             OR       by
                                                    air
take
         update   remove      package   shipping             complete
order

                                                   by land




                                                                   86
Flow of Data in a Catalog
            Ordering System

                           bill
                                                    by
                                                    air
take
         update   remove      package   shipping             complete
order

                                                   by land




                                                                   87
Workflow Agent

•   Capable of performing tasks
•   Has a set of associated roles describing tasks it can do
•   Has a worklist listing tasks that have been assigned to it
•   Possible implementation:
    – Worklist stored in a recoverable queue
    – Agent is an infinitely looping process that processes one
      queue element on each iteration




                                                                  88
Workflow and ACID Properties
• Individual tasks might be ACID, but workflow as
  a whole is not
  – Some task might not be essential: its failure is
    ignored even though workflow completes
  – Concurrent workflows might see each other’s
    intermediate state
  – Might not choose to compensate for a task even
    though workflow fails




                                                       89
Workflow and ACID Properties
• Each task is either
   – Retriable: Can ultimately be made to commit if
     retried a sufficient number of times (e.g., deposit)
   – Compensatable: Compensating task exists (e.g.,
     withdraw)
   – Pivot: Neither retriable nor compensatable (e.g.,
     buy a non-refundable ticket)




                                                       90
Workflow and ACID Properties

• The atomicity of a workflow is guaranteed if
  each execution path is characterized by
      {compensatable}* [pivot] {retriable}*
• This does not guarantee isolation since
  intermediate states are visible




                                                 91
Workflow Management System
• Provides mechanism for specifying workflow
  (control flow language, GUI)
• Provides mechanism for controlling execution of
  concurrent workflows:
  –   Roles and agents
  –   Worklists and load balancing
  –   Filters (data reformatting) and controls flow of data
  –   Task activation
  –   Maintain workflow state durably (data, task status)
  –   Use of recoverable queues
  –   Failure recovery of WFMS itself (resume workflows)
                                                        92
Importance of Workflows
• Allows management of an enterprise to
  guarantee that certain activities are carried out
  in accordance with established business rules,
  even though those activities involve a collection
  of agents, perhaps in different locations and
  perhaps with minimal training




                                                  93

Weitere ähnliche Inhalte

Andere mochten auch

Database operation with nested transaction handling
Database operation with nested transaction handlingDatabase operation with nested transaction handling
Database operation with nested transaction handlingAshwinPoojary
 
04 transaction models
04 transaction models04 transaction models
04 transaction modelsashish61_scs
 
Database ,10 Transactions
Database ,10 TransactionsDatabase ,10 Transactions
Database ,10 TransactionsAli Usman
 
SQL Server Transaction Management
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction ManagementDenise McInerney
 
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...slashn
 
Transactions (Distributed computing)
Transactions (Distributed computing)Transactions (Distributed computing)
Transactions (Distributed computing)Sri Prasanna
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactionsNilu Desai
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlbalamurugan.k Kalibalamurugan
 
Lecture 11 - distributed database
Lecture 11 - distributed databaseLecture 11 - distributed database
Lecture 11 - distributed databaseHoneySah
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency controlAbDul ThaYyal
 
Transaction slide
Transaction slideTransaction slide
Transaction slideshawon roy
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating SystemsDr Sandeep Kumar Poonia
 
Distributed database management systems
Distributed database management systemsDistributed database management systems
Distributed database management systemsDhani Ahmad
 

Andere mochten auch (20)

Database operation with nested transaction handling
Database operation with nested transaction handlingDatabase operation with nested transaction handling
Database operation with nested transaction handling
 
Lec13s transaction
Lec13s transactionLec13s transaction
Lec13s transaction
 
04 transaction models
04 transaction models04 transaction models
04 transaction models
 
Database ,10 Transactions
Database ,10 TransactionsDatabase ,10 Transactions
Database ,10 Transactions
 
SQL Server Transaction Management
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction Management
 
Database Management & Models
Database Management & ModelsDatabase Management & Models
Database Management & Models
 
distributed dbms
distributed dbmsdistributed dbms
distributed dbms
 
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
Slash n: Tech Talk Track 2 – Distributed Transactions in SOA - Yogi Kulkarni,...
 
Distributed Operating System_4
Distributed Operating System_4Distributed Operating System_4
Distributed Operating System_4
 
Transactions (Distributed computing)
Transactions (Distributed computing)Transactions (Distributed computing)
Transactions (Distributed computing)
 
Distributed Transaction
Distributed TransactionDistributed Transaction
Distributed Transaction
 
management of distributed transactions
management of distributed transactionsmanagement of distributed transactions
management of distributed transactions
 
Distributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency controlDistributed datababase Transaction and concurrency control
Distributed datababase Transaction and concurrency control
 
6.Distributed Operating Systems
6.Distributed Operating Systems6.Distributed Operating Systems
6.Distributed Operating Systems
 
Lecture 11 - distributed database
Lecture 11 - distributed databaseLecture 11 - distributed database
Lecture 11 - distributed database
 
4. concurrency control
4. concurrency control4. concurrency control
4. concurrency control
 
Distributed Operating System_1
Distributed Operating System_1Distributed Operating System_1
Distributed Operating System_1
 
Transaction slide
Transaction slideTransaction slide
Transaction slide
 
8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems8. mutual exclusion in Distributed Operating Systems
8. mutual exclusion in Distributed Operating Systems
 
Distributed database management systems
Distributed database management systemsDistributed database management systems
Distributed database management systems
 

Ähnlich wie A

Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency controlAnand Grewal
 
Navigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesNavigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesShivji Kumar Jha
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Mydbops
 
Database , 13 Replication
Database , 13 ReplicationDatabase , 13 Replication
Database , 13 ReplicationAli Usman
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxhritikraj888
 
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnReactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnZalando Technology
 
The Power of Determinism in Database Systems
The Power of Determinism in Database SystemsThe Power of Determinism in Database Systems
The Power of Determinism in Database SystemsDaniel Abadi
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mangkhoahuy82
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on TransactionRahul Prajapati
 
Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Paradigma Digital
 
Educational seminar lessons learned from customer db2 for z os health check...
Educational seminar   lessons learned from customer db2 for z os health check...Educational seminar   lessons learned from customer db2 for z os health check...
Educational seminar lessons learned from customer db2 for z os health check...John Campbell
 
Refactoring to a system of systems
Refactoring to a system of systemsRefactoring to a system of systems
Refactoring to a system of systemsVMware Tanzu
 
Architecting for the cloud elasticity security
Architecting for the cloud elasticity securityArchitecting for the cloud elasticity security
Architecting for the cloud elasticity securityLen Bass
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMJonas Bonér
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfHiroshi Ono
 

Ähnlich wie A (20)

Transaction concurrency control
Transaction concurrency controlTransaction concurrency control
Transaction concurrency control
 
Navigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern DatabasesNavigating Transactions: ACID Complexity in Modern Databases
Navigating Transactions: ACID Complexity in Modern Databases
 
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
Navigating Transactions: ACID Complexity in Modern Databases- Mydbops Open So...
 
Database , 13 Replication
Database , 13 ReplicationDatabase , 13 Replication
Database , 13 Replication
 
Hbase hivepig
Hbase hivepigHbase hivepig
Hbase hivepig
 
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptxFALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
FALLSEM2023-24_BCSE302L_TH_VL2023240100957_2023-06-21_Reference-Material-I.pptx
 
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland KuhnReactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
Reactive Design Patterns: a talk by Typesafe's Dr. Roland Kuhn
 
The Power of Determinism in Database Systems
The Power of Determinism in Database SystemsThe Power of Determinism in Database Systems
The Power of Determinism in Database Systems
 
Hbase hive pig
Hbase hive pigHbase hive pig
Hbase hive pig
 
7. transaction mang
7. transaction mang7. transaction mang
7. transaction mang
 
Presentation on Transaction
Presentation on TransactionPresentation on Transaction
Presentation on Transaction
 
Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?
 
Educational seminar lessons learned from customer db2 for z os health check...
Educational seminar   lessons learned from customer db2 for z os health check...Educational seminar   lessons learned from customer db2 for z os health check...
Educational seminar lessons learned from customer db2 for z os health check...
 
Refactoring to a system of systems
Refactoring to a system of systemsRefactoring to a system of systems
Refactoring to a system of systems
 
Unit 06 dbms
Unit 06 dbmsUnit 06 dbms
Unit 06 dbms
 
Architecting for the cloud elasticity security
Architecting for the cloud elasticity securityArchitecting for the cloud elasticity security
Architecting for the cloud elasticity security
 
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVMState: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
State: You're Doing It Wrong - Alternative Concurrency Paradigms For The JVM
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
 
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdfstateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
stateyouredoingitwrongjavaone2009-090617031310-phpapp02.pdf
 

Kürzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Kürzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

A

  • 2. Structuring Applications • Many applications involve long transactions that make many database accesses • To deal with such complex applications many transaction processing systems provide mechanisms for imposing some structure on transactions 2
  • 3. Flat Transaction • Consists of: – Computation on local variables begin transaction • not seen by DBMS; hence will be ignored in most future discussion EXEC SQL ….. – Access to DBMS using call or statement level interface • This is transaction schedule; EXEC SQL ….. commit applies to these operations • No internal structure commit • Accesses a single DBMS • Adequate for simple applications 3
  • 4. Flat Transaction • Abort causes the begin transaction execution of a program that restores the EXEC SQL ….. variables updated by the transaction to the EXEC SQL ….. state they had when the transaction first if condition then abort accessed them. commit 4
  • 5. Limitations of Flat Transactions • Only total rollback (abort) is possible – Partial rollback not possible • All work lost in case of crash • Limited to accessing a single DBMS • Entire transaction takes place at a single point in time 5
  • 6. Providing Structure Within a Single Transaction 6
  • 7. Savepoints • Problem: Transaction detects condition that requires rollback of recent database changes that it has made • Solution 1: Transaction reverses changes itself • Solution 2: Transaction uses the rollback facility within DBMS to undo the changes 7
  • 8. Savepoints begin transaction S1; Call to DBMS sp1 := create_savepoint(); S2; sp2 := create_savepoint(); S3; if (condition) {rollback (sp1); S5}; S4; commit • Rollback to spi causes database updates subsequent to creation of spi to be undone – S2 and S3 updated the database (else there is no point rolling back over them) • Program counter and local variables are not rolled back • Savepoint creation does not make prior database changes durable (abort rolls all changes back) 8
  • 9. Example of Savepoints • Suppose we are making airplane reservations for a long trip – London-NY NY-Chicago Chicago-Des Moines • We might put savepoints after the code that made the London-NY and NY-Chicago reservations • If we cannot get a reservation from Chicago to Des Moines, we would rollback to the savepoint after the London-NY reservation and then perhaps try to get a reservation through St Louis 9
  • 10. Distributed Systems: Integration of Legacy Applications • Problem: Many enterprises support multiple legacy systems doing separate tasks – Increasing automation requires that these systems be integrated withdraw part return part Inventory DBMS 1 Site B stock level Application order part Billing payment DBMS 2 Site C Application 10
  • 11. Distributed Transactions • Incorporate transactions at multiple servers into a single (distributed) transaction – Not all distributed applications are legacy systems; some are built from scratch as distributed systems tx_begin; Inventory DBMS 1 Site B order_part; Application withdraw_part; payment; Billing tx_commit; DBMS 2 Site C Application Site A 11
  • 12. Distributed Transactions • Goal: distributed transaction should be ACID – Each subtransaction is locally ACID (e.g., local constraints maintained, locally serializable) – In addition the transaction should be globally ACID • A: Either all subtransactions commit or all abort • C: Global integrity constraints are maintained • I: Concurrently executing distributed transactions are globally serializable • D: Each subtransaction is durable 12
  • 13. Banking Example • Global atomicity - funds transfer – Either both subtransactions commit or neither does tx_begin; withdraw(acct1); deposit(acct2); tx_commit; 13
  • 14. Banking Example (con’t) • Global consistency - – Sum of all account balances at bank branches = total assets recorded at main office 14
  • 15. Banking Example (con’t) • Global isolation - local serializability at each site does not guarantee global serializability – post_interest subtransaction is serialized after audit subtransaction in DBMS at branch 1 and before audit in DBMS at branch 2 (local isolation), but – there is no global order post_interest audit time ↓ sum balances at branch 1; post interest at branch 1; post interest at branch 2; sum balances at branch 2; 15
  • 16. Exported Interfaces Local system might export an interface for executing individual SQL statements. subtransaction tx_begin; DBMS 1 site B EXEC SQL SELECT.. EXEC SQL INSERT.. EXEC SQL SELECT.. DBMS 2 site C tx_commit; site A subtransaction Alternatively, the local system might export an interface for executing subtransactions. 16
  • 17. Multidatabase • Multidatabase (or federated database): set of databases accessed by a distributed transaction – Each database retains its autonomy and might support local (non-distributed) transactions • Might have global integrity constraints – e.g., Sum of balances of individual bank accounts at all branch offices = total assets stored at main office 17
  • 18. Transaction Hierarchy • Subtransactions: invoked by a distributed transaction • General model: one distributed transaction might invoke another as a subtransaction, yielding a hierarchical structure Distributed transactions 18
  • 19. Models of Distributed Transactions • Can siblings execute concurrently? • Can parent execute concurrently with children? • Who initiates commit? Hierarchical Model: No concurrency among subtransactions, root initiates commit Peer Model: Concurrency among siblings & between parent and children, any of them can initiate commit 19
  • 20. Distributed Transactions • Transaction designer has little control over the structure. – Decomposition fixed by distribution of data and/or exported interfaces (legacy environment) • Essentially a bottom-up design 20
  • 21. Nested Transactions • Problem: Lack of mechanisms that allow: – a top-down, functional decomposition of a transaction into subtransactions – individual subtransactions to abort without aborting the entire transaction • Although a nested transaction looks similar to a distributed transaction, it is not conceived of as a tool for accessing a multidatabase 21
  • 22. Characteristics of Nested Transactions Parent: • creates children to perform subtasks • either sequentially or concurrently • waits until all children complete • no comm between parent and children. Each subtransaction (together with its descendants): • is isolated w.r.t. each sibling (and its descendants). • hence, siblings are serializable, • but order is not determined i.e. NT is non-deterministic. Concurrent nested transactions are serializable. 22
  • 23. Characteristics of Nested Transactions A subtransaction is atomic: • It can abort or commit independently of other subtransactions. • Commit is conditional on commit of parent (since child task is a subtask of parent task). • Abort causes abort of all subtransaction’s children. Nested transaction commits when root commits: • At that point updates of committed subtransactions are made durable. 23
  • 24. Nested Transaction - Example Booking a flight from L -- DM C London to Des Moines concurrent C = commit A = abort C L -- NY C NY -- DM sequential NY -- Chic -- DM A concurrent C stop in Chicago concurrent NY -- StL -- DM stop in St. Louis C/A A C C NY -- Chic Chic -- DM NY -- StL StL -- DM 24
  • 25. Nested Transactions parent of all nested transactions concurrent isolation isolation isolation 25
  • 26. Characteristics of Nested Transactions Consistency: • Individual subtransactions are not necessarily consistent, • But nested transaction as a whole is consistent 26
  • 27. Structuring to Increase Transaction Performance • Problem: In models previously discussed, transactions generally lock items they accesses and hold locks until commit time to guarantee serializabiltiy acquire lock on x release lock on x ↓ ↓ T1: r(x:12) .. compute .. w(x:13) commit T2: request read(x) r(x:13) ..compute.. w(x:14) .. ↑ ↑ (wait) acquire lock on x • Eliminates bad interleavings, but limits concurrency and hence performance 27
  • 28. Example - Switch Sections transaction moves student from section s1 to section s2, Move(s1, s2) uses TestInc, Dec Section abstr. L2 TestInc(s2) Dec(s1) Tuple abstr. enrollments L1 Sel(t2) Upd(t2) stored in tuples Upd(t1) t1 and t2 Page abstr. L0 Rd(p2) Rd(p2) Wr(p2) Rd(p1) Wr(p1) tuples stored in pages time p1 and p2 28
  • 29. Structuring Applications into Multiple Transactions 29
  • 30. Chained Transactions • Problem 1 (trivial): Invoking begin_transaction at the start of each transaction involves communication overhead • With chaining: a new transaction is started automatically for an application program when the program commits or aborts the previous one – This is the approach taken in SQL 30
  • 31. Chained Transactions transaction starts begin transaction begin transaction implicitly S1 S1 S1 commit commit commit S2 begin transaction S2 begin transaction S2 S3 S3 S3 commit commit commit S2 not included in a Equivalent since Chaining transaction since it S2 does not access equivalent has no db operations the database 31
  • 32. Chained Transactions • Problem 2: If the system crashes during the execution of a long-running transaction, considerable work can be lost • Chaining allows a transaction to be decomposed into sub- S1; S1 commit; transactions with intermediate S2 => S2; commit points S3 commit; commit S3; • Database updates are made commit; durable at intermediate points => less work is lost in a crash 32
  • 33. Example S1; -- update recs 1 - 1000 commit; S2; -- update recs 1001 - 2000 commit; S3; -- update recs 2001 - 3000 commit; Chaining compared with savepoints: • Savepoint: explicit rollback to arbitrary savepoint; all updates lost in a crash • Chaining: abort rolls back to last commit; only the updates of the most recent transaction lost in a crash 33
  • 34. Atomicity and Chaining • Transaction as a whole is not atomic. If crash occurs – DBMS cannot roll the entire transaction back • Initial subtransactions have committed, – Their updates are durable – The updates might have been accessed by other transactions (locks have been released) – Hence, the application must roll itself forward 34
  • 35. Atomicity and Chaining • Roll forward requires that on recovery the application can determine how much work has been committed – Each subtransaction must tell successor where it left off • Communication between successive subtransactions cannot use local variables (they are lost in a crash) – Use database to communicate between subtransactions r(rec_index:0); S1; -- update records 1 - 1000 w(rec_index:1000); -- save index of last record updated commit; r(rec_index:1000); -- get index of last record updated S2; -- update records 1001 – 2000 w(rec_index:2000); commit; 35
  • 36. Isolation, Consistency and Chaining • Transaction as a whole is not isolated. – Database state between successive subtransactions might change since locks are released (but performance improves) subtransaction 1 subtransaction 2 T1: r(x:15)..w(x:24)..commit r(x:30).. T2: ..w(x:30)..commit • Subtransactions might not be consistent – Inconsistent intermediate states visible to concurrent transactions during execution or after a crash 36
  • 37. Alternative Semantics for Chaining S1; chain; S2; chain; S3; commit; • Chain commits the transaction (makes it durable) and starts a new transaction, but does not release locks – Individual transactions do not have to be consistent – Recovery is complicated (as before); rollforward required – No performance gain 37
  • 38. A Problem with Obtaining Atomicity with Chaining • Suppose we use the first semantics for chaining – Subtransactions give up locks when they commit • Suppose that after a subtransaction of a transaction T makes its changes to some item and commits – Another transaction changes the same item and commits – T would then like to abort – Based on our usual definition of chained transactions, atomicity cannot be achieved because of the committed subtransactions 38
  • 39. Partial Atomicity • Suppose we want to: achieve some measure of atomicity by undoing the effects of all the committed subtransactions when the overall transaction wants to abort • We might think we can: undo the updates made by T by just restoring the values each item had when T started (physical logging) – This will not work 39
  • 40. An Example T1: Update(x)1,1 commit1,1 … abort1 T2: Update(x) commit If, when T1 aborts: • we just restore the value of x to the value it had before T1 updated it, • T2’s update would be lost 40
  • 41. Compensation • Compensation: is approach to this problem • Intuition : instead of restoring a value physically, we restore it logically by executing a compensating transaction – In the student registration system, a Deregistration subtransaction compensates for a successful Registration subtransaction – Thus Registration increments the Enrollment attribute and Deregistration decrements that same attribute • Compensation works even if some other concurrent Registration subtransaction has also incremented Enrollment 41
  • 42. Sagas An Extension To Chained Transactions That Achieves Partial Atomicity • For each subtransaction, STi,j in a chained transaction Ti a compensating transaction, CTi,j is designed • Thus if a transaction T1 consisting of 5 chained subtransactions aborts after the first 3 subtransactions have committed, then CT1,3CT1,2CT1,1 ST1,1ST1,2ST1,3 will perform the desired compensation 42
  • 43. Sagas and Atomicity • With this type of compensation: when a transaction aborts, the value of every item it changed is eventually restored to the value it had before that transaction started • However, complete atomicity is not guaranteed – Some other concurrent transaction might have read the changed value before it was restored to its original value 43
  • 44. Declarative Transaction Demarcation • We have already talked about two ways in which procedures can execute within a transaction – As a part of the transaction • Stored procedure – As a child in a nested transaction 44
  • 45. Declarative Transaction Demarcation (con’t) • Two other possible ways – The calling transaction is suspended, and a new transaction is started. When it completes the first transaction continues • Example: The called procedure is at a site that charges for its services and wants to be paid even if the calling transaction aborts – The calling transaction is suspended, and the called procedure executes outside of any transaction. When it completes the first transaction continues • Example: The called procedure accesses a non- transactional file system 45
  • 46. Declarative Transaction Demarcation (con’t) • One way to implement such alternatives is through declarative transaction demarcation – Declare in some data structure, outside of any transaction, the desired transactional behavior – When the procedure is called, the system intercepts the call and provides the desired behavior 46
  • 47. Implementation of Declarative Transaction Demarcation • Declarative transaction demarcation is implemented within J2EE and .NET – We discuss J2EE (.NET is similar) • The desired transactional behavior of each procedure is declared as an attributed in a separate file called the deployment descriptor 47
  • 48. Transaction Attributes • Possible attributes (in J2EE) are – Required – RequiresNew – Mandatory – NotSupported – Supports – Never • The behavior for each attribute depends on whether or not the procedure is called from within a procedure – All possibilities are on the next slide 48
  • 49. Status of Calling Method Attribute of Called Not in a In a Transaction Method Transaction Required Starts a New Executes Within Transaction the Transaction RequiresNew Starts a New Starts a New Transaction Transaction Mandatory Exception Executes Within Thrown the Transaction NotSupported Transaction Not Transaction Started Suspended Supports Transaction Not Executes Within Started the Transaction Never Transaction Not Exception Started Thrown All Possibilities 49
  • 50. Description of Each Attribute • Required: – The procedure must execute within a transaction • If called from outside a transaction, a new transaction is started • If called from within a transaction, it executes within that transaction 50
  • 51. Description (con’t) • RequiresNew: – Must execute within a new transaction • If called from outside a transaction, a new transaction is started • If called from within a transaction, that transaction is suspended and a new transaction is started. When that transaction completes, the first transaction resumes – Note that this semantics is different from nested transactions. In this case the commit of the new transaction is not conditional. 51
  • 52. Description (con’t) • Mandatory: – Must execute within an existing transaction • If called from outside a transaction, an exception is thrown • If called from within a transaction, it executes within that transaction 52
  • 53. Description (con’t) • NotSupported: – Does not support transaction • If called from outside a transaction, a transaction is not started • If called from inside a transaction, that transaction is suspended until the procedure completes after which the transaction resumes 53
  • 54. Description (con’t) • Supports: – Can execute within or not within a transaction, but cannot start a new transaction • If called from outside a transaction, a transaction is not started • If called from inside a transaction, it executes within that transaction 54
  • 55. Description (con’t) • Never: – Can never execute within a transaction • If called from outside a transaction, a new transaction is not started • If called from within a transaction, an exception is thrown 55
  • 56. Example • The Deposit and Withdraw transactions in a banking application would have attribute Required. – If called to perform a deposit, a new transaction would be started – If called from within a Transfer transaction to transfer money between accounts, they would execute within that transaction 56
  • 57. Advantages • Designer of individual procedures does not have to know the transactional context in which the procedure will be used • The same procedure can be used in different transaction contexts – Different attributes are specified for each different context • We discuss J2EE in more detail and how declarative transaction demarcation is implemented in J2EE in the Architecture chapter. 57
  • 58. Multilevel Transactions • A multilevel transaction is a nested set of subtransactions. – The commitment of a subtransaction is unconditional, causing it to release its locks, but – Multilevel transactions are atomic and their concurrent execution is serializable 58
  • 59. Multilevel Transactions • Data is viewed as a sequence of increasing, application oriented, levels of abstraction • Each level supports a set of abstract objects and abstract operations (methods) for accessing those objects • Each abstract operation is implemented as a transaction using the abstractions at the next lower level 59
  • 60. Example - Switch Sections transaction (sequential), moves student from one section to another, Move(s1, s2) uses TestInc, Dec Section abstr. L2 TestInc(s2) Dec(s1) Tuple abstr. L1 Sel(t2) Upd(t2) Upd(t1) Page abstr. L0 Rd(p2) Rd(p2) Wr(p2) Rd(p1) Wr(p1) time 60
  • 61. Multilevel Transactions • Parent initiates a single subtransaction at a time and waits for its completion. – Hence a multilevel transaction is sequential. • All leaf subtransactions in the tree are at the same level • Only leaf transactions access the database. • Compare with distributed and nested models 61
  • 62. Multilevel Transactions • When a subtransaction (at any level) completes: – it commits unconditionally and – releases locks it has acquired on items at the next lower level. – TestInc(s2) locks t2; unlocks t2 when it commits • Changes made to the locked item become visible to subtransactions of other transactions – Incremented value of t2 is visible to a subsequent execution of TestInc or Dec by conc. transactions • Creates problems maintaining isolation & atomicity. 62
  • 63. Maintaining Isolation p2 is unlocked when Sel commits ↓ TestInc1: Sel(t2) Upd(t2) TestInc2: Sel(t2) Upd(t2) ↑ Sel2 can lock p2 • Problem: Interleaved execution of two TestInc’s results in error (we will return to this later) 63
  • 64. Maintaining Atomicity Move1: TestInc(s2) Dec(s1) abort Move2: TestInc(s3) Dec(s1) commit • When T1 aborts, the value of s1 that existed prior to its access cannot simply be restored (physical restoration) • Logical restoration must be done using compensating transactions – Inc compensates for Dec; Dec compensates for a successful TestInc; no compensation needed for unsuccessful TestInc 64
  • 65. Compensating Transactions • Multilevel model uses compensating transaction logical restoration (using compensation) caused by abort T1: TestInc(s2) Dec(s1) Inc(s1) Dec(s2) T2: TestInc(s3) Dec(s1) commit 65
  • 66. Correctness of Multilevel Transactions • As we shall see later: – Multilevel transactions are atomic • In contrast with Sagas, which also use compensation, but do not guarantee atomicity – Concurrent execution of multilevel transactions is serializable 66
  • 67. Recoverable Queues • Immediate: distributed model assumes that the subtransactions of a transaction follow one another immediately (or are concurrent). • Eventually: some applications require that a subtransaction be eventually executed, but not necessarily immediately. • Recoverable queue: a transactional data structure in which information about transactions to be executed later can be durably stored. 67
  • 68. Transactional Features T1: begin transaction; T2: begin transaction; compute; dequeue(item); item := service recoverable perform requested description queue service; enqueue(item); commit; commit; • Item is enqueued if T1 commits (deleted if it aborts); item is deleted if T2 commits (restored if it aborts) • An item enqueued by T1 cannot be dequeued by T2 until T1 commits • Queue is durable 68
  • 69. Pipeline Queue for Billing Application shipping billing queue queue order entry shipping billing transaction transaction transaction 69
  • 70. Concurrent Implemention of the Same Application shipping shipping queue transaction order entry transaction billing billing queue transaction 70
  • 71. Recoverable Queue • Queue could be implemented within database, but performance suffers – A transaction should not hold long duration locks on a heavily used data structure acquire lock on queue in db release lock on queue ↓ ↓ T1: enq(I1) …………..compute………………commit T2: request enq(I2) (wait) enq(I2) T3: request enq(I3) (wait) T4: request enq(I4) (wait) acquire lock on queue 71
  • 72. Recoverable Queue • Separate implementation: takes advantage of semantics to improve performance – enqueue and dequeue are atomic and isolated, but some queue locks are released immediately acquire lock on queue and entry I1 release lock on queue release lock on I 1 T1: enq(I1) …………..compute………………commit T2: enq(I2) …………….compute………….. acquire lock T3: on queue and enq(I3) ………………..compute ………… I2 T4: enq(I4)…………….compute ….. 72
  • 73. Recoverable Queue begin transaction select DBMS update enqueue select recoverable dequeue queue commit • Queue and DBMS are two separate systems – Transaction must be committed at both but • isolation is implemented at the DBMS and applies to the schedule of requests made to the DBMS only 73
  • 74. Scheduling • As a result, any scheduling policy for accessing the queue might be enforced – but a FIFO queue might not behave in a FIFO manner T1: enq(I1) …commit restore I1 T2: enq(I2) …commit T3: deq(I1) … abort T4: deq(I2) …commit 74
  • 75. Performing Real-World Actions • Roll-back?: A real-world action performed from within a transaction, T, cannot be rolled back if crash occurs before commit. T: begin_transaction; compute; crash update database; activate device; commit; • On recovery after a crash: how can we tell if the action has occurred? – ATM example: We do not want to dispense cash twice. 75
  • 76. Performing Real-World Actions • Solution (part 1): T enqueues entry. If T aborts, item is dequeued; if T commits action executed later T queue TD device T: begin_transaction; TD: begin_transaction; compute; dequeue entry; update database; activate device; enqueue entry; commit; commit; • Server executes TD in a loop – but problem still exists within TD 76
  • 77. Performing Real-World Actions T queue TD counter device • Solution (part 2): – Device maintains read-only counter (hardware) that is automatically incremented with each action • Action and increment are assumed to occur atomically – Server performs: TD: begin_transaction; dequeue; activate device; record counter in db; commit; 77
  • 78. Performing Real-World Actions • On recovery: Restore queue and database if (device value > recorded value) then discard head entry; Restart server; 78
  • 79. Example of Real World Action • Suppose the hardware counter and the database counter were both at 100 before the transaction started – When the hardware performs its action, it increments its counter to 101 – TD would then increment the database counter to 101 • If the system crashed after the hardware performed its action the database increment (if it had occurred) would be rolled back to 100 • Thus when the system recovered – If the hardware counter was 101 and the database counter was 100, we would know that the action had been performed. – If both counters were the same (100), we would know that the action had not taken place. 79
  • 80. Forwarding Agent • Implementing deferred service: enqueue invoke dequeue client agent server reply Request queue Response dequeue queue enqueue • In general: there are multiple clients (producers) and multiple servers (consumers) 80
  • 81. Workflows • Flexibility: None of the previous models are sufficiently flexible to describe complex, long- running enterprise processes involving computational and non-computational tasks in distributed, heterogeneous systems over extended periods of time 81
  • 82. Workflow Task • Self-contained job performed by an agent – Inventory transaction (agent = database server) – Packing task (agent = human) • Has an associated role that defines type of job – An agent can perform specified roles • Accepts input from other tasks, produces output • Has physical status: committed, aborted, ... – Committed task has logical status: success, failure 82
  • 83. Workflow • Task execution precedence specified separately from task itself – using control flow language: initiate T2, T3 when T1 committed – or using graphical tool: T2 T1 T3 AND condition concurrency 83
  • 84. Workflow • Conditional alternatives can be specified: if (condition) execute T1 else execute T2 • Conditions: – Logical/physical status of a task – Time of day – Value of a variable output by a task • Alternative paths can be specified in case of task failure 84
  • 85. Workflow • Specifies flow of data between tasks T2 T1 T3 85
  • 86. Execution Precedence in a Catalog Ordering System O bill R AND OR by air take update remove package shipping complete order by land 86
  • 87. Flow of Data in a Catalog Ordering System bill by air take update remove package shipping complete order by land 87
  • 88. Workflow Agent • Capable of performing tasks • Has a set of associated roles describing tasks it can do • Has a worklist listing tasks that have been assigned to it • Possible implementation: – Worklist stored in a recoverable queue – Agent is an infinitely looping process that processes one queue element on each iteration 88
  • 89. Workflow and ACID Properties • Individual tasks might be ACID, but workflow as a whole is not – Some task might not be essential: its failure is ignored even though workflow completes – Concurrent workflows might see each other’s intermediate state – Might not choose to compensate for a task even though workflow fails 89
  • 90. Workflow and ACID Properties • Each task is either – Retriable: Can ultimately be made to commit if retried a sufficient number of times (e.g., deposit) – Compensatable: Compensating task exists (e.g., withdraw) – Pivot: Neither retriable nor compensatable (e.g., buy a non-refundable ticket) 90
  • 91. Workflow and ACID Properties • The atomicity of a workflow is guaranteed if each execution path is characterized by {compensatable}* [pivot] {retriable}* • This does not guarantee isolation since intermediate states are visible 91
  • 92. Workflow Management System • Provides mechanism for specifying workflow (control flow language, GUI) • Provides mechanism for controlling execution of concurrent workflows: – Roles and agents – Worklists and load balancing – Filters (data reformatting) and controls flow of data – Task activation – Maintain workflow state durably (data, task status) – Use of recoverable queues – Failure recovery of WFMS itself (resume workflows) 92
  • 93. Importance of Workflows • Allows management of an enterprise to guarantee that certain activities are carried out in accordance with established business rules, even though those activities involve a collection of agents, perhaps in different locations and perhaps with minimal training 93