Labs / Chapter 7
The next read still returns the old address
Read a replica that has not applied the write and watch the old address come back. Then run choose_read_target. Without primary fallback the read should be unavailable. With fallback it should come from the primary. Catch a replica up and watch the router choose it again.
The system
Replica lag is 400 ms. This read ignored the policy and returned the old address.
choose_read_target
- # lag_ms = available = sample_is_current =
- target =
- def choose_read_target(policy, observations, request):
- candidates = [replica for replica in observations.replicas
- if replica.available
- and replica.sample_is_current()
- and policy.accepts(replica)]
- if candidates:
- return replica_admission.try_choose(candidates, deadline=request.deadline)
- if policy.allow_primary_fallback:
- return primary_fallback.try_admit(deadline=request.deadline)
- raise ReadTemporarilyUnavailable()
- Lag400 ms behind the write
- This readReplica. The old address comes back.
This read
Saved-address shown and primary share are both percents of this one read, not of the whole fleet.
Saved address 0 · Primary 0
The chart fills as the lab runs. % is the vertical unit.
- Saved address
- Primary
- %
