Skip to content

fix(#4806): stop gRPC insertStream after a mid-stream commit failure and stop mis-indexing the error - #4820

Merged
robfrank merged 5 commits into
mainfrom
fix/4806-grpc-insertstream-keeps-processing-after
Jun 30, 2026
Merged

robfrank merged 5 commits into
mainfrom
fix/4806-grpc-insertstream-keeps-processing-after

Conversation

@robfrank

Copy link
Copy Markdown
Collaborator

Summary

Fixes #4806. A mid-stream commit failure in ArcadeDbGrpcService.insertStream (e.g. a deferred unique-index violation surfacing at db.commit() in PER_BATCH/PER_ROW mode) was mishandled:

  • The exception (which escapes insertRows, since per-row errors are caught row-by-row inside it) was recorded against a single context-wide row index (ctx.received - 1) with a generic DB_ERROR code, mis-attributing a transaction-level failure to one row.
  • The finally kept pulling more chunks (call.request(1)) against the already rolled-back transaction (the post-commit db.begin() never ran). Subsequent rows then ran on the broken transaction, producing spurious "Transaction not begun" errors, and onCompleted re-raised the same on its deferred commit.

Fix

In insertStream:

Test

Issue4806InsertStreamMidStreamCommitFailureIT - PER_BATCH, server_batch_size = 1, UNIQUE index. A duplicate row triggers a mid-stream commit failure followed by a would-be-valid row.

Before the fix the summary contained 3 errors (mis-indexed DB_ERROR, a "Transaction not begun" DB_ERROR from processing the next row on the dead transaction, and a COMMIT_FAILED from onCompleted). After the fix it contains exactly 1 transaction-level error (rowIndex == -1, code CONFLICT) and the subsequent row is not inserted.

Verification

  • New IT passes; the 4 existing insertStream ITs (Issue4198, Issue4214, Issue4644, Issue4656 - 21 tests) pass with no regressions.
  • grpcw module compiles cleanly.

🤖 Generated with Claude Code

@mergify

mergify Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@codacy-production

codacy-production Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses issue #4806 by ensuring that ArcadeDbGrpcService.insertStream stops processing chunks and correctly records a transaction-level error (using rowIndex = -1) when a mid-stream commit failure occurs. It also adds a regression test to verify this behavior. The review feedback highlights two important improvements to prevent transaction leaks and release resources early: first, explicitly rolling back any active transaction in the catch block of onNext when a transaction-level failure is caught, and second, ensuring that any active transaction is bound and rolled back in onCompleted when streamFailed is true to avoid thread-local transaction pollution in the gRPC thread pool.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +1791 to 1800
if (!streamFailed.get()) {
try {
// Issue #4644: onCompleted may run on a different pool thread than the onNext that began
// the transaction; re-bind it to this thread so the deferred commit finds it.
ctx.bindToCurrentThread();
ctx.flushCommit(true); // commit if not validate-only
} catch (Exception commitEx) {
recordCommitException(totals, commitEx);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When streamFailed is true, the deferred commit is skipped. However, if the transaction was not already rolled back by the engine during the mid-stream failure, it will remain active and bound to the current thread. Since gRPC threads are reused from a shared pool, this can lead to thread-local transaction pollution, causing subsequent unrelated requests on the same thread to inherit this broken transaction. To prevent transaction leaks, we should explicitly bind and roll back the transaction in the else block if it is still active.

          if (!streamFailed.get()) {
            try {
              // Issue #4644: onCompleted may run on a different pool thread than the onNext that began
              // the transaction; re-bind it to this thread so the deferred commit finds it.
              ctx.bindToCurrentThread();
              ctx.flushCommit(true); // commit if not validate-only
            } catch (Exception commitEx) {
              recordCommitException(totals, commitEx);
            }
          } else {
            try {
              ctx.bindToCurrentThread();
              if (ctx.db != null && ctx.db.isTransactionActive()) {
                ctx.db.rollback();
              }
            } catch (Exception rollbackEx) {
              LogManager.instance().log(this, Level.WARNING, "Failed to rollback active transaction on stream failure", rollbackEx);
            }
          }

Comment on lines 1740 to 1750
} catch (Exception e) {
// Register as an error on totals; keep stream alive unless you prefer to fail
// the call
totals.err(Math.max(0, (ctxRef.get() != null ? ctxRef.get().received : 0) - 1), "DB_ERROR", e.getMessage(),
"");
// Issue #4806: per-row errors are handled row-by-row inside insertRows, so an exception
// reaching here is a transaction-level failure (typically a mid-stream PER_BATCH/PER_ROW
// commit that has already rolled the transaction back). Record it once at the transaction
// level (rowIndex -1) instead of mis-attributing it to a single row, and mark the stream
// failed so subsequent chunks are not inserted into the broken transaction. onCompleted
// delivers the summary.
streamFailed.set(true);
final String code = e instanceof DuplicatedKeyException ? "CONFLICT" : "COMMIT_FAILED";
totals.err(-1, code, e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName(), "");
} finally {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When a transaction-level failure occurs, the transaction might still be active (e.g., if the exception was not a commit failure or if the engine did not automatically roll it back). To release database locks and resources as early as possible (rather than waiting for all remaining inbound chunks to be drained and onCompleted to be called), we should explicitly roll back the transaction immediately in this catch block if it is still active.

Suggested change
} catch (Exception e) {
// Register as an error on totals; keep stream alive unless you prefer to fail
// the call
totals.err(Math.max(0, (ctxRef.get() != null ? ctxRef.get().received : 0) - 1), "DB_ERROR", e.getMessage(),
"");
// Issue #4806: per-row errors are handled row-by-row inside insertRows, so an exception
// reaching here is a transaction-level failure (typically a mid-stream PER_BATCH/PER_ROW
// commit that has already rolled the transaction back). Record it once at the transaction
// level (rowIndex -1) instead of mis-attributing it to a single row, and mark the stream
// failed so subsequent chunks are not inserted into the broken transaction. onCompleted
// delivers the summary.
streamFailed.set(true);
final String code = e instanceof DuplicatedKeyException ? "CONFLICT" : "COMMIT_FAILED";
totals.err(-1, code, e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName(), "");
} finally {
} catch (Exception e) {
// Issue #4806: per-row errors are handled row-by-row inside insertRows, so an exception
// reaching here is a transaction-level failure (typically a mid-stream PER_BATCH/PER_ROW
// commit that has already rolled the transaction back). Record it once at the transaction
// level (rowIndex -1) instead of mis-attributing it to a single row, and mark the stream
// failed so subsequent chunks are not inserted into the broken transaction. onCompleted
// delivers the summary.
streamFailed.set(true);
final String code = e instanceof DuplicatedKeyException ? "CONFLICT" : "COMMIT_FAILED";
totals.err(-1, code, e.getMessage() != null ? e.getMessage() : e.getClass().getSimpleName(), "");
try {
final InsertContext ctx = ctxRef.get();
if (ctx != null && ctx.db != null && ctx.db.isTransactionActive()) {
ctx.db.rollback();
}
} catch (Exception rollbackEx) {
LogManager.instance().log(this, Level.WARNING, "Failed to rollback active transaction on mid-stream failure", rollbackEx);
}
}

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: fix(#4806) gRPC insertStream mid-stream commit failure

Solid, well-scoped fix with excellent root-cause analysis. The code comments tying each change back to its issue number (#4198/#4644/#4806) make the streaming state machine much easier to follow, and the regression test reproduces the original 3-error symptom precisely. A few observations, mostly minor.

Correctness / data consistency

  1. received is undercounted in the summary when insertRows throws (minor, pre-existing). In onNext, insertRows(...) increments c.received per row, but totals.add(cts) only runs if insertRows returns normally (ArcadeDbGrpcService.java:1738-1739). When the mid-stream flushCommit throws, cts is discarded, so the failing chunk's rows never reach totals.received. The resulting summary reports received=0, failed=1 - failed > received, internally inconsistent. The new test sidesteps this by not asserting received. Since the client did send the row, arguably received should reflect it. Not introduced by this PR (the old catch had the same gap), but this is a natural place to fix it - e.g. add the failing chunk's getRowsCount() to totals.received.

  2. Asymmetry with recordCommitException is actually correct - worth a one-line note. The new catch deliberately does not reclassify previously-counted inserted/updated as failed, unlike recordCommitException. That's right: in PER_BATCH/PER_ROW the earlier batches already committed and persisted, while the failing batch's counts were dropped along with cts. The contrast with the onCompleted path (where the deferred whole-stream commit really does roll back optimistically-counted rows) is subtle enough that a short comment would help the next reader.

  3. streamFailed semantics for PER_STREAM/PER_REQUEST. An exception escaping insertRows in those modes can't come from a mid-stream flushCommit (it is a no-op until end), so it would only be a setup/structural error. Setting streamFailed then skips the deferred commit in onCompleted, discarding everything accumulated in the stream. That is a reasonable all-or-nothing stance, but a behavior change from the previously per-row-error-tolerant path. Worth confirming this is intended for non-PER_BATCH modes.

Maintainability

  1. Duplicated code-derivation logic. e instanceof DuplicatedKeyException ? "CONFLICT" : "COMMIT_FAILED" plus the getMessage() != null ? ... : getClass().getSimpleName() fallback now appears both at :1748 and in recordCommitException (:1831-1832). Consider extracting a small helper (classifyCommitError(e)) to keep the two in sync.

Test coverage

  1. Only the PER_BATCH + DuplicatedKeyException -> CONFLICT path is exercised. The PER_ROW path (also escapes via flushCommit) and the COMMIT_FAILED branch (non-duplicate commit failure) are untested. A second case would lock in the other half of the new code branch.

  2. The test is an ...IT (runs in the integration phase, good), creates a server and waits up to 30s. Consistent with the sibling insertStream ITs.

Nits

  • GRPC_PORT = 50051 hardcoded, but matches every other gRPC IT in the module, so consistent.
  • docs/4806-grpc-insertstream-commit-failure.md is a nice analysis artifact; confirm the team wants per-issue markdown checked into docs/ (there appear to be siblings, so this seems to be the convention).

Overall this is a correct, targeted fix that removes the mis-indexed error and the processing-on-a-dead-transaction bug. The received-undercount in point 1 is the only thing I would consider addressing before merge; the rest are optional polish.

@robfrank

Copy link
Copy Markdown
Collaborator Author

Thanks for the reviews. Addressed in ae0837c and f28957a:

@gemini-code-assist (transaction leak on a non-commit failure): valid - a structural failure (e.g. "options changed mid-stream") leaves the transaction active and bound to the pooled gRPC thread. Added InsertContext.abortTransaction() which rolls back only if the transaction is still active on the calling thread (releasing locks and clearing the binding) and drops the captured handle. It is called from the onNext catch (on the failing thread, where the transaction is bound) and defensively in onCompleted when the stream already failed. I deliberately did not follow the literal suggestion of calling bindToCurrentThread() first, because the captured handle points at a dead transaction and re-binding it would re-pollute the thread-local; abortTransaction() never re-binds. New regression test midStreamContractChangeAbortsActiveTransactionAndReportsSingleError proves the buffered row is rolled back rather than committed by the deferred commit.

@claude:

  1. received undercount (failed > received): fixed - the failing chunk's getRowsCount() is now added to totals.received in the catch.
    2/3. Asymmetry vs recordCommitException and the all-or-nothing stance for PER_STREAM/PER_REQUEST: confirmed intentional and documented in comments. A structural mid-stream failure is not a recoverable per-row error, so the deferred commit is skipped rather than persisting a partial stream; and the mid-stream catch intentionally does not reclassify already-committed inserted/updated.
  2. Duplicated classification logic: extracted commitErrorCode(e) and exceptionMessage(e), now shared by both paths.
  3. COMMIT_FAILED branch coverage: the new contract-change test exercises the non-DuplicatedKeyException (COMMIT_FAILED) branch.

All 23 insertStream ITs (2 new + 21 existing across #4198/#4214/#4644/#4656) pass with no regressions.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

The implementation of abortTransaction() correctly ensures that the transaction is rolled back and the handle is cleared, preventing thread-local pollution. The extraction of commitErrorCode(e) and exceptionMessage(e) into helper methods is a clean improvement for maintainability. The updated logic in onCompleted and the catch block correctly handles the transaction-level failure state. The changes look solid.

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: fix(#4806) - stop gRPC insertStream after a mid-stream commit failure

Solid, well-scoped fix with a clear root-cause writeup and good inline comments. The two ITs cover the two distinct transaction-level failure modes (a deferred commit failure that the engine already rolled back, and a contract-change rejection that leaves the tx active), and they follow the existing sibling-IT conventions (BaseGraphServerTest, GRPC_PORT 50051, no new deps). Nice touch distinguishing the "already rolled back" vs "still active and bound to a pooled thread" cases and rolling back on the failing thread to release locks.

A few points worth considering, none blocking:

1. Partial-chunk accounting can under-report persisted rows (edge case)

In PER_BATCH with server_batch_size smaller than a chunk's row count, insertRows commits intermediate mini-batches via flushCommit(false) (line ~2498). If a later row's commit fails, the earlier mini-batches in that same chunk are already durable, but because the exception escapes insertRows, totals.add(cts) (line 1739) is skipped - so those persisted rows are never counted, and the summary reports inserted=0 for a chunk that actually wrote rows. The new tests use single-row chunks (server_batch_size=1), so this path isn't exercised. Probably out of scope for #4806, but the divergence between what the summary says and what is in the DB is worth a follow-up note or a code comment so it is not silently assumed handled.

2. COMMIT_FAILED code for non-commit failures is slightly misleading

The catch labels any non-DuplicatedKeyException as COMMIT_FAILED, and the second test asserts that even for an "options changed mid-stream" contract violation (an IllegalArgumentException, not a commit failure at all). The code/message pair is a bit contradictory from a client's perspective. Consider a distinct code (e.g. STREAM_ABORTED / CONTRACT_VIOLATION) for the validation path, or confirm COMMIT_FAILED is the intended catch-all the client API documents.

3. Defensive abortTransaction() in onCompleted and pooled-thread state

When streamFailed is set, onCompleted calls ctx.abortTransaction() without re-binding (correct, since the handle is dead). But abortTransaction() keys off db.isTransactionActive() on the current thread. In the normal path tx was already nulled in onNext, so this is a no-op. The theoretical risk: if onCompleted runs on a pooled gRPC thread that still carries a stale active transaction binding for this same db path from a prior request, the db.rollback() would roll back that unrelated tx. Low risk given normal per-request cleanup, and it mirrors the existing thread-hop handling, but worth a sanity check that bindings are always cleared at request end.

4. Minor: call.request(1) in the short-circuit branch

The new streamFailed short-circuit (lines 1683-1686) calls call.request(1) unconditionally, whereas the finally guards it with !cancelled.get(). Harmless because cancelled is checked immediately above and nothing async intervenes, but mirroring the !cancelled.get() guard would keep the two drain paths consistent.

Style / conventions

  • Imports (DuplicatedKeyException, AtomicBoolean) already present - good.
  • The docs/4806-...md writeup matches the existing docs/ convention for issue analyses.
  • These are ITs (network + server), consistent with siblings that carry no @Tag - fine, since they run in the IT phase rather than the unit phase.

Overall this is a correct, targeted fix that removes the spurious extra errors and the mis-indexing, and the regression coverage is genuinely good. The accounting gap in (1) is the only thing I would flag for a follow-up.

@robfrank

Copy link
Copy Markdown
Collaborator Author

Thanks @claude, addressed in 84f21e0:

  1. Misleading COMMIT_FAILED for a non-commit failure: agreed. commitErrorCode() now classifies a stream contract rejection (IllegalArgumentException, e.g. "options changed mid-stream") as CONTRACT_VIOLATION, keeping CONFLICT for DuplicatedKeyException and COMMIT_FAILED for actual commit failures. The contract-change test asserts CONTRACT_VIOLATION.
  2. Defensive abortTransaction() in onCompleted could roll back an unrelated pooled-thread tx: good catch - removed it. The onNext catch already aborts the transaction on the thread it was bound to and clears the handle, so the onCompleted cleanup was redundant; doing a rollback() on the (possibly different, pooled) onCompleted thread risked rolling back a transaction another request left bound to it. Replaced with a comment explaining why no cleanup happens there.
  3. call.request(1) guard in the short-circuit: mirrored the !cancelled.get() guard since cancellation is asynchronous.
  4. Partial-chunk inserted under-count (server_batch_size < chunk size): confirmed out of scope for gRPC insertStream keeps processing after a commit failure and mis-indexes the error #4806 and documented as a follow-up in a code comment at the catch - the discarded Counts drops the count of mini-batches that already committed within the failing chunk; a precise per-chunk reconciliation is separate work.

All 23 insertStream ITs still pass.

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: PR #4820 - stop gRPC insertStream after a mid-stream commit failure

Thanks for the careful write-up and the two regression ITs. The core change is sound: an exception escaping insertRows is genuinely a transaction-level failure, so recording it once at rowIndex = -1, marking streamFailed, draining the rest of the stream, and skipping the deferred commit in onCompleted is the right shape. The extracted commitErrorCode/exceptionMessage helpers and the abortTransaction() thread-binding reasoning are good. A few things worth addressing before merge.

1. Summary can over-report inserted/updated when buffered rows are rolled back (main concern)

The catch deliberately does not reclassify previously counted inserted/updated as failed (lines 1754-1756), with the rationale that "in PER_BATCH/PER_ROW the earlier batches already committed and persisted." That is true for committed batches, but not for rows buffered in the still-active transaction that abortTransaction() then rolls back.

Your own second test exercises exactly this: midStreamContractChangeAbortsActiveTransactionAndReportsSingleError uses PER_BATCH with the default (1000) batch size, so chunk 0's Buffered row is counted into totals.inserted (insertRows returns c.inserted=1, totals.add(c)), but it is never committed. The contract violation on chunk 1 then calls abortTransaction(), which rolls Buffered back. Result:

  • DB state: 0 rows (the test asserts this - correct).
  • InsertSummary: received=2, inserted=1, failed=1 - inserted=1 is wrong, nothing persisted.

This is precisely the discrepancy recordCommitException was written to avoid (it reclassifies inserted+updated -> failed on rollback). The onNext path needs the same treatment, but only for the uncommitted portion (rows since the last successful flushCommit). The committed batches must stay counted.

2. Mirror image: same-chunk committed batches are silently dropped

The root cause of (1) is that the partial Counts c from the throwing insertRows call is discarded entirely. Consider a single chunk of 3 rows with serverBatchSize=1: rows 1 and 2 commit (persisted), row 3's commit throws. c (received=3, inserted=2) is thrown away; the catch does totals.received += 3 and totals.err(...) (failed=1), so the summary reports received=3, inserted=0, failed=1 - the 2 persisted rows vanish from inserted.

So depending on the scenario the summary either over-reports (buffered, rolled back) or under-reports (committed, persisted) inserted. Both stem from dropping c. The clean fix is to let insertRows surface its partial counts on failure (e.g. accumulate into ctx/an out-param, or attach to the thrown exception), then in the catch add the persisted portion to totals and reclassify only the buffered portion as failed. That would also let you assert exact counts in the tests.

3. received accounting is inconsistent between the failing chunk and drained chunks

The failing chunk's rows are added to received ("the client did send them"), but subsequent chunks short-circuited by the streamFailed guard (line 1683) are drained without counting their rows. By the same logic those should arguably count too. Whichever convention you pick, it would be good to make it consistent and assert it.

4. Test coverage gap

Both new tests assert the error list and DB state but not the summary tallies (getReceived()/getInserted()/getFailed()), unlike Issue4198InsertStreamCommitErrorIT which pins all three. Adding those assertions would lock in the accounting contract and would have surfaced (1). I'd suggest asserting the full summary in both tests.

Minor / out of scope

  • closeQuietly() -> close() is an empty body, so the onError path never rolls back a live transaction. Pre-existing and not introduced here, but related to the leak concerns this PR is tightening; might be worth a follow-up.
  • The docs/4806-...md file matches the existing per-issue doc convention - good.
  • These ITs spin up a server and hardcode port 50051 (consistent with siblings); fine, just flagging they won't run in parallel with the other gRPC ITs.

Summary

The behavioral fix (stop processing, single transaction-level error, skip deferred commit) is correct and well-justified. The remaining issue is summary accuracy after a rollback of buffered rows - the reported inserted/updated can disagree with what actually persisted, and the second test demonstrates the case without asserting against it. Addressing (1)/(2) and tightening the test assertions (4) would make this solid.

@claude

claude Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Claude finished @robfrank's task in 1m 18s —— View job


Review: fix(#4806) - final round (84f21e0)

All four points are correctly addressed. Here is what I verified:

Point 2 - CONTRACT_VIOLATION code

The extracted commitErrorCode() now has a clean three-way classification:

  • DuplicatedKeyException → CONFLICT
  • IllegalArgumentException → CONTRACT_VIOLATION
  • anything else → COMMIT_FAILED

One micro-edge: if a commit path itself unexpectedly throws IllegalArgumentException, it would land as CONTRACT_VIOLATION rather than COMMIT_FAILED. That's a very narrow theoretical mis-classification and the mapping is reasonable in practice since IllegalArgumentException from the engine means a validation/structural rejection, not a commit abort. Not worth changing.

Point 3 - no abortTransaction() on the onCompleted thread

The removal is correct and the added comment explains it well. The onNext catch calls failedCtx.abortTransaction() while still on the thread that owns the transaction binding - that's the right thread. The onCompleted comment clearly explains why it deliberately does not try to clean up (risk of rolling back an unrelated transaction on a pooled thread). This reasoning is sound.

abortTransaction() itself is a clean, idempotent implementation - it guards on isTransactionActive(), catches and swallows the engine rolling it back first, and always nulls tx in finally. The "must be called on the thread whose context holds the transaction" Javadoc note correctly documents the threading contract.

Point 4 - call.request(1) guard in the short-circuit

The short-circuit branch now mirrors the !cancelled.get() guard consistently with the finally block. Good.

Point 1 - partial-chunk accounting gap

The inline comment at the catch site is clear and appropriately scoped. The received fix (adding c.getRowsCount()) is in the right place.

Test coverage

Both tests are well-structured:

  • midStreamCommitFailureStopsStreamAndRecordsTransactionLevelError - covers CONFLICT / DuplicatedKeyException via the deferred commit path.
  • midStreamContractChangeAbortsActiveTransactionAndReportsSingleError - covers CONTRACT_VIOLATION / IllegalArgumentException and verifies rollback via a row count query (good end-to-end check that the buffered row was not leaked into a commit).

The ctx == null path in onCompleted now returns accumulated totals (with errors) rather than hard-coded zeros - that's a correct improvement that handles the "first-chunk setup failed before ctxRef.set(ctx)" edge case too.

This PR is good to go.

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: PR #4820 - stop gRPC insertStream after a mid-stream commit failure

Reviewed the diff against ArcadeDbGrpcService.insertStream/InsertContext and the new IT. This is a well-targeted, carefully-reasoned fix. The root-cause analysis is correct: an exception escaping insertRows is by construction a transaction-level failure (per-row errors are all caught inside insertRows), so recording it at rowIndex = -1 and halting further inserts into the rolled-back transaction is the right behavior. The code is unusually well commented and the two ITs cover both the commit-failure (CONFLICT) and the structural/contract-change (CONTRACT_VIOLATION) paths.

Strengths

  • streamFailed short-circuit + drain is the correct pattern: it keeps pulling inbound chunks (call.request(1)) so the stream still reaches onCompleted, while never touching the dead transaction. Skipping the deferred flushCommit in onCompleted avoids the spurious "Transaction not begun" re-raise.
  • abortTransaction() reasoning is sound. It only rolls back when db.isTransactionActive() is true on the calling thread (so a commit-failure case, where the engine already rolled back, just clears the handle), and the explicit decision not to roll back from onCompleted (possibly a different pooled thread) is correct - I confirmed InsertContext.close()/closeQuietly() is a no-op, so there is no cross-thread rollback risk there.
  • Extracting commitErrorCode()/exceptionMessage() shared by both the mid-stream and deferred-commit (Bug: InsertStream surfaces commit-time constraint violations as a stream-level INTERNAL error instead of populating InsertSummary.errors #4198) paths is a good dedup that keeps the two in sync.
  • Counts.err() increments failed, so for the single-row failing chunk received == failed == 1 - the summary stays internally consistent.

Minor / discussion points (non-blocking)

  1. received under-counts rows the client actually streamed. Subsequent chunks that arrive after streamFailed is set are drained but never added to totals.received (the short-circuit returns before any counting). So a client that streamed 2 rows and hit a failure on row 1 sees received = 1. The failing chunk itself is counted (totals.received += c.getRowsCount()), but later drained chunks are not. Arguably intended ("we stopped attempting"), but it means received no longer reflects "rows the server received over the wire," which could surprise a client doing reconciliation. Worth a one-line comment clarifying the intended semantics, or counting drained rows too.

  2. commitErrorCode() classifies by exception type, not by origin. IllegalArgumentException -> CONTRACT_VIOLATION is correct for the explicit "options changed mid-stream" throw, but it is slightly fragile: if db.commit() (or any commit-path code) ever throws an IllegalArgumentException for a genuine data/validation reason, it would be mislabeled CONTRACT_VIOLATION instead of COMMIT_FAILED. This also subtly widens the behavior of the pre-existing Bug: InsertStream surfaces commit-time constraint violations as a stream-level INTERNAL error instead of populating InsertSummary.errors #4198 recordCommitException path (previously only CONFLICT/COMMIT_FAILED). Low risk in practice, but classifying the contract violation at the throw site (a dedicated marker exception) would be more robust than keying off IllegalArgumentException.

  3. Multi-row failing chunk accounting is acknowledged as a known limitation in the comment (the N-1 non-failing rows of a failed chunk land in received but neither inserted nor failed). Fine to defer; the in-code documentation of it is appreciated.

Test coverage

Good coverage of both failure modes plus the "Charlie not inserted" / "buffered row rolled back" assertions. Two suggestions:

  • Assert the numeric summary fields (getReceived(), getFailed(), getInserted()) in addition to the errors list, to pin down the accounting contract from point 1 and guard against regressions.
  • Consider a PER_ROW (and/or PER_STREAM) variant - the fix touches all deferred-commit modes but the ITs only exercise PER_BATCH.
  • These ITs spin up a server; if they run noticeably long, consider @Tag("slow") per CLAUDE.md (a single-row insert is likely fast enough to leave untagged).

Overall a solid, correct fix with strong documentation and tests. The points above are minor and can be addressed in follow-ups. Nice work.

@codecov

codecov Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.76744% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.24%. Comparing base (6aa559c) to head (7da6b89).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
.../com/arcadedb/server/grpc/ArcadeDbGrpcService.java 69.76% 9 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4820      +/-   ##
============================================
+ Coverage     65.21%   65.24%   +0.02%     
  Complexity      757      757              
============================================
  Files          1681     1681              
  Lines        133522   133603      +81     
  Branches      28514    28532      +18     
============================================
+ Hits          87079    87165      +86     
+ Misses        34482    34470      -12     
- Partials      11961    11968       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

robfrank and others added 4 commits June 30, 2026 15:50
…and stop mis-indexing the error

A mid-stream commit failure in insertStream (e.g. a deferred unique-index
violation surfacing at db.commit() in PER_BATCH/PER_ROW mode) escaped insertRows
and was recorded against a single context-wide row index (ctx.received-1) with a
generic DB_ERROR code, while the finally kept pulling more chunks against the
now rolled-back transaction. Subsequent rows then operated on the broken
transaction, producing spurious "Transaction not begun" errors.

Mark the stream failed on a transaction-level exception, record it once at the
transaction level (rowIndex -1, code CONFLICT/COMMIT_FAILED) instead of
attributing it to a wrong row, skip inserting further chunks, and skip the
deferred commit in onCompleted (the transaction is already gone). A structured
InsertSummary is still delivered, consistent with #4198/#4214.

Adds Issue4806InsertStreamMidStreamCommitFailureIT.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…re (review)

Address review feedback: a transaction-level failure that is not a commit
failure (e.g. an "options changed mid-stream" rejection or a schema error)
leaves the PER_BATCH/PER_ROW transaction still active and bound to the pooled
gRPC thread, leaking its locks and thread-local binding into a later request
that reuses the thread.

Add InsertContext.abortTransaction(): rolls back the transaction if still active
on the calling thread (releasing locks and clearing the binding) and drops the
captured handle so the dead transaction is never re-bound. Call it from the
onNext catch (on the failing thread) and defensively in onCompleted when the
stream already failed. abortTransaction does not re-bind, avoiding rebinding a
dead transaction onto a pooled thread.

Adds a regression test for the contract-change path proving the buffered row is
rolled back rather than committed by the deferred onCompleted commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ssification (review)

Address review feedback:
- Count the failing chunk's rows as received when insertRows throws and discards
  its partial Counts, so the summary can no longer report failed > received.
- Extract commitErrorCode()/exceptionMessage() helpers shared by the mid-stream
  onNext failure path and the deferred whole-stream recordCommitException path so
  the CONFLICT/COMMIT_FAILED classification stays in sync.
- Clarify in comments that the mid-stream catch does not reclassify
  already-committed inserted/updated (unlike recordCommitException) and that
  skipping the deferred commit is an intentional all-or-nothing stance for
  structural failures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…rollback (review)

Address second review pass:
- Classify a stream contract rejection (IllegalArgumentException, e.g. "options
  changed mid-stream") as CONTRACT_VIOLATION instead of the misleading
  COMMIT_FAILED; it is not a commit failure. Update the regression test.
- Remove the defensive abortTransaction() in onCompleted: the onNext catch
  already aborts the transaction on the thread it was bound to, so the
  onCompleted call was redundant and could roll back an unrelated transaction
  left bound to a reused pooled thread.
- Guard the streamFailed short-circuit call.request(1) with !cancelled.get() to
  mirror the finally drain path (cancellation is asynchronous).
- Document the known partial-chunk inserted under-count limitation (server batch
  size smaller than a chunk) as an out-of-scope follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@robfrank
robfrank force-pushed the fix/4806-grpc-insertstream-keeps-processing-after branch from 84f21e0 to a4d2592 Compare June 30, 2026 13:51
@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: fix(#4806) gRPC insertStream mid-stream commit failure

Thanks for this - the root-cause analysis is excellent and the fix is well targeted. Distinguishing a transaction-level failure (anything that escapes insertRows, since per-row errors are caught row-by-row inside it) from a recoverable per-row error is the right framing, and recording it once at rowIndex == -1 is clearly correct. The two ITs, the shared commitErrorCode()/exceptionMessage() helpers, and the deliberate decision not to call abortTransaction() from onCompleted (where the tx may be bound to a different pooled thread) are all good calls.

A few observations, one of which I think is worth addressing before merge.

1. (Medium) Summary can over-report inserted/updated after abortTransaction() rolls back uncommitted rows

insertRows resets inBatch = 0 on every call (line 2684), so in PER_BATCH with a batch size larger than the per-chunk row count - and always in PER_STREAM - rows from earlier chunks stay uncommitted in the still-active transaction. When a later chunk triggers a transaction-level failure, abortTransaction() rolls those rows back, but they were already folded into totals.inserted/totals.updated via totals.add(cts).

The onNext catch deliberately skips the reclassification that recordCommitException does, with the comment "in PER_BATCH/PER_ROW the earlier batches already committed and persisted." That reasoning holds for batches that actually committed, but it overlooks the uncommitted-yet-counted rows that abortTransaction() then rolls back. Result: the client receives inserted = 1 for a row that is not in the database.

This is exactly the path midStreamContractChangeAbortsActiveTransactionAndReportsSingleError exercises: "Buffered" is counted as inserted, then rolled back. The test asserts the DB row count is 0 (good) but never asserts summary.getInserted(), so the over-report slips through.

Suggestion: have abortTransaction() report whether a rollback actually happened, and when it did, reclassify the still-uncommitted inserted/updated as failed (the symmetric counterpart to recordCommitException). At minimum, add a summary.getInserted() / getFailed() assertion to the contract test so the count contract is pinned, and document the gap.

2. (Minor) COMMIT_FAILED can mislabel non-commit structural failures

commitErrorCode() returns COMMIT_FAILED as the catch-all. But not everything escaping insertRows is a commit: e.g. schema.getType(targetClass) (line 2687) runs before the row loop and would surface a missing/invalid target type as COMMIT_FAILED, when no commit was ever attempted. Probably acceptable given the dominant case, but worth a second look at whether a more neutral default code is warranted.

3. (Minor) New CONTRACT_VIOLATION client-facing code is undocumented

The added CONTRACT_VIOLATION code is a new value in the client-visible InsertError.code contract. Error codes here are free-form strings, so clients may switch on them. Consider documenting the full code set (CONFLICT, CONTRACT_VIOLATION, COMMIT_FAILED, DB_ERROR, MISSING_ENDPOINTS, INVALID_KEY_COLUMN) somewhere discoverable.

4. (Nit) Stale note in the docs file

docs/4806-...md cycle-2 note says "the contract-change test covers the COMMIT_FAILED branch", but that test asserts CONTRACT_VIOLATION. The COMMIT_FAILED branch doesn't appear to have a direct assertion.

5. (Nit/edge) Transaction leak if the InsertContext constructor throws after db.begin()

If the constructor throws after db.begin() but before ctxRef.set(ctx), the onNext catch sees failedCtx == null and skips abortTransaction(), leaving a begun transaction bound to the pooled gRPC thread. Narrow window and largely pre-existing, but streamFailed plus the ctx == null path in onCompleted won't clean it up either.


Overall a solid, well-tested fix that clearly improves correctness over the prior behavior. #1 is the one I'd like to see resolved (or at least explicitly asserted/documented); the rest are minor.

…leak

- #1 (medium): abortTransaction() now reports whether it rolled back an active tx; the
  mid-stream onNext catch reclassifies still-uncommitted inserted/updated as failed when
  it did (PER_STREAM/PER_REQUEST, or PER_BATCH with batch > chunk), so the summary no
  longer over-reports rows that were rolled back. Counts stand when nothing rolled back
  (PER_BATCH/PER_ROW already-committed batches). Contract-change test now asserts
  inserted==0, received==2, failed==2.
- #5 (edge): InsertContext ctor rolls back its own just-begun transaction if construction
  fails after db.begin(), closing a leak the mid-stream path could not reach (ctxRef unset).
- #4/#3 (docs): correct the stale 'COMMIT_FAILED' note (test asserts CONTRACT_VIOLATION) and
  document the full InsertError.code set.
@codacy-production

codacy-production Bot commented Jun 30, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 79.07% diff coverage · +24.39% coverage variation

Metric Results
Coverage variation ✅ +24.39% coverage variation
Diff coverage ✅ 79.07% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6d1d611) 133572 56871 42.58%
Head commit (7da6b89) 165406 (+31834) 110764 (+53893) 66.96% (+24.39%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4820) 43 34 79.07%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@claude

claude Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review: PR #4820 - stop gRPC insertStream after a mid-stream commit failure

Solid, well-scoped fix for #4806. The root-cause framing is correct (anything escaping insertRows is transaction-level, not per-row), the streamFailed short-circuit + transaction-level error reporting is the right shape, and the supporting edge cases (constructor tx-leak, not rolling back on a possibly-different pooled onCompleted thread) are handled with care. The extracted commitErrorCode()/exceptionMessage() helpers remove duplication and keep the #4806 and #4198 paths in sync, in line with the repo's reuse guidance. Per-issue docs/ note matches the existing convention.

A few observations, one worth a closer look.

1. (Edge case, correctness) failed over-reporting when a rolled-back active tx coexists with already-committed batches

In the onNext catch (lines 2026-2030):

```java
if (rolledBack) {
totals.failed += totals.inserted + totals.updated;
totals.inserted = 0;
totals.updated = 0;
}
```

totals.inserted is cumulative for the whole stream, but the rolled-back transaction only contains the rows since the last successful batch commit. The comment justifies this with "When nothing was rolled back the earlier batches had already committed... their counts stand" - i.e. it assumes rolledBack == true implies nothing committed earlier. That holds for PER_STREAM/PER_REQUEST, but not for PER_BATCH when server_batch_size spans multiple chunks:

  • batch size 2, single-row chunks
  • chunk 0: row A buffered (not committed), inserted=1
  • chunk 1: row B -> batch full -> A+B committed durably, inserted=2
  • chunk 2: row C buffered, inserted=3
  • chunk 3: options changed -> IllegalArgumentException (CONTRACT_VIOLATION) thrown before insertRows; row C's tx is still active -> rolledBack == true

Result: failed += 3 reclassifies A and B (durably committed, still in the DB) as failed, and the summary reports inserted=0 while the database actually holds A and B. The summary then disagrees with durable state.

This is narrow (requires PER_BATCH with batch > chunk + a mid-stream contract change after at least one committed batch), and the same optimistic-zeroing assumption already exists in the pre-existing recordCommitException (line 2111), so it's not a regression introduced here. But since this PR adds a second copy of the pattern, it's worth either guarding it to only reclassify the uncommitted tail or explicitly documenting it alongside the existing "received under-reporting" known-limitation note so the two stay consistent.

2. Test coverage

The two ITs are strong - they assert balanced counts (received == inserted + updated + failed), the transaction-level rowIndex == -1, the distinct CONFLICT vs CONTRACT_VIOLATION codes, and the actual DB state (Charlie not inserted, count == 0). Nicely done.

The one gap is exactly the scenario in #1: there's no test for PER_BATCH with a batch size larger than the chunk where earlier batches committed before the failure. Adding one would either confirm the current counts are acceptable or surface the over-reporting, and would lock the behavior down.

3. Minor

  • Consider @Tag("slow") for consistency with the sibling Issue4656InsertStreamConflictUpdateIT (server startup + several DDL round-trips). Optional.
  • commitErrorCode() keeping COMMIT_FAILED as the catch-all even for a pre-loop structural failure is reasonable given InsertError.code is a client-visible contract; the doc already calls this out.

Verdict

Correct and clearly the right direction for #4806. Recommend addressing #1 (at minimum a documenting comment + a covering test), otherwise good to merge.

Reviewed against CLAUDE.md conventions (reuse, final usage, structured-summary-over-Status.INTERNAL stance, per-issue docs). I did not run the build/ITs in this review.

@robfrank
robfrank merged commit e21ddb3 into main Jun 30, 2026
18 of 25 checks passed
@robfrank
robfrank deleted the fix/4806-grpc-insertstream-keeps-processing-after branch June 30, 2026 14:15
mergify Bot added a commit that referenced this pull request Jul 29, 2026
…io with 2 updates [skip ci]

Bumps the build-tools group in /studio with 2 updates: [webpack](https://github.com/webpack/webpack) and [webpack-cli](https://github.com/webpack/webpack-cli).
Updates `webpack` from 5.109.0 to 5.109.2
Release notes

*Sourced from [webpack's releases](https://github.com/webpack/webpack/releases).*

> v5.109.2
> --------
>
> ### Patch Changes
>
> * Resolve aliases pointing at a package directory whose name ends with `.js` again. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21542](https://redirect.github.com/webpack/webpack/pull/21542))
> * Name CSS sources in source maps by their resource path, without the `css`  prefix. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21536](https://redirect.github.com/webpack/webpack/pull/21536))
> * Delete no longer referenced files from the filesystem cache directory after storing the cache, age them by recorded time so restored caches are cleaned too, and collect every fully expired pack in one store instead of one per build. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21528](https://redirect.github.com/webpack/webpack/pull/21528))
> * Report `"universal"` as the loader context target for the universal target. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21540](https://redirect.github.com/webpack/webpack/pull/21540))
> * Skip `require().prop` in dead branches gated by inlined imported constants. (by [`@​hai-x`](https://github.com/hai-x) in [#21517](https://redirect.github.com/webpack/webpack/pull/21517))
> * Annotate configuration options and public hooks in the generated types with the `@since` JSDoc tag. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21473](https://redirect.github.com/webpack/webpack/pull/21473))
>
> v5.109.1
> --------
>
> ### Patch Changes
>
> * Fix stray semicolon emitted before an imported call following a parenthesized sequence element. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21533](https://redirect.github.com/webpack/webpack/pull/21533))
> * Make `require(esm)` `module.exports` re-export analysis independent of module processing order. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21521](https://redirect.github.com/webpack/webpack/pull/21521))
> * Ignore ERR\_SERVER\_NOT\_RUNNING on lazy-compilation backend dispose so `compiler.close()` succeeds on Bun. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21521](https://redirect.github.com/webpack/webpack/pull/21521))
> * Name the failing key when DefinePlugin fails to evaluate a `typeof` value. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21503](https://redirect.github.com/webpack/webpack/pull/21503))
> * Improve Deno compatibility: guard `setNoDelay` and force-close connections on lazy-compilation backend dispose, and return a real `ArrayBuffer` from the Node async/sync wasm loader so `WebAssembly.instantiate` accepts it. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21524](https://redirect.github.com/webpack/webpack/pull/21524))
> * Speed up the HTML parser and cut its peak memory: module-scope helpers/state and tokenizer callbacks, plus exact AST column pre-sizing. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21492](https://redirect.github.com/webpack/webpack/pull/21492))
> * Track CommonJS build dependencies by parsing sources when `require.cache` children are unavailable (e.g. Bun). (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21531](https://redirect.github.com/webpack/webpack/pull/21531))
> * Cook common string-literal escapes on the JS parser fast path and own the tokenizer's cold-path readers. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21500](https://redirect.github.com/webpack/webpack/pull/21500))
> * Build the CSS `parseA*` AST on the SoA store instead of node classes, cutting parse memory and time. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21498](https://redirect.github.com/webpack/webpack/pull/21498))
> * Speed up and cut memory of the experimental CSS and HTML parsers: drop two derivable AST node columns, and scan long string, url, comment, and plaintext token bodies natively. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21504](https://redirect.github.com/webpack/webpack/pull/21504))
> * Speed up non-modules CSS parsing: skip redundant token re-reads, drop selector-prelude tokens without materializing nodes, allocate rule preludes lazily, and fast-path empty list seals. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21511](https://redirect.github.com/webpack/webpack/pull/21511))
> * Speed up stats generation and cut its peak memory: reuse cached sort comparators instead of thrashing the comparator caches on every sort, and drop redundant module-graph lookups and allocations in the extractors. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21506](https://redirect.github.com/webpack/webpack/pull/21506))
> * Speed up CSS parsing: byte-range function-name checks, indexed sibling lookahead. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21520](https://redirect.github.com/webpack/webpack/pull/21520))
> * Reduce allocations and redundant work across the code-generation, module-concatenation, exports/usage-analysis, hashing, and chunk-splitting hot paths. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21516](https://redirect.github.com/webpack/webpack/pull/21516))
> * Enable the Node.js compile cache in the webpack CLI entry point. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21523](https://redirect.github.com/webpack/webpack/pull/21523))
> * Encode the persistent cache with V8's value serializer. (by [`@​avivkeller`](https://github.com/avivkeller) in [#21514](https://redirect.github.com/webpack/webpack/pull/21514))

... (truncated)


Changelog

*Sourced from [webpack's changelog](https://github.com/webpack/webpack/blob/main/CHANGELOG.md).*

> 5.109.2
> -------
>
> ### Patch Changes
>
> * Resolve aliases pointing at a package directory whose name ends with `.js` again. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21542](https://redirect.github.com/webpack/webpack/pull/21542))
> * Name CSS sources in source maps by their resource path, without the `css`  prefix. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21536](https://redirect.github.com/webpack/webpack/pull/21536))
> * Delete no longer referenced files from the filesystem cache directory after storing the cache, age them by recorded time so restored caches are cleaned too, and collect every fully expired pack in one store instead of one per build. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21528](https://redirect.github.com/webpack/webpack/pull/21528))
> * Report `"universal"` as the loader context target for the universal target. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21540](https://redirect.github.com/webpack/webpack/pull/21540))
> * Skip `require().prop` in dead branches gated by inlined imported constants. (by [`@​hai-x`](https://github.com/hai-x) in [#21517](https://redirect.github.com/webpack/webpack/pull/21517))
> * Annotate configuration options and public hooks in the generated types with the `@since` JSDoc tag. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21473](https://redirect.github.com/webpack/webpack/pull/21473))
>
> 5.109.1
> -------
>
> ### Patch Changes
>
> * Fix stray semicolon emitted before an imported call following a parenthesized sequence element. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21533](https://redirect.github.com/webpack/webpack/pull/21533))
> * Make `require(esm)` `module.exports` re-export analysis independent of module processing order. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21521](https://redirect.github.com/webpack/webpack/pull/21521))
> * Ignore ERR\_SERVER\_NOT\_RUNNING on lazy-compilation backend dispose so `compiler.close()` succeeds on Bun. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21521](https://redirect.github.com/webpack/webpack/pull/21521))
> * Name the failing key when DefinePlugin fails to evaluate a `typeof` value. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21503](https://redirect.github.com/webpack/webpack/pull/21503))
> * Improve Deno compatibility: guard `setNoDelay` and force-close connections on lazy-compilation backend dispose, and return a real `ArrayBuffer` from the Node async/sync wasm loader so `WebAssembly.instantiate` accepts it. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21524](https://redirect.github.com/webpack/webpack/pull/21524))
> * Speed up the HTML parser and cut its peak memory: module-scope helpers/state and tokenizer callbacks, plus exact AST column pre-sizing. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21492](https://redirect.github.com/webpack/webpack/pull/21492))
> * Track CommonJS build dependencies by parsing sources when `require.cache` children are unavailable (e.g. Bun). (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21531](https://redirect.github.com/webpack/webpack/pull/21531))
> * Cook common string-literal escapes on the JS parser fast path and own the tokenizer's cold-path readers. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21500](https://redirect.github.com/webpack/webpack/pull/21500))
> * Build the CSS `parseA*` AST on the SoA store instead of node classes, cutting parse memory and time. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21498](https://redirect.github.com/webpack/webpack/pull/21498))
> * Speed up and cut memory of the experimental CSS and HTML parsers: drop two derivable AST node columns, and scan long string, url, comment, and plaintext token bodies natively. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21504](https://redirect.github.com/webpack/webpack/pull/21504))
> * Speed up non-modules CSS parsing: skip redundant token re-reads, drop selector-prelude tokens without materializing nodes, allocate rule preludes lazily, and fast-path empty list seals. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21511](https://redirect.github.com/webpack/webpack/pull/21511))
> * Speed up stats generation and cut its peak memory: reuse cached sort comparators instead of thrashing the comparator caches on every sort, and drop redundant module-graph lookups and allocations in the extractors. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21506](https://redirect.github.com/webpack/webpack/pull/21506))
> * Speed up CSS parsing: byte-range function-name checks, indexed sibling lookahead. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21520](https://redirect.github.com/webpack/webpack/pull/21520))
> * Reduce allocations and redundant work across the code-generation, module-concatenation, exports/usage-analysis, hashing, and chunk-splitting hot paths. (by [`@​alexander-akait`](https://github.com/alexander-akait) in [#21516](https://redirect.github.com/webpack/webpack/pull/21516))
> * Enable the Node.js compile cache in the webpack CLI entry point. (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#21523](https://redirect.github.com/webpack/webpack/pull/21523))

... (truncated)


Commits

* [`6a24bd6`](webpack/webpack@6a24bd6) chore(release): new release ([#21534](https://redirect.github.com/webpack/webpack/issues/21534))
* [`d1b5b6d`](webpack/webpack@d1b5b6d) fix: resolve aliases pointing at a package directory ending in .js ([#21542](https://redirect.github.com/webpack/webpack/issues/21542))
* [`9cdcc57`](webpack/webpack@9cdcc57) fix(target): report "universal" as the loader target ([#21540](https://redirect.github.com/webpack/webpack/issues/21540))
* [`774e7e4`](webpack/webpack@774e7e4) feat: annotate schema options with added keywords ([#21473](https://redirect.github.com/webpack/webpack/issues/21473))
* [`ff07bdc`](webpack/webpack@ff07bdc) fix(css): name CSS sources in source maps by their resource path ([#21536](https://redirect.github.com/webpack/webpack/issues/21536))
* [`d56d82d`](webpack/webpack@d56d82d) fix(cache): reclaim stale filesystem cache files reliably ([#21539](https://redirect.github.com/webpack/webpack/issues/21539))
* [`ae67e2a`](webpack/webpack@ae67e2a) chore(readme): add codspeed ([#21497](https://redirect.github.com/webpack/webpack/issues/21497))
* [`964bbfa`](webpack/webpack@964bbfa) fix: delete no longer referenced files from the filesystem cache directory (#...
* [`075d0cd`](webpack/webpack@075d0cd) feat: skip `require().prop` in dead branches ([#21517](https://redirect.github.com/webpack/webpack/issues/21517))
* [`ec39088`](webpack/webpack@ec39088) chore(release): new release ([#21493](https://redirect.github.com/webpack/webpack/issues/21493))
* Additional commits viewable in [compare view](webpack/webpack@v5.109.0...v5.109.2)
  
Updates `webpack-cli` from 7.2.1 to 7.2.2
Release notes

*Sourced from [webpack-cli's releases](https://github.com/webpack/webpack-cli/releases).*

> webpack-cli@7.2.2
> -----------------
>
> ### Patch Changes
>
> * perf: enable the Node.js compile cache (`module.enableCompileCache`, available on Node.js >= 22.8.0) to speed up CLI startup (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#4818](https://redirect.github.com/webpack/webpack-cli/pull/4818))


Changelog

*Sourced from [webpack-cli's changelog](https://github.com/webpack/webpack-cli/blob/main/CHANGELOG.md).*

> 7.2.2
> -----
>
> ### Patch Changes
>
> * perf: enable the Node.js compile cache (`module.enableCompileCache`, available on Node.js >= 22.8.0) to speed up CLI startup (by [`@​bjohansebas`](https://github.com/bjohansebas) in [#4818](https://redirect.github.com/webpack/webpack-cli/pull/4818))


Commits

* [`191fa9f`](webpack/webpack-cli@191fa9f) chore(release): new release ([#4820](https://redirect.github.com/webpack/webpack-cli/issues/4820))
* [`1082235`](webpack/webpack-cli@1082235) chore(deps-dev): bump js-yaml from 5.2.1 to 5.2.2 ([#4821](https://redirect.github.com/webpack/webpack-cli/issues/4821))
* [`e36ae82`](webpack/webpack-cli@e36ae82) chore: add publish workflow and script for pkg.pr.new integration ([#4819](https://redirect.github.com/webpack/webpack-cli/issues/4819))
* [`b0a2024`](webpack/webpack-cli@b0a2024) perf: enable the Node.js compile cache ([#4818](https://redirect.github.com/webpack/webpack-cli/issues/4818))
* [`53f6d72`](webpack/webpack-cli@53f6d72) chore(deps): bump actions/checkout in the dependencies group ([#4816](https://redirect.github.com/webpack/webpack-cli/issues/4816))
* [`8856346`](webpack/webpack-cli@8856346) chore: add allowscripts to work with npm 12 ([#4811](https://redirect.github.com/webpack/webpack-cli/issues/4811))
* [`0b0f1ee`](webpack/webpack-cli@0b0f1ee) chore(deps): bump fast-uri from 3.1.2 to 3.1.4 ([#4815](https://redirect.github.com/webpack/webpack-cli/issues/4815))
* [`d60a777`](webpack/webpack-cli@d60a777) chore(deps-dev): bump postcss from 8.5.10 to 8.5.22 ([#4814](https://redirect.github.com/webpack/webpack-cli/issues/4814))
* [`8c1719a`](webpack/webpack-cli@8c1719a) chore(deps): bump shell-quote from 1.8.4 to 1.10.0 ([#4813](https://redirect.github.com/webpack/webpack-cli/issues/4813))
* [`8c2473c`](webpack/webpack-cli@8c2473c) chore(deps): bump immutable from 5.1.5 to 5.1.9 ([#4812](https://redirect.github.com/webpack/webpack-cli/issues/4812))
* Additional commits viewable in [compare view](https://github.com/webpack/webpack-cli/compare/webpack-cli@7.2.1...webpack-cli@7.2.2)
  
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore  major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself)
- `@dependabot ignore  minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself)
- `@dependabot ignore ` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore ` will remove all of the ignore conditions of the specified dependency
- `@dependabot unignore  ` will remove the ignore condition of the specified dependency and ignore conditions
robfrank added a commit that referenced this pull request Aug 14, 2026
…and stop mis-indexing the error (#4820)

(cherry picked from commit e21ddb3)
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.

gRPC insertStream keeps processing after a commit failure and mis-indexes the error

1 participant