The Bay Lease That Expires During Failover
When the dock scheduler fails over, the most dangerous value in the deployment is the bay reservation lease TTL. It lives in one config file and the failover timing lives in another. Each one looks sane on its own, and together they let the standby give a bay to a second trailer while a yard tractor is still reversing into it. Code review rarely catches this because nobody reads the two diffs side by side.
How a correct value turns wrong
A bay reservation is a lease. The guidance session renews it while the tractor manoeuvres, and if renewals stop, the lease expires and the scheduler frees the bay. A team that wants faster bay turnover after no-shows sets the lease to 45 s, and that is a reasonable number in isolation. In a separate change, often months apart, someone tunes the high-availability layer: election timeout, snapshot replay, the warm-up before the standby accepts writes. During that whole window no node renews leases, because the old primary is gone and the new one is not serving yet. If the takeover lasts longer than the lease, the standby wakes up to a table full of expired reservations and acts on them correctly by its own logic. It frees the bays and reassigns them, while the tractor's local guidance loop has no idea anything happened.
Why review and testing both miss it
Neither diff is wrong, so neither reviewer objects. The bug is a relation between two values owned by different teams, and normal review checks values, not relations. Staging failover drills usually run with an idle yard, so no lease is live when the primary dies, and the drill passes. The double booking only shows up under load during a real outage, which is the one moment you can least afford it. That makes it a safety problem as well as a scheduling one: once two trailers are assigned to the same door, the interlocks and the people on the dock floor are the only things left between them, and machinery functional safety standards such as ISO 13849 assume those protective layers are not routinely being exercised by software.
The check you can run today
Read the lease TTL from the scheduler config and the election timeout plus worst-case replay time from the HA config, add one renewal interval to the failover side, and fail the CI pipeline unless the lease is strictly longer. Then make the staging drill honest: start a simulated reversing session that holds a live lease, kill the primary, and once the standby is serving run SELECT bay_id, count(*) FROM reservations WHERE state = 'active' GROUP BY bay_id HAVING count(*) > 1 against the reservation store. Any row returned is a double booking you would otherwise have found in production. My estimate is that most teams who add this drill find the inequality violated on at least one site configuration, because per-site overrides drift away from the defaults the original author reasoned about.
The decision rule is that a lease must outlive the worst failover you have measured, not the one you designed for, and the standby must treat replicated leases as frozen until it has served for one full renewal interval, so a tractor already in motion keeps its bay even when the scheduler that granted it is gone.
Technical FAQ: Why not just make the lease very long and avoid the problem?
A long lease protects bays during failover, but it costs you capacity every time a trailer really is a no-show, because the bay sits held until the lease expires. The better fix is to freeze leases during takeover, which lets you keep a short lease for no-shows without letting failover release bays that are still in use. You still have to measure your real failover time, and you have to measure it again whenever the HA layer changes.