Repository navigation
[client] Back off writes rejected by disk protection #4533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a0f8439
[client] Back off writes rejected by disk protection
fhan688 99e067b
fix(client): invalidate metadata before re-enqueuing write retries
fhan688 f5f3ee7
fix(client): wake sender when KV pressure shortens throttle deadline
fhan688 ac91ce5
fix(client): back off retriable writes per bucket
fhan688 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
291 changes: 180 additions & 111 deletions
291
fluss-client/src/main/java/org/apache/fluss/client/write/RecordAccumulator.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MEDIUM: Retryable invalid-metadata write responses now rebuild the Cluster snapshot once per failing bucket (up to once per bucket in the response) instead of once per response.
handleProduceLogResponse/handlePutKvResponse iterate every bucket response and call handleWriteBatchException per bucket, and the changed code invalidates the RPC target inline via metadataUpdater.invalidPhysicalTableBucketMeta(Collections.singleton(writeTargetPath)) instead of accumulating writeTargetPath into invalidMetadataTablesSet for the single post-loop call; the set that handleWriteBatchException now returns is empty on this path, so the trailing aggregated invalidate is a no-op. Each invalidate rebuilds a Cluster by copying availableLocationsByPath (new HashMap plus a defensive ArrayList copy per retained path), bucketCountByTableOrPartition, tableIdByPath, partitionsIdByPath and aliveTabletServersById, so an N-bucket invalid-metadata response costs N O(cluster-metadata) rebuilds where the base cost one. The invalidate-before-retry ordering is required, but per-bucket fan-out is not: the union of paths could still be invalidated once before the batches are re-enqueued.
Failure scenario: A ProduceLog/PutKv response to a node rejects M buckets with a retryable InvalidMetadataException (e.g. NOT_LEADER_OR_FOLLOWER after a leader change). Precondition: the cluster snapshot holds B bucket locations. Operation: the per-bucket loop calls handleWriteBatchException M times, each calling invalidPhysicalTableBucketMeta(Collections.singleton(path)); every call rebuilds a cluster of O(B) entries. Actual result: M full Cluster rebuilds instead of 1, all on the sender/RPC callback thread. Violated contract: the base per-response invalidation cost contract; response handling becomes O(M*B) allocations and cluster-map copies under a metadata storm.
Suggested fix: Collect writeTargetPath into a per-response Set inside handleWriteBatchException (or return it as before) and perform one metadataUpdater.invalidPhysicalTableBucketMeta(set) after the response loop and before the batches are re-enqueued, preserving the invalidate-before-retry ordering while restoring one Cluster rebuild per response.
Confidence: 90/100