group-commit patches - #12
Merged
Merged
Conversation
…ent HTTP commits.
Connection::BeginTransaction()/Commit()/Rollback() each run a full SQL
statement ("BEGIN TRANSACTION"/"COMMIT"/"ROLLBACK") through the parser,
binder, optimizer, and task-scheduled executor -- real, measured overhead
per HTTP/async/gRPC ingest request. Added RawBeginTransaction/
RawCommitTransaction/RawRollbackTransaction, which call the same
ClientContext::transaction primitives DuckDB's own PhysicalTransaction
operator uses, skipping the SQL front end entirely. Applied everywhere
this pattern existed: raw_api.cpp, raw_async.cpp, raw_grpc.cpp.
Fixed a real concurrency bug this surfaced under sustained 16-32-way
concurrent OTLP/HTTP load: multiple exporter processes racing to INSERT
into a table that doesn't exist yet each open their own transaction, and
DuckDB's catalog allows only one to CREATE TABLE -- the rest saw a
TransactionException surfaced as an HTTP 400, which OTLP exporters
correctly do not retry, silently dropping that batch. Fixed with
RawIngestSerialized: a table's first-ever insert queues behind an
in-process lock instead of racing; every request afterward never touches
the lock, just a cached membership check.
Even with that race fixed, DuckDB's single-writer WAL still serializes
every commit's fsync regardless of how many independent Connections are
committing -- no single commit was ever slow in isolation, but under a
big enough pile-up the cumulative queueing occasionally pushed one
unlucky request's latency past a 10s client timeout. Fixed with
RawIngestGroupCommit: concurrent requests to the same table coalesce into
one shared commit. Lingering to let a batch form is gated on an in-flight
counter, not unconditional -- a lone, uncontended request skips the
linger and the whole coalescing path entirely, going straight through at
the same latency as a direct call. (The first cut lingered unconditionally
and regressed every request's latency ~7x with nobody to batch with --
caught by explicitly re-benchmarking the solo/no-contention case, not
just the concurrent stress test that motivated the fix.)
Verified: full sqllogictest suite repeatedly; 45/45 clean in dedicated
concurrency stress testing (16-way and 32-way, previously ~90-95%
reliable); solo-request latency back to the same ~4-6ms baseline as
before any of this; the 1M-record bulk-ingest benchmark (unaffected by
these HTTP-only changes) unchanged within noise against BENCHMARK.md's
recorded numbers.
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.
No description provided.