Course contents
On this page
Keep a page alive while a reader uses it
Separate transaction correctness from the lifetime of an internal memory reference.
A transaction can have a valid snapshot and still follow an invalid memory reference. Suppose a reader obtains the address of a page in a buffer frame. Before the reader finishes, another worker reuses that frame for a different page.
The snapshot rule says which logical version the reader may see. It does not automatically keep the referenced bytes alive. We need a separate lifetime rule.
Protect identity before touching contents
The buffer lesson introduced pinning. Fetching a page must acquire a pin while the page-to-frame mapping is protected, so eviction cannot slip between finding the frame and establishing the pin.
- Fetch page P and pin its frame
The buffer manager establishes that this frame still contains P and cannot be reused while the pin is held.
- Read or change P's structure
Use the required short-lived protection for its contents. A pin alone does not prevent a concurrent writer.
- Finish and release protection
Release the structural protection, then the pin. Do not keep using the frame address afterward.
A short lock protecting an internal structure is often called a latch. A transaction lock may protect a logical row until commit, while a latch protects a brief operation on a page or directory. Releasing a latch does not commit the transaction.
For example, splitting an index page changes routing entries and child references. Concurrent traversals must not observe an unsupported half-split structure. The tree’s latch protocol establishes which states readers can safely encounter.
Removing a reference is not the same as freeing memory
Consider a linked node removed from an index. New readers may no longer discover it, but an older reader may already hold its address. Freeing it immediately lets the allocator reuse those bytes while the older reader still depends on them.
Memory reclamation determines when removed objects can actually be reused. Reference counts, protected reader epochs, and other schemes supply different proofs that no reader still needs an object. An epoch is a tracked period of reader activity; reclamation waits until relevant earlier readers have finished. These techniques require precise protocols, not just an extra counter added afterward.
Let the pin go too soon
A worker fetches P, copies the frame’s address, releases the pin, and then reads the row through that address. Is the access safe because the address still has the same numeric value?
Ask what now occupies the address
No. The frame may have been reused for Q. The address identifies memory, not an eternal association with page P. The worker must retain the required protection while using the bytes, or copy the needed data while protected and then use that independent copy.
Transaction isolation, structural consistency, and memory lifetime are separate obligations. Correctness requires all of them at the relevant boundary.
CMU’s buffer-pool project discusses guarded page access. The extended chapter develops reclamation and lock-free implementation concerns beyond this first lifetime trace.
Extended reference
The extended chapter preserves the original technical coverage, additional examples, and citations. The explanation above supplies the concepts needed for this page; the reference develops the specialist cases.
Find a section from the original chapter
- Learning outcomes
- A valid transaction can follow an invalid pointer
- Locks versus latches
- Atomic operations and memory ordering
- False sharing and coherence
- Concurrent tree traversal
- Memory reclamation
- Lock-free does not mean wait-free or faster
- NUMA-aware ownership
- Failure and verification
- Publication and reclamation are independent proofs
- Epoch reclamation trades per-object work for delayed reuse
- A concurrent split needs an observable intermediate state
- Atomics cannot repair an undefined access pattern
- Coherence traffic can dominate independent work
- Progress guarantees do not imply latency bounds
- Verification should separate semantic layers
- A reader lifetime timeline
- Separate a transaction retry from a structural restart
- Design conclusion
- Sources and further reading