Repository navigation
[client-v2] Document how an insert from an InputStream retries - #3404
Open
polyglotAI-bot wants to merge 1 commit into
Open
polyglotAI-bot wants to merge 1 commit into
polyglotAI-bot wants to merge 1 commit into
Conversation
Before each retry, Client#insert with an InputStream calls reset() on the stream, also when the failed attempt read no data, and never calls mark(). A stream with no valid mark (a BufferedInputStream with no mark, a FileInputStream) makes the insert fail with "Failed to reset stream before next attempt". After a retryable server error the client has already sent all of the data, so a mark must cover all of it. Document when the client retries (the default causes, including ServerRetryable, which the Timeouts & Retry table did not list; the maximum with more than one endpoint), what reset() does for each kind of stream, and three procedures: mark the stream, use a DataStreamWriter that opens the source again, or disable retries. Also fix the DataStreamWriter Javadoc: onOutput is called once for each request, not once for each operation. Add the behavior to the client-v2 compatibility traits in docs/features.md. Implements: #2675 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Auto-approved by the AI review gate on 2dcb030. Details in the approver's comment on this pull request.
AI review gate — auto-approved
History (latest 5 heads, newest first)
|
1 task
Client V2 CoverageCoverage Report
Class Coverage
|
JDBC V2 CoverageCoverage Report
Class Coverage
|
1 task
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.
Summary
Closes #2675
This PR documents how
Client#insertwith anInputStreamuses the stream for a retry. No code behavior changes.Before each retry, the client calls
reset()on the stream (viaDataStreamWriter#onRetry,Client.javastream insert overload). It does this also when the failed attempt read no data (connection refused), and it never callsmark(). ABufferedInputStreamwith no mark, or a stream for whichmarkSupported()isfalse, makes the insert fail withClientException: Failed to reset stream before next attempt.client.mdx, Insert API: new part "Retries and Input Streams" (#insert-stream-retries). It tells when the client retries, whatreset()does for each kind of stream, and three procedures: mark the stream, use aDataStreamWriterthat opens the source again, or disable retries (per insert or per client).client.mdx, Timeouts & Retry table: the default ofclient_retry_on_failuresnow includesServerRetryable(the code default since Polish excpetion api + build in code list that is retryable #2453).setMaxRetriestells the rule with more than one endpoint: the maximum ismax(retry, endpoints - 1), sosetMaxRetries(0)does not disable the failover retry.InputStreamoverloads ofClient#insert, andDataStreamWriter.onOutputis called once for each request, not once for each operation.docs/features.md: one client-v2 compatibility trait for this behavior.Test
No tests: no code behavior changes. A scratch program (not in the PR) checked each statement against ClickHouse 26.10.4:
READONLY, 164), the client had read all 35 MB of the stream beforereset(). Thusmark(1 MiB)failed andmark(Integer.MAX_VALUE)worked.[refused, good],setMaxRetries(0)still retried once and calledreset().retryOnFailures(ClientFaultCause.None)and the per-insertclient_retry_on_failuresoption did not call it.DataStreamWritergot 4onOutputcalls for 4 attempts after server errors.mvn -pl client-v2 compile javadoc:javadoc: no new warning.Checklist
reset()can fail on retries for BufferedInputStreams #2675docs/clickhouse-docspages in this repo sync to clickhouse-docs)docs/changes_checklist.md: no section applies (Javadoc and docs only). Nohistory/latest/entry: docs-only PRs in this repo do not add one.🤖 Generated with Claude Code
Note
Low Risk
Javadoc and user-facing documentation only; no changes to insert or retry implementation.
Overview
Documentation-only change clarifying how
Client#insertwithInputStreamorDataStreamWriterinteracts with the client’s retry logic (no runtime behavior changes).Javadoc on the
InputStreaminsert overloads andDataStreamWriternow states that each retry callsInputStream#reset()(the app must set a mark; failures becomeClientException) and thatonOutput/onRetryrun once per HTTP attempt. The client guide adds a Retries and Input Streams section with stream-type guidance, workarounds (ByteArrayInputStream,mark,DataStreamWriter, disabling retries viaClientFaultCause.None), and corrects the documented default forretryOnFailuresto includeServerRetryableplus multi-endpointsetMaxRetriesbehavior.features.mdrecords insert retries as a client-v2 compatibility trait.Reviewed by Cursor Bugbot for commit 2dcb030. Bugbot is set up for automated code reviews on this repo. Configure here.