Skip to content

test(e2e): flush LRU access times by restart, not by sleeping - #230

Merged
ovaistariq merged 1 commit into
mainfrom
test/deflake-lru-protection
Aug 19, 2026
Merged

ovaistariq merged 1 commit into
mainfrom
test/deflake-lru-protection

Conversation

@ovaistariq

@ovaistariq ovaistariq commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Kills the eviction-suite flake that has failed CI seven times in three days across four PRs (#216, #219, #228, #229), each time costing a rerun cycle.

Why the sleep could never work

The check reads the oldest keys to bump their LRU recency, then triggers eviction and asserts the bumped keys survived. It waited with sleep 8 for "a few flush intervals". But the bumps are queued by the read path and persisted asynchronously — the batch is time-gated (accessTimeLRU + DefaultAccessUpdateDelay) and written by a background ticker — so the delay is not bounded by the ticker period. No sleep length is a guarantee; CI simply lost the race periodically.

The deterministic replacement

accessUpdater.Stop() drains the update channel and flushes unconditionally before the process exits:

case <-a.done:
    a.collectUpdates()
    a.flushBatch()
    return

So a graceful restart is the guarantee — no timing assumption at all. The access index lives in RocksDB and survives restart (the suite's own "Restart persistence" test asserts exactly that property), so what's under test is unchanged; only the synchronization becomes deterministic.

Also fixed

restart_server passed server_args where start_server expects its cleanup argument, so the first server flag was silently swallowed — a latent bug that would have dropped -disk from the restarted command line. It now passes cleanup=false explicitly, which is also the only correct value for a restart.

Verification

Eviction suite run 4× locally: LRU and FIFO protection pass every time, all 8 subtests green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L5DLvDTo9dhD38YQXhHpU9


Note

Cursor Bugbot is generating a summary for commit 2ffac0d. Configure here.

The eviction suite's LRU protection check slept 8s hoping the
accessUpdater had persisted the read bumps before eviction ran. That
raced on CI seven times in three days across four PRs: the flush is not
bounded by the ticker period — updates are time-gated into a batch and
written asynchronously — so no sleep length is a guarantee.

accessUpdater.Stop() drains the update channel and flushes
unconditionally before the process exits, so a graceful restart IS the
guarantee. The access index lives in RocksDB and survives restart (the
suite's own Test 4 asserts exactly that), so the property under test is
unchanged — only the synchronization is now deterministic.

Also fixes restart_server dropping the first server flag: it passed
server_args where start_server expects its cleanup argument, so the
leading flag was swallowed. It now passes cleanup=false explicitly,
which is also the only correct value for a restart.

Verified: eviction suite run 4x locally, LRU and FIFO protection pass
every time (previously reproducible flake on CI).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L5DLvDTo9dhD38YQXhHpU9
Signed-off-by: Ovais Tariq <[email protected]>
@greptile-apps

greptile-apps Bot commented Aug 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR makes the eviction end-to-end test deterministic by restarting the server to flush queued LRU access-time updates instead of relying on a fixed sleep.

  • Preserves the test data directory during restarts by passing cleanup=false explicitly.
  • Reapplies the complete eviction configuration after restart.
  • Uses graceful shutdown to drain access updates before testing eviction behavior.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code failures identified.

The restart now preserves the intended disk directory, reapplies the complete server configuration, and follows the shutdown path that drains queued access updates before reopening persisted eviction state.

Important Files Changed

Filename Overview
tests/e2e/common.sh Correctly supplies the cleanup positional argument so restart flags are no longer shifted and the persisted data directory is retained.
tests/e2e/eviction_test.sh Replaces an unreliable timing delay with a graceful restart that synchronously flushes LRU access updates while preserving eviction state.

Reviews (1): Last reviewed commit: "test(e2e): flush LRU access times by res..." | Re-trigger Greptile

@ovaistariq
ovaistariq merged commit 32f716b into main Aug 19, 2026
12 checks passed
@ovaistariq
ovaistariq deleted the test/deflake-lru-protection branch August 19, 2026 04:53
@tigrisdata-argocd-bot

Copy link
Copy Markdown

🎉 This PR is included in version 1.11.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

ovaistariq added a commit that referenced this pull request Sep 7, 2026
… (#261)

The access index orders entries by nanosecond and a put records its write
time at that precision, but a read bump was queued as whole Unix seconds
and rebuilt with time.Unix(sec, 0), i.e. at the START of its second. A key
read at hh:mm:ss.8 therefore sorted before every key written at
hh:mm:ss.1..ss.7 and was evicted ahead of them.

That is the eviction e2e "Protection semantics" flake. The five protecting
reads land in the same wall-clock second as the tail of the twenty setup
writes whenever the writes are fast, and the failing CI run shows exactly
that order: keys 6-9 evicted, then the "protected" 1-3, with 10-20
untouched. PR #230 made the flush deterministic via a graceful restart,
but could not fix the timestamp being flushed.

The updater now carries time.Time end to end (queue, time-gate LRU, index
key), so a bump sorts after everything written before the read.
SetAccessTime keeps its Unix-seconds signature for the integration
harness. A new unit test pins the ordering and fails on main.

Fixes #257
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