Skip to content

group-commit patches - #12

Merged
lmangani merged 1 commit into
mainfrom
group-commit
Aug 22, 2026
Merged

group-commit patches#12
lmangani merged 1 commit into
mainfrom
group-commit

Conversation

@lmangani

Copy link
Copy Markdown
Contributor

No description provided.

…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.
@lmangani
lmangani merged commit a14e474 into main Aug 22, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant