sequenceDiagram
participant John as John
participant DB as Database
participant Mary as Mary
John->>DB: begin_transaction()
Note over DB: Lock acquired on source & dest accounts
Mary->>DB: begin_transaction()
Note over Mary,DB: Waiting for lock release
John->>DB: debit_source_account()
John->>DB: credit_destination_account()
Note over DB: Lock still held
John-->>John: Error occurs
John->>DB: rollback_transaction()
Note over DB: Lock released
Note over Mary,DB: Lock acquired on source & dest accounts
Mary->>DB: debit_source_account()
Mary->>DB: credit_destination_account()
Note over DB: Lock still held
Mary->>DB: commit_transaction()
Note over DB: Lock released
Last active
October 16, 2023 19:53
-
-
Save karloscodes/205667e939d121417ce253718bd14a30 to your computer and use it in GitHub Desktop.
Pesimistic locking sequence diagram
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment