Skip to content

Redis IT job flakes on L1 cache stale-after-write race #28912

Closed

Description

@yan-3005

Problem

The integration-tests-postgres-elasticsearch-redis CI job has been flaking intermittently across unrelated PRs since early June, failing on different tests each run. Across 4 runs traced, 6 distinct failures share one root cause — a stale read from the in-process L1 entity cache after a write commits.

Observed failures:

  • MlModelResourceIT.test_entityStatus
  • GlossaryResourceIT.test_entityStatus
  • MetadataServiceResourceIT.post_delete_entityWithOwner_200
  • ContextFileIT.testHardDeleteFileIsAsync
  • DriveFileUploadIT.testUploadPdfToMinIO
  • RdfGlossaryGraphIT.scopedResponseCarriesGlossaryNameAndIdPerNode

All share the shape: write succeeds → immediately-following read returns the prior state.

Root cause

Guava LoadingCache puts a returning loader's value into L1 even if invalidate() was called while the loader was running. A concurrent reader that started loading before a write commits can poison L1 with the pre-write value AFTER the writer's invalidate ran. Subsequent reads on the same pod serve stale data until L1 TTL (~30s).

The race is structural and older than #28675. It was partially patched in #28197 (NotFoundCache marker for delete) and #28100 (rename-cascade fix), with the comment in EntityRepository.java:4578-4582 explicitly acknowledging the residual hole. PR #28012 (May 13) added the Redis CI variant that exposes it; PR #28675 (June 5) widened the window with per-entity async indexing + out-of-transaction invalidateCachesAfterStore.

Impact

  • All PRs running CI inherit the flake regardless of their own changes.
  • Real users hitting PATCH→GET or DELETE→GET on the same entity under load see stale data for up to 30s.

Fix

PR #28902 — three layered defenses: NotFoundCache check on L1 hit (delete-side), per-entity write-epoch counter the loader checks at end-of-load (update-side), deferred async re-invalidate as backstop.

Activity

  1. added
    bug
    on Jun 10, 2026
  2. added this to Shipping and removed this from Roadmapon Jun 10, 2026
  3. moved this to In Review / QA 👀 in Shippingon Jun 10, 2026
  4. moved this from In Review / QA 👀 to Done ✅ in Shippingon Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    • Status
      Done ✅

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions