Loading...
Several clients can access one database service. A sequence that works in isolation can lose updates when its read and write steps interleave with another client’s work.
What you'll be able to do
Suppose a balance starts at 100. Client A reads 100 and plans to subtract 10; B also reads 100 and plans to subtract 20. If A writes 90 and B then writes 80 from its stale read, A’s change is lost. A correct sequential application of both changes would produce 70.
The fault is not necessarily a broken arithmetic operation. It arises because the application’s logical update spans several actions that were not isolated appropriately. A simultaneous-access service needs to define which combined outcomes are valid.
A transaction groups related operations into a unit with commit or rollback behaviour. Atomicity avoids leaving only part of a multi-step change applied. Isolation controls which effects other transactions can observe and how conflicting work behaves. Constraints and correct application logic remain important for valid data.
Record locks can require another client to wait or retry before conflicting access. A suitable locking protocol can prevent the stale-read sequence, but merely mentioning “a lock” without saying when it is acquired and held does not establish correctness. Deadlocks and contention are additional practical concerns.
Serial execution applies transactions one at a time; serialisable concurrent behaviour aims for results equivalent to an appropriate serial ordering. Timestamp ordering assigns an order used to manage conflicting operations, potentially rejecting or retrying work that violates it. Commitment-ordering approaches coordinate commit order with relevant conflict constraints.
AQA expects awareness of these concurrency-control approaches, not the assertion that every database uses one identical implementation. The chosen isolation and retry strategy should match application requirements. Distinguish a committed durable outcome from an intermediate value visible only inside unfinished work.
| Step | A | B | Stored balance |
|---|---|---|---|
| 1 | Read 100 | 100 | |
| 2 | Read 100 | 100 | |
| 3 | Write 90 | 90 | |
| 4 | Write 80 from stale read | 80 |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.