feat(mem-wal): add ShardWriter::put_no_wait#7362
Open
hamersaw wants to merge 2 commits into
Open
Conversation
Split put_memtable into a no-wait core that performs the visible in-memory insert and triggers the durable flush, returning the BatchDurableWatcher un-awaited, plus a thin wrapper that awaits it (preserving put's behavior). This lets an external caller serialize a read-merge-insert critical section under its own lock and await durability after releasing it, so concurrent durable flushes still coalesce. The in-memory insert stays guarded by the writer's state_lock, so BatchStore's single-writer invariant holds without relying on the external lock. Re-exports BatchDurableWatcher and WriteResult. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
What
Adds
ShardWriter::put_no_wait, a variant ofputthat performs the visible in-memory insert and triggers the durable WAL flush, then returns theBatchDurableWatcherwithout awaiting it. A thin wrapper restoresput's behavior (await the watcher), so existing callers are unchanged.put_memtableis split into:put_memtable_no_wait— the in-memory critical section (insert understate_lock+track_batch_for_wal+ flush triggers) followed bytrigger_flush, returning(WriteResult, Option<BatchDurableWatcher>).put_memtable— calls the above, thenwatcher.wait().BatchDurableWatcherandWriteResultare re-exported frommem_wal.Why
Lets an external caller hold its own serialization lock across only the in-memory read-merge-insert critical section and await durability after releasing it, so concurrent durable flushes still coalesce. The in-memory insert stays guarded by the writer's
state_lock, soBatchStore's single-writer invariant holds regardless of the external lock —state_lockis intentionally not skipped.This is the lance-side primitive for sophon's WAL partial-column-update path (read fresh tier → merge → insert under a per-bucket lock, durability awaited outside it).
Tests
test_put_no_wait_durable_visible_then_durable(row visible before durability, watcher resolves) andtest_put_no_wait_non_durable_returns_no_watcher.