Account Transfer using optimistic concurrency control

Figure 1032. Optimistic concurrency control

An interfering transaction obeying the protocol causes a transaction failure:

Figure 1033. Failure with optimistic transactions

Considerations:

  • Race conditions, time of check to time of use

exercise No. 6

Optimistic account transfer

Q:

Implement your (pessimistic) account transfer application Accounts and balances in an optimistic manner:

  • Make sure both source and destination accounts get protected against interfering transactions.

  • Provide a means to definitely avoid deadlocks during the second transaction section of a balance transfer operation.

  • Supply a suitable message in case of an interfering second balance transfer