A semantic lock is an application-level flag on a record created or updated by a saga. It signals that the value is uncommitted and may change, so other transactions can be restricted or treat it cautiously. section 9.3.2
Use the flag to signal in-progress work; it can function in either of two ways:
- Prevent other transactions from accessing the record. section 9.3.2
- Warn other transactions to handle the record cautiously. section 9.3.2
Order creation
An Order can use a *_PENDING state to signal that a saga is updating it. In the FTGO Create Order Saga, semantic locks are used for both Order and Ticket entities so other transactions can detect and handle in-progress updates. section 9.3.2 section 11.1.1
Table 11.1 The definition of the FTGO Create Order Saga
Saga canvas |
|||
System operation: |
createOrder(…) |
||
Step |
Participant |
Transaction |
Compensating transaction |
1 |
Order Service |
(orderId, orderTotal) = createOrder(…) |
rejectOrder(orderId) |
2 |
Consumer Service |
verifyConsumer(…) |
- |
3 |
Kitchen Service |
createTicket(…) |
rejectTicket(…) |
4 |
Accounting Service |
authorizeCard(…) |
- |
5 |
Order Service |
approveOrder() |
- |
6 |
Kitchen Service |
approveTicket() |
- |
Review the six-step Create Order Saga flow and its participants to see where semantic locks support concurrent updates. section 11.1.1
