Title: Implementing Transactions in JOIN Calculus
1Theoretical Foundations for Compensations in Flow
Composition Languages
Hernán Melgratti Joint work with Roberto Bruni
and Ugo Montanari Dipartimento di Informatica -
Università di Pisa
2Motivations Web Service Composition
- Defining complex services as aggregations of
simpler services - Interaction based Composition, Conversational
Patterns or Global Model - Services describe the ways they can be engaged in
a larger process - Flow Composition or Hierarchical Patterns
- Similar to workflow systems a process describes
the flow of both control and data among WS
3Motivations Flow Composition
A3
A2
A1
A5
A4
4Motivations Transactional Flow
Transactional Process
A3
A2
A1
A5
A4
5Motivations Compensation
Transactional Process
A3
A2
B3
B2
A1
A5
B1
B5
A4
B4
6Motivations Compensation Flow
Transactional Process
A3
A2
B3
B2
A1
A5
B1
B5
A4
B4
7Outline of the talk
- Sequential Sagas
- Graphical representation
- Syntax and Semantics
- Adequacy results
- Parallel Sagas
- Nested Sagas
- Additional features
- Concluding remarks
8Sequential Sagas Graphical Repr.
Accept Order
Update Credit
Prepare Order
Refuse Order
Refund Money
Update Stock
9Sequential Sagas Syntax
Accept Order
Update Credit
Prepare Order
Refuse Order
Refund Money
Update Stock
(Step) X 0 A AB (Process) P X
PP (Saga) S P
10Sequential Sagas Syntax
Accept Order
Update Credit
Prepare Order
Refuse Order
Refund Money
Update Stock
S AORO UCRM POUS
(Step) X 0 A AB (Process) P X
PP (Saga) S P
11Sequential Sagas Semantics
- An activity A either
- commits (A ? )
- aborts (A ? )
- ? A1 ? ,, An ?
12Sequential Sagas Semantics
- A saga S P under ? either
- commits ( )
- aborts ( )
- fails ( )
- ? is the observable flow
?
? S ??
?
?
? S ??
?
?
? S ??
?
13Sequential Sagas Semantics
- A process P under ? either
- commits (
) - aborts ( )
- fails ( )
- ß and ß are the installed compensations
14Sequential Sagas Semantics
(saga)
15Sequential Sagas Semantics
(saga)
(zero)
16Sequential Sagas Semantics
(saga)
(zero)
(s-act)
17Sequential Sagas Semantics
(saga)
(zero)
(s-act)
?
? ltß,0gt ?? lt , 0gt
?
(s-cmp)
?
A ? , ? ltAB,ßgt ?? lt , 0gt
?
?
? ltß,0gt ?? lt , 0gt
?
(f-cmp)
?
A ? , ? ltAB,ßgt ?? lt , 0gt
?
18Sequential Sagas Semantics
?
?
? ltQ,ßgt ?? lt ,ßgt
? ltP,ßgt ?? lt ,ßgt
?
?
(s-step)
??
? ltPQ, ßgt ?? lt ,ßgt
?
?
? ltP,ßgt ?? lt , 0gt
?
(a-step)
?
? ltPQ,ßgt ?? lt ,0gt
?
?
? ltP,ßgt ?? lt , 0gt
?
(a-step)
?
? ltPQ,ßgt ?? lt ,0gt
?
19Sequential Sagas Adequacy Theorem
?
and ? A1An
? S ??
?
A1
Aj
Ak
An
20Sequential Sagas Adequacy Theorem
?
and ? A1An
? S ??
?
A1
Aj
Ak
An
?
and ? A1Ak-1Bk-1B1
? S ??
?
Ak
A1
Aj
An
Bj
B1
21Sequential Sagas Adequacy Theorem
?
and ? A1An
? S ??
?
A1
Aj
Ak
An
?
and ? A1Ak-1Bk-1B1
? S ??
?
Ak
A1
Aj
An
Bj
B1
?
and ? A1Ak-1Bk-1Bj1
? S ??
?
A1
Aj
Ak
An
Bj
B1
22Parallel Sagas Graphical Representation
Update Credit
Refund Money
Accept Order
Refuse Order
Prepare Order
Update Stock
23Parallel Sagas Syntax
Update Credit
Refund Money
Accept Order
Refuse Order
Prepare Order
Update Stock
(Step) X 0 A AB (Process) P X PP
PP (Saga) S P
24Parallel Sagas Syntax
Update Credit
Refund Money
Accept Order
Refuse Order
Prepare Order
Update Stock
S AORO UCRM POUS
(Step) X 0 A AB (Process) P X PP
PP (Saga) S P
25Parallel Sagas The Naïve Way
B1
Bj
Bn
B1
Bj
A1
A2
A1
C1
Ck
Cm
C1
Ck
Cm
A1(B1Bj-1Bj-1B1 C1CmCmC1)A1
26Parallel Sagas Revised
B1
Bj
Bn
B1
Bj
A1
A2
A1
C1
Ck
Cm
C1
Ck
Cm
A1(B1Bj-1Bj-1B1 0)A1
A1(B1Bj-1Bj-1B1 C1C1)A1
A1(B1Bj-1Bj-1B1 C1CmCmC1)A1
27Parallel Sagas Semantics
- A process P under ? either
- commits (
) - aborts ( )
- fails ( )
- is forced to abort (
) - is forced to fail (
) - ? is the observable concurrent flow
?
? ltP,ßgt ?? lt ,ßgt
?
?
? ltP,ßgt ?? lt , 0gt
?
?
? ltP,ßgt ?? lt , 0gt
?
?
? ltP,ßgt ?? lt , 0gt
?
?
? ltP,ßgt ?? lt , 0gt
?
28Parallel Sagas Semantics
?
? ltP,0gt ?? lt?, ßgt
? ? , ,
?
(saga)
?
? P ?? ?
?
(forced-abt)
(forced-abt)
29Parallel Sagas Semantics
(s-par)
30Parallel Sagas Semantics
(c-par)
?1, ?2 ? ,
?
?
?
? ltP,0gt ?? lt?1,0gt
? ltQ,0gt ?? lt?2,0gt
? ltß,0gt ?? lt ,0gt
?
?
?
?? ?
? ltPQ, ßgt ???? lt ?1 ? ?2 , 0gt
?
?
?
?
?
?
31Parallel Sagas Semantics
(c-par)
?1, ?2 ? ,
?
?
?
? ltP,0gt ?? lt?1,0gt
? ltQ,0gt ?? lt?2,0gt
? ltß,0gt ?? lt ,0gt
?
?
?
?? ?
? ltPQ, ßgt ???? lt ?1 ? ?2 ? , 0gt
?
?
?
?
?
?
32Parallel Sagas Semantics
(f-par)
?1 ? ,
?
?
? ltP,0gt ?? lt?1,0gt
? ltQ,0gt ?? lt?2,0gt
?
?
?2 ? , , ,
??
? ltPQ, ßgt ??? lt ?1 ? ?2 , 0gt
?
?
?
?
?
?
33Parallel Sagas Adequacy
Completion
34Parallel Sagas Adequacy
Successful Compensation
35Parallel Sagas Adequacy
Failed Compensation
36Nested Sagas Graphical Representation
Update Credit
Refund Money
Accept Order
Refuse Order
Prepare Order
Update Stock
Add Points
Subtract Points
37Nested Sagas Syntax
(Step) X 0 A AB S (Process) P X
PP PP (Saga) S P
38Nested Sagas Syntax
Update Credit
Refund Money
Accept Order
Refuse Order
Prepare Order
Update Stock
Add Points
Subtract Points
S ? AORO UCRM POUS APSP
39Nested Sagas Semantics
?
? ltP,0gt ?? lt , ßgt
?
(sub-cmt)
?
?
? ltP,ßgt ?? lt , ßßgt
ß acts as default compensation
?
? ltP,0gt ?? lt , 0gt
?
(sub-abt)
?
?
? ltP,ßgt ?? lt , ßgt
?
? ltP,0gt ?? lt , 0gt
?
(sub-fail)
?
? ltP,ßgt ?? lt , 0gt
?
40Nested Sagas Semantics
(sub-forced-1)
(sub-forced-2)
(sub-forced-2)
41Nested Sagas Adequacy
Completion
42Nested Sagas Adequacy
Successful Compensation
43Nested Sagas Adequacy
Failed Compensation
44More on Sagas
- Exception handling try S with P
- Used to catch crashes during backward computation
- Forward recovery strategies try S or P
- Can be used to retry or to improve activities
- Fully programmable compensations SP
- More expressive than default compensation
(sub-cmt) - Allowed by languages like BPEL4WS
- Choices
- discriminator P?Q
- internal P?Q
- Data dependencies A?B
- Valid executions must satisfy dependency
constraints
45Final Remarks
- Our definition for compensable languages
- abstracts away from low-level computations
- can be easily extended
- independent from the coordination mechanisms that
implement the primitives - Java Transactional Web Services (JTWS)
- Distributed implementation of flows
- Allows to reason about program properties
- Adequacy
- Correctness of implementation