[client] Thrown exception if Server type mismatch.#2606
Open
loserwang1024 wants to merge 1 commit intoapache:mainfrom
Open
[client] Thrown exception if Server type mismatch.#2606loserwang1024 wants to merge 1 commit intoapache:mainfrom
loserwang1024 wants to merge 1 commit intoapache:mainfrom
Conversation
403c90f to
b3d6ad6
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses client-side “stuck” behavior when requests are routed to the wrong server type (e.g., coordinator vs tablet server after restarts/IP swaps) by adding a server-type check during API version negotiation and surfacing the mismatch as a metadata-related exception so clients can recover.
Changes:
- Add
server_typetoApiVersionsResponseand populate it on the server/test gateways. - Validate server type on the client during API_VERSIONS handshake and close the connection with an
InvalidServerTypeExceptionon mismatch. - Refresh physical-table metadata during writer-id initialization retries when the failure is an
InvalidMetadataException.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java | Sets server_type in API_VERSIONS responses emitted by servers. |
| fluss-rpc/src/main/proto/FlussApi.proto | Extends ApiVersionsResponse with optional int32 server_type. |
| fluss-rpc/src/main/java/org/apache/fluss/rpc/netty/client/ServerConnection.java | Adds server-type validation on API_VERSIONS response and closes with InvalidServerTypeException on mismatch. |
| fluss-common/src/main/java/org/apache/fluss/exception/InvalidServerTypeException.java | Introduces a new exception type (extends InvalidMetadataException) to trigger metadata refresh/retry behavior. |
| fluss-common/src/main/java/org/apache/fluss/cluster/ServerType.java | Adds ServerType.forId(int) to decode server_type. |
| fluss-rpc/src/test/java/org/apache/fluss/rpc/netty/client/ServerConnectionTest.java | Adds coverage for wrong-server-type connection behavior. |
| fluss-rpc/src/test/java/org/apache/fluss/rpc/netty/authenticate/AuthenticationTest.java | Updates test ServerNode types to match new server-type handshake behavior. |
| fluss-rpc/src/test/java/org/apache/fluss/rpc/TestingTabletGatewayService.java | Makes test tablet gateway report TABLET_SERVER provider type. |
| fluss-rpc/src/test/java/org/apache/fluss/rpc/TestingGatewayService.java | Adds server_type to API_VERSIONS responses for test gateway service. |
| fluss-client/src/main/java/org/apache/fluss/client/write/WriterClient.java | Wires MetadataUpdater into IdempotenceManager construction. |
| fluss-client/src/main/java/org/apache/fluss/client/write/IdempotenceManager.java | Refreshes metadata on InvalidMetadataException during writer-id init retries. |
| fluss-client/src/test/java/org/apache/fluss/client/write/SenderTest.java | Updates IdempotenceManager construction to include MetadataUpdater. |
| fluss-client/src/test/java/org/apache/fluss/client/write/RecordAccumulatorTest.java | Updates IdempotenceManager construction for new signature (passes null updater). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fluss-rpc/src/main/java/org/apache/fluss/rpc/netty/client/ServerConnection.java
Outdated
Show resolved
Hide resolved
fluss-client/src/main/java/org/apache/fluss/client/write/IdempotenceManager.java
Show resolved
Hide resolved
fluss-client/src/main/java/org/apache/fluss/client/write/IdempotenceManager.java
Show resolved
Hide resolved
fluss-server/src/main/java/org/apache/fluss/server/RpcServiceBase.java
Outdated
Show resolved
Hide resolved
fluss-common/src/main/java/org/apache/fluss/cluster/ServerType.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/main/java/org/apache/fluss/rpc/netty/client/ServerConnection.java
Outdated
Show resolved
Hide resolved
fluss-rpc/src/test/java/org/apache/fluss/rpc/netty/client/ServerConnectionTest.java
Show resolved
Hide resolved
fluss-common/src/main/java/org/apache/fluss/exception/InvalidServerTypeException.java
Outdated
Show resolved
Hide resolved
b3d6ad6 to
cb06849
Compare
Contributor
Author
|
@wuchong @swuferhong , CC |
cb06849 to
366c954
Compare
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.
Purpose
Linked issue: close #2604
Brief change log
Tests
API and Format
Documentation