Buffer pools: one page, three different questions
- Residency: is it cached?
- Pin count: may its frame be replaced?
- Dirty state: does this copy contain writes?
Predict: two fetches of page A, one unpin. Can A be evicted?
1 / 8
Predict: two fetches of page A, one unpin. Can A be evicted?
fetch A pin=1
fetch A pin=2
unpin A pin=1
A is still in use. A pin does not provide transaction isolation.
Capacity 2; recency is oldest → newest:
| Page | Pin count | Dirty |
|---|---|---|
| A | 1 | false |
| B | 0 | true |
Fetch C: evict B, reporting dirty=true.
The oldest page is not necessarily the oldest eligible page.
fetch/unpin A
fetch/unpin B
fetch/unpin A
unpin B again
fetch C
Predict the victim before advancing.
A's second fetch made it most recent. Unpin does not refresh recency.
A clean unpin also does not clear an earlier dirty flag.
Check these as separate invariants; a single “last touched” field can encode the wrong policy.
Both frames pinned → fetch fails.
ok=false.An empty operation list still succeeds at capacity zero.
Real page: pageLSN=42, durable WAL ends at 39.
flush WAL through 42 → write page → reuse frame
The exercise reports a dirty victim. Its API does not simulate either flush.
Map + ordered slice: O(MC) time, O(C) resident metadata.
Explain how your code preserves:
Then implement buffer-pool and reproduce the lesson's nine-step trace.