feat: opt-in commit=wait_for for completion-tracked batches#25
Merged
Conversation
A 200 from the ingest endpoint means the documents reached the server's WAL, not that they are committed/searchable. For tracked callers (IngestSync / IngestBatch) settle(nil) is a durability claim, so make the commit boundary configurable. Add SetIngestCommit(CommitAuto|CommitWaitFor|CommitForce). The mode is applied per batch: only when a batch carries a tracked item does it use the stronger commit (?commit=wait_for / force); pure fire-and-forget batches keep commit=auto and pay no extra latency. Two endpoint URLs are precomputed per worker, so the default (CommitAuto) path is unchanged. Combines cleanly with ?detailed_response=true. wait_for/force block the request until commit, which can exceed the default ResponseHeaderTimeout (ingestTimeout/3); the IngestSync and SetIngestCommit docs spell out the >3x-commit-interval timeout headroom needed to avoid timeout-driven retries/duplicates. Also tightened the IngestSync doc: nil means WAL-persisted (crash-safe) by default, committed/searchable under wait_for. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
"With care" item #6 from the review: make the durability boundary of a tracked Ack configurable.
Problem
A 200 from the ingest endpoint means the documents reached the server's write-ahead log, not that they're committed/searchable. For tracked callers (
IngestSync/IngestBatch),settle(nil)is a durability claim, so the WAL-vs-searchable distinction matters.Change
Add
SetIngestCommit(CommitAuto | CommitWaitFor | CommitForce), applied per batch:?commit=wait_for/force) only if it carries a tracked item.commit=autoand pay no extra latency.Two endpoint URLs are precomputed per worker (
endpointDefault,endpointTracked); they're equal when the mode isCommitAuto, so the default path is byte-for-byte unchanged. Combines cleanly with?detailed_response=true(#23).Also tightened the
IngestSyncdoc:nilmeans WAL-persisted (crash-safe) by default, committed/searchable underwait_for.The sharp edge (documented)
wait_for/forceblock the request until commit, which can exceed the defaultResponseHeaderTimeout(=ingestTimeout/3, from #22). If it does, the request is aborted → retried → re-ingested. TheSetIngestCommitdoc spells out the required headroom: setSetIngestTimeoutto >3× the index commit interval (or supply your ownhttp.Client), and rely on a dedup id./scrutinizeflagged that an earlier draft of the doc only said "raise the timeout" without the 3× factor — fixed.Tests
4 (
commit_mode_test.go): default → no commit param; tracked →commit=wait_for; fire-and-forget withwait_forset → still auto (no tracked item);force+detailed_responsecombine into one well-formed query (asserted viaurl.ParseQuery). Full suite green,go vetclean, race-clean ×2.🤖 Generated with Claude Code