Skip to content

test: make eviction e2e LRU protection reliable on CI - #192

Merged
ovaistariq merged 2 commits into
mainfrom
fix/eviction-e2e-lru-flakiness
Jul 19, 2026
Merged

ovaistariq merged 2 commits into
mainfrom
fix/eviction-e2e-lru-flakiness

Conversation

@ovaistariq

@ovaistariq ovaistariq commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The Test workflow on main (commit ccedac2) failed at the Run eviction E2E test (LRU + FIFO) step — specifically the LRU protection semantics case: read-oldest keys survived only 2/5 (threshold ≥3). FIFO passed all four cases.

Root cause

Under LRU a key is protected from eviction only when a read succeeds and its async access-bump lands. Access buckets are hourly, so eviction order within a bucket is purely by nanosecond timestamp; an un-bumped key stays at its original (oldest) write position and is evicted first. The protective reads in the test suppressed errors (./ocachecli get ... || true), so on a busy CI runner a silently-failed get left that key unprotected — hence the flaky partial count. FIFO has no async path, so it was deterministic.

Fix

  • Retry each protective read until it actually succeeds, so the LRU bump is genuinely triggered. The 5-minute access-update delay gate makes any extra reads no-ops, so retrying is safe.
  • Wait several flush intervals (1s DefaultAccessUpdateInterval) before forcing eviction, for CI headroom.

Verification

make test-e2e-eviction locally: LRU read-oldest survival goes from a flaky 2/5 to a stable 5/5; FIFO stays 0/5; all 8 subtests (both policies) pass. Test-only change.

🤖 Generated with Claude Code


Note

Low Risk
Test-only changes to eviction_test.sh; no production cache or eviction logic modified.

Overview
Hardens Test 2 (protection semantics) in eviction_test.sh so LRU/FIFO assertions are less flaky on busy CI.

Setup writes for order-key-* are retried (up to 5 attempts) instead of being ignored on failure. Protective reads of keys 1–5 retry until ocachecli get succeeds and returns non-empty data, so LRU access bumps actually happen instead of silent misses counting as success.

If setup cannot write/read reliably, the test fails with an explicit “inconclusive setup” message rather than blaming eviction. The access-time flush wait before phase 2 increases from 5s to 8s (several DefaultAccessUpdateInterval cycles). Phase 2 eviction checks are unchanged but only run when setup succeeded.

Reviewed by Cursor Bugbot for commit 1fe7e01. Bugbot is set up for automated code reviews on this repo. Configure here.

The LRU "protection semantics" e2e case flaked on CI (read-oldest keys
survived 2/5, threshold ≥3), while FIFO passed. Root cause: LRU protects
a key only when the read succeeds and its async access-bump lands —
access buckets are hourly, so eviction order within the bucket is purely
by nanosecond, and an un-bumped key stays at its oldest write position
and is evicted first. The protective reads suppressed errors (`|| true`),
so on a busy runner a silently-failed `get` left the key unprotected.

Retry each protective read until it actually succeeds (the 5-minute
access-update delay gate makes extra reads no-ops, so retrying is safe),
and wait several flush intervals before forcing eviction. Locally this
takes the LRU read-oldest survival from a flaky 2/5 to a stable 5/5;
FIFO stays 0/5.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>
@greptile-apps

greptile-apps Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR makes eviction protection tests more reliable on busy CI runners. The main changes are:

  • Retries setup writes before running protection checks.
  • Requires protective reads to succeed and return data.
  • Reports inconclusive setup failures separately from eviction failures.
  • Extends the wait for asynchronous access updates.

Confidence Score: 5/5

This looks safe to merge.

  • Missing keys can no longer count as successful protective reads.
  • Exhausted setup retries no longer continue into eviction assertions.
  • No blocking issue remains in the updated test flow.

Important Files Changed

Filename Overview
tests/e2e/eviction_test.sh Adds bounded setup retries, validates protective reads, gates eviction checks on successful setup, and increases the access-update wait.

Reviews (2): Last reviewed commit: "test: harden eviction e2e setup so LRU p..." | Re-trigger Greptile

Comment thread tests/e2e/eviction_test.sh Resolved
Comment thread tests/e2e/eviction_test.sh Resolved
Comment thread tests/e2e/eviction_test.sh Resolved
Address review feedback on the LRU protection case:

- Retry the phase-1 setup writes until they succeed; a silently-dropped
  write (previously `|| true`) would leave a protected key absent and skew
  the survivor count.
- Require each protective read to return a non-empty value, not just exit
  zero. `ocachecli get` exits non-zero on a miss, but capturing the value
  also guards against a key that was never written — the bump only fires
  after the server finds the key.
- If any setup write/read can't be satisfied, fail the case with a clear
  "inconclusive" cause instead of falling into a misleading
  "reads did not protect" assertion.

The async access-bump itself is persisted on the first read of a
never-read key (the access-updater time-gate only suppresses *repeat*
reads within the 5-minute window), so no change is needed there; local
`make test-e2e-eviction` stays LRU 5/5, FIFO 0/5, all 8 subtests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YCoN4Him5ZY4hZovVp37ra
Signed-off-by: Ovais Tariq <[email protected]>
@ovaistariq

Copy link
Copy Markdown
Contributor Author

Thanks — addressed in 1fe7e01. Notes on each finding:

P1: "Delay Gate Discards Fresh Read Bumps" — not correct, no change needed.
A freshly-written, never-read key is not in the access-updater's accessTimeLRU cache, because writes go through putLow (which writes the access-bucket entry directly), not through the updater. So the first read hits the !ok branch of timeGateUpdate (storage/access_updater.go:167) and is added to the persisted batch — the 5-minute delay gate only suppresses repeat reads of an already-tracked key. This is confirmed empirically: with reliable reads, make test-e2e-eviction gives LRU read-oldest survival of 5/5 (it would be 0/5 if fresh bumps weren't persisted).

P1: "Missing Keys Count As Successful Reads" — mechanism inaccurate, but the adjacent risk is now closed.
ocachecli get actually exits non-zero on a miss: the server returns codes.NotFound (server/service/get.go:44), which propagates through the stream so the CLI hits os.Exit(1) (client/cmd/main.go:156). So a missing key does not satisfy the retry. The real fragility was a silently-failed setup write leaving the key absent — now fixed: phase-1 writes are retried until they succeed, and each protective read must return a non-empty value (not just exit 0), proving the key was actually read.

P1: "Retry Exhaustion Still Runs Eviction" — fixed.
If any setup write or protective read can't be satisfied, the case now fails immediately with an "inconclusive setup" message instead of falling through to a misleading "reads did not protect" assertion.

@ovaistariq

Copy link
Copy Markdown
Contributor Author

@greptile

@ovaistariq
ovaistariq merged commit ec720ee into main Jul 19, 2026
9 checks passed
@ovaistariq
ovaistariq deleted the fix/eviction-e2e-lru-flakiness branch July 19, 2026 18:05
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants