Repository navigation
fix(#8674): end a streamed batch relay cut by the follower's body cap with the leader's in-band 413 - #8720
Conversation
… with the leader's in-band 413 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe streamed batch relay now detects when the follower’s body-size cap interrupts a request. It tracks leader progress and terminal events, and writes an in-band 413 error when the cap is reached before a terminal event. ChangesStreamed batch relay
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The relay adds a separately framed 413 without an identified merge-blocking regression. The change is mergeable after normal checks; current JDK response timing still limits live exercise of this path. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change preserves database authorization and upload-size enforcement while improving refusal reporting. No introduced security vulnerability was established. Remaining uncertainty concerns future runtimes that deliver responses during upload and client handling of a terminal error without a consistency bookmark. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 22 |
🟢 Coverage 85.71% diff coverage · -6.02% coverage variation
Metric Results Coverage variation ✅ -6.02% coverage variation Diff coverage ✅ 85.71% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (2fa02b3) 200461 168972 84.29% Head commit (d818474) 233091 (+32630) 182448 (+13476) 78.27% (-6.02%) 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 (#8720) 70 60 85.71% 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.
Review of #8720The change is small, well scoped and honest about its reach. The relay refactor keeps the existing contracts. Only the cap-trip branch changes, and the discrimination is made on the stream ( 1. Counters come from the last line only (possible misreport)
Suggested fix: keep the counters from the last line that parsed as a A test for "progress line, then a truncated line, then a clean EOF after the cap trip" would pin whichever you choose. 2. Log attribution when the cap trips and the client write also failedIf the loop's 3. Dead-on-arrival production pathThe PR shows that this branch is unreachable on JDK 21, 25 and 27. The pin test 4. Tests
Style
Overall this is a good, safe defensive fix. I would address point 1 before merge, since it is the only place the new line could state something false. |
…ine, not a trailing fragment Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Review of #8720Overall this is a well-scoped change. The core logic reads correctly, the "ask the stream, not the failure" design is sound ( Potential bugs / edge cases
Style / conventions (CLAUDE.md)
PerformanceNo concerns: the extra work is one TestsGood coverage of the matrix (read failure vs clean EOF, fragment, no progress yet, leader already terminal, under-cap failure) and the JDK pin test is a nice tripwire. The PR description says the 3 cap-trip tests fail with the fix disabled, which is the right validation. Gaps: the trailing-blank-line case above, and a case where a Nice work on filing #8719 for the consequence on |
… 413 line when the client is gone Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ReviewOverall this is a careful, well-scoped defensive fix. The reasoning about JDK reachability is documented honestly (#8719 filed, comment in Code (
|
…ce signal in the cap log, tidy comments Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review of PR 8720 The change is small and well reasoned. The terminal-line invariant is enforced correctly: one 413 line when the cap trip cuts the relay, none when the leader already ended the stream, and none when the leader fails on a body under the cap. I read the diff only and did not run the tests. What looks good
Suggestions
The code matches project conventions ( |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8720 +/- ##
============================================
- Coverage 76.01% 75.99% -0.02%
+ Complexity 3655 3652 -3
============================================
Files 2067 2067
Lines 200461 200521 +60
Branches 42233 42243 +10
============================================
+ Hits 152371 152386 +15
- Misses 31531 31576 +45
Partials 16559 16559 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #8674
When a streamed (
Accept: application/x-ndjson) batch upload sent to a follower is cut by the follower'sarcadedb.server.httpBodyContentMaxSizeafter the leader has already started answering,relayNdJsonFromLeadernow writes the in-band terminal line the leader writes for the same refusal:{"error": {..., "status": 413, "exception": "io.undertow.server.RequestTooBigException", "exceptionArgs": "<cap>", "verticesCreated", "edgesCreated", "partialCommit"}}. It is built by the sameclassifyError/buildErrorBodyand carries the counters of the last relayed progress line. The follower's log now names this node's cap instead of blaming the leader relay. If the leader's answer already ends in a terminal line (summaryorerror), the relay adds nothing. The check asks the stream (CountingInputStream.refusedOverCap()) and not the failure, so it covers both a failed read and a leader answer that simply ends.Important finding: this sub-path cannot be reached on the JDKs we ship with. On JDK 21, 25 and 27, an HTTP/1.1
HttpClientexchange hands back the response only after the request body has been published whole, even when the leader has already sent 200 and a progress line. So a cap trip always fails the send itself, and #8161's real 413 answers it beforerelayNdJsonFromLeaderruns. I verified this with a raw-socket probe on all three JDKs, andtheJdkClientHandsBackTheResponseOnlyOnceTheUploadIsPublishednow pins it. The relay change is therefore a defense for the day that JDK behavior changes, and it is tested by driving the relay directly with a scripted leader answer. The same JDK behavior makes the existing comments inforwardBatchToLeaderwrong ("the send completes as soon as the leader's response HEADERS arrive"). The consequence is thatproxyBatchReadTimeoutcaps the whole streamed upload through a follower and progress lines are not incremental across the hop. That is filed as #8719, and the inline comment now points to it.Test plan
Issue8674StreamedRelayBodyCapTerminalLineTest(9 tests after review cycles: the original 6 plus fragment, line-after-terminal, and summary+blank-line cases; real Undertow exchange, scripted leader answer):partialCommit: truepartialCommit: falsetooBig = null), the 3 cap-trip tests fail and the 3 guards passCoverage
Invariant: a streamed relay whose upload this node's cap refused never ends without a terminal line, and it never gets two.
relayNdJsonFromLeader, read fails after the cap triprelayNdJsonFromLeader, clean EOF after the cap triprelayNdJsonFromLeader, leader already wrote a terminal lineforwardBatchToLeader, cap trips before the response is handed back (every case on JDK 21/25/27)Issue8161FollowerForwardBodyCapTest)CountingInputStreamgrep -rn -e refusedOverCap -e relayNdJson -e "new CountingInputStream" server/src/main ha-raft/src/mainfinds onlyPostBatchHandlerKnown gaps
sendBoundeddeadline covers the whole upload and progress lines are not incremental across the hop, because the JDK withholds the response until the upload is published. Out of scope here.commitIndexis not on the follower-built 413 line. The leader's own line carries its applied index, and the follower cannot state it.Adversarial pass
The skill's Phase 1.5 subagent could not be spawned (no subagent tool in this run's toolset), so this was a self-review:
streamRecordsAsNdJson's write-failure branch.Review cycles
partialCommit: false), FINE log of the relay failure, no null guard{"progress"prefix gate, no 413 write when the client is gone, test lines from the realNdJsonResultStream, asummaryterminal caseendedtracking (blank lines ignored), prefix gate removed,clientGoneskips the write, leader-built test lines, summary+blank testended, leader-expiry kept in the cap log, comment tidy-up, "see #8719" on the pin assertionended+ test, expiry in the cap log, comments moved, pin messageDeferred items
Not applied because max cycles was reached; left for the developer:
trackRelayedEventrunsnew JSONObject(line)on every relayed line ... Consider a cheap prefix orindexOfcheck on the event key, and parse onlyprogresslines." Cycle 2 asked for the opposite: drop thestartsWith("{\"progress\"")gate as fragile against serialization changes. Batch NDJSON lines are few (one per flush plus the terminal line), so the cost is small, but a key-prefix check guarded by a test driving the realNdJsonResultStreamwriter would satisfy both reviews.assumeTrueon it. Its assertion message already names A streamed batch forwarded by a follower gets no response until the upload ends, so proxyBatchReadTimeout caps the whole upload and progress lines are not incremental across the hop #8719 and says a failure is not an ArcadeDB regression. Left as a plain test so the signal is not silently skipped.isBlankcheck, inliningparseNdJsonLine, the log suffix as a local).rethrowIfRefusedOverCap(getUserSevereErrorLogLevel()). No change needed.new ServerSocket(0)/addHttpListener(0)loopback, like the neighbouringIssue7738/Issue8161tests.HardcodedTestServerPortsTestis green. Not changed.Final state
max-cycles-reached. Every review said nothing blocks the merge. One performance suggestion is deferred (above).🤖 Generated with Claude Code
Summary by CodeRabbit