feat(rollout): add opt-in ?flush=true for read-your-write appends - #191
Merged
Conversation
Since the flush decoupling, a rollout append is durable on return but not readable until the sweeper seals the memtable — up to ROLLOUT_FLUSH_INTERVAL_SECS (default 30s) later. `RolloutStore::flush` could close that gap but was unreachable from the HTTP API, so a caller needing read-your-write had no option short of lowering the global interval, which penalizes every store in the process and re-serializes writes that do not need the guarantee. Add `?flush=true` to the rollout append endpoint: seal before responding, trading latency for immediate visibility, with the asynchronous path unchanged as the default. Motivating cases are training loops that verify a trajectory they just wrote and write-then-assert tests. Parsing is deliberately conservative — only `flush=true`, `flush=1`, or a bare `flush` opt in, so a typo cannot silently make every append pay a seal. It reads the query off the URI because the handler consumes the whole `Request` to dispatch on Content-Type. Closes #186 Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #186.
Problem
A rollout append is durable on return but not readable until the flush sweeper seals the memtable — by default up to 30s later.
RolloutStore::flushexists but had no path through the HTTP API, so callers needing read-your-write were stuck loweringROLLOUT_FLUSH_INTERVAL_SECSglobally, which penalizes every store in the process and re-serializes appends that never needed the guarantee.Motivating cases: an RL training loop verifying a trajectory it just wrote; write-then-assert integration tests; any client doing
POST .../recordsthenGET.Change
POST /rollouts/{name}/records?flush=trueseals before responding.flush=true,flush=1, or bareflushopt in.flush=false,flush=yes,noflush=true, andflushed=trueall do not, so a typo cannot silently make every append pay a seal.flushis&selfand safe against concurrent appends.rollout_appends_flushed_totalcounter so opt-in usage is visible in metrics.Query parsing is by hand rather than via a
Queryextractor because the handler consumes the wholeRequestto dispatch onContent-Type.Testing
flush_true_gives_read_your_write_and_default_does_notdrives the real handler and asserts both halves: the default append leaves the row invisible (no sweeper running in the test), and?flush=truemakes it readable before the response returns.Verified it is a real guard by stubbing the flush call out:
Plus
flush_query_param_is_parsed_conservativelycovering the accept/reject table.cargo test -p lance-context-server→ 51 passed, 0 failed. fmt + clippy clean.Follow-up, deliberately not in this PR
The Rust client and Python binding do not yet expose the flag. Threading it through means a breaking signature change to
RolloutStoreApi::add, which affects both the local and remote implementations — worth its own PR and version bump rather than inflating this one. The HTTP API is the layer the issue's motivating cases hit directly.🤖 Generated with Claude Code