---
title: "Tracing Cache Inconsistencies to Their Root Cause"
description: "Nextdoor extended its versioned Valkey ORM cache so every conditional write also atomically stores a short-lived verification key (receipt) recording the operation (fill_on_write or fill_on_miss), writer service, trace ID and replaced version, colocated via a hash tag in the same cluster slot."
url: "https://swe.quest/articles/tracing-cache-inconsistencies-to-their-root-cause-0cc21b10b814cb9e"
canonical: "https://engblog.nextdoor.com/tracing-cache-inconsistencies-to-their-root-cause-8f9c7f4a00e7"
source: "Nextdoor Engineering"
published: "2026-11-23"
difficulty: "medium"
kind: "Case study"
reading_minutes: 7
tags: ["caching","consistency","observability","postgres","debugging"]
---

# Tracing Cache Inconsistencies to Their Root Cause

A post on [Nextdoor Engineering](https://swe.quest/sources/nextdoor.md), published 2026-11-23, 7 min read, Case study. Original: [https://engblog.nextdoor.com/tracing-cache-inconsistencies-to-their-root-cause-8f9c7f4a00e7](https://engblog.nextdoor.com/tracing-cache-inconsistencies-to-their-root-cause-8f9c7f4a00e7)

## Summary

Nextdoor extended its versioned Valkey ORM cache so every conditional write also atomically stores a short-lived verification key (receipt) recording the operation (fill\_on\_write or fill\_on\_miss), writer service, trace ID and replaced version, colocated via a hash tag in the same cluster slot. The CDC-driven reconciler reads receipts for both the checked and cached versions during its two passes, classifying each inconsistency as an expected race, a stale fill, or a missing cache write, and emits one per-model metric. Receipts expire after pass 2 or within minutes, and are skipped where the reconciler never checks. The approach exposed three non-cache bugs: a silent context-cancellation failure in the reconciler, an ORM save() falling back to INSERT and resurrecting deleted rows, and redelivered long-running background jobs writing stale versions.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Consistency models](https://swe.quest/tags/consistency.md) (Distributed systems)
- [Observability](https://swe.quest/tags/observability.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)

## Prerequisites

- cache invalidation basics ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- change data capture
- Redis/Valkey Lua scripting ([easy posts on Caching](https://swe.quest/tags/caching.md?difficulty=easy))
- optimistic versioning

## Keywords

Valkey, PostgreSQL, Lua, change data capture, Valkey Cluster hash tags, Nextdoor

## Related posts

- [Cache made consistent](https://swe.quest/articles/cache-made-consistent-61a6d7479b73ae8d.md): Meta Engineering · 2022-06-08 · Medium · 13 min read · Caching, Consistency models, Observability, Distributed systems, Debugging
  Meta raised TAO's cache consistency from six nines to ten nines (99.99999999% of cache writes consistent within five minutes) by treating consistency as a measurement and debugging problem rather than only a protocol problem.
- [Eventually Consistent: How Do We Know the Systems Eventually Agree?](https://swe.quest/articles/eventually-consistent-how-do-we-know-the-systems-eventually-agree-446e4800453d4b35.md): Kogan.com Dev Blog · 2026-11-09 · Medium · 9 min read · Event-driven architecture, Consistency models, Resilience, PostgreSQL, E-commerce
  Eventually consistent event-driven order systems need a reconciliation job that starts from the authoritative order store, not from received messages, so orders whose events were lost (like a fraud-hold release that never reached SAP) still surface.
- [The final boss of reliability: formal verification](https://swe.quest/articles/the-final-boss-of-reliability-formal-verification-7d09556f91a9c3f0.md): Turso · 2026-07-07 · Medium · 6 min read · Formal methods, Testing, Storage engines, SQLite, Rust
  Turso, a from-scratch SQLite rewrite, is adding formal verification via Aretta AI's Aristo, which turns natural-language intents annotated on code into formally checked properties, to complement its deterministic simulation testing and Antithesis runs.
- [Birth and death of a row in Turso's MVCC](https://swe.quest/articles/birth-and-death-of-a-row-in-turso-s-mvcc-f60b68028888940e.md): Turso · 2026-10-19 · Hard · 14 min read · Storage engines, SQLite, Consistency models, Databases
  Turso's MVCC, modeled on Hekaton, tracks each row as a chain of versions in a lock-free SkipMap, with begin/end fields holding a TxId while a transaction is active and a commit timestamp once it commits.
- [Slack’s Incident on 2-22-22](https://swe.quest/articles/slack-s-incident-on-2-22-22-7a35cde32cfb5fd8.md): Slack Engineering · 2022-04-26 · Medium · 12 min read · Incidents & postmortems, Caching, Resilience, MySQL, Distributed systems
  A Consul agent rolling restart caused Mcrib, Slack's memcached control plane, to replace and flush cache nodes, dropping hit rates during peak traffic.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
