You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fluss.apache.org by "platinumhamburg (via GitHub)" <gi...@apache.org> on 2026/08/17 09:22:57 UTC

[PR] [client] Scope sender failures to per-table requests [fluss]

platinumhamburg opened a new pull request, #4017:
URL: https://github.com/apache/fluss/pull/4017

   <!--
   *Thank you very much for contributing to Fluss - we are happy that you want to help us improve Fluss. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GitHub issue](https://github.com/apache/fluss/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no issue.
   
     - Name the pull request in the format "[component] Title of the pull request", where *[component]* should be replaced by the name of the component being changed. Typically, this corresponds to the component label assigned to the issue (e.g., [kv], [log], [client], [flink], [rust], [python], [c++], [elixir]). Skip *[component]* if you are unsure about which is the best component.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
   
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes.
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
   
     - **Generative AI disclosure:** Indicate whether generative AI tools were used in authoring this PR. If yes, specify the tool below.
       - [ ] No generative AI tools used
       - [ ] Yes (please specify the tool below)
   
   **(The sections below can be removed for hotfixes or typos)**
   -->
   
   <!--
   Generated-by: [Tool Name and Version] following [the guidelines](https://github.com/apache/fluss/blob/main/AGENTS.md)
   -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Linked issue: close #3772
   
   <!-- What is the purpose of the change -->
   
   ### Brief change log
   
   <!-- Please describe the changes made in this pull request and explain how they address the issue -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [client] Scope sender failures to per-table requests [fluss]

Posted by "platinumhamburg (via GitHub)" <gi...@apache.org>.
platinumhamburg merged PR #4017:
URL: https://github.com/apache/fluss/pull/4017


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [client] Scope sender failures to per-table requests [fluss]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4017:
URL: https://github.com/apache/fluss/pull/4017#discussion_r3795404474


##########
fluss-client/src/main/java/org/apache/fluss/client/write/Sender.java:
##########
@@ -453,15 +451,17 @@ private void sendPutKvRequestAndHandleResponse(
             TabletServerGateway gateway,
             PutKvRequest request,
             long tableId,
-            Map<TableBucket, ReadyWriteBatch> recordsByBucket) {
+            List<ReadyWriteBatch> writeBatches) {
+        Map<TableBucket, ReadyWriteBatch> recordsByBucket = new HashMap<>();
+        writeBatches.forEach(batch -> recordsByBucket.put(batch.tableBucket(), batch));

Review Comment:
   The same `recordsByBucket` construction is duplicated in both `sendProduceLogRequestAndHandleResponse` and `sendPutKvRequestAndHandleResponse`. Consider extracting a small helper (or building/passing the map once where the request is created) to avoid divergence between the two paths and simplify future changes.



##########
fluss-client/src/main/java/org/apache/fluss/client/write/Sender.java:
##########
@@ -433,15 +429,17 @@ private void sendProduceLogRequestAndHandleResponse(
             TabletServerGateway gateway,
             ProduceLogRequest request,
             long tableId,
-            Map<TableBucket, ReadyWriteBatch> recordsByBucket) {
+            List<ReadyWriteBatch> writeBatches) {
+        Map<TableBucket, ReadyWriteBatch> recordsByBucket = new HashMap<>();
+        writeBatches.forEach(batch -> recordsByBucket.put(batch.tableBucket(), batch));

Review Comment:
   The same `recordsByBucket` construction is duplicated in both `sendProduceLogRequestAndHandleResponse` and `sendPutKvRequestAndHandleResponse`. Consider extracting a small helper (or building/passing the map once where the request is created) to avoid divergence between the two paths and simplify future changes.



##########
fluss-client/src/test/java/org/apache/fluss/client/write/SenderTest.java:
##########
@@ -1057,6 +1193,44 @@ private int pendingRequestSize(TableBucket tb) {
         return gateway.pendingRequestSize();
     }
 
+    private int findRequestIndex(TableBucket referenceBucket, long tableId) {
+        int requestCount = pendingRequestSize(referenceBucket);
+        for (int index = 0; index < requestCount; index++) {
+            if (getWriteRequestTableId(getRequest(referenceBucket, index)) == tableId) {
+                return index;
+            }
+        }
+        throw new IllegalStateException("No pending write request for table " + tableId);
+    }
+
+    private List<Long> pendingWriteRequestTableIds(TableBucket referenceBucket) {
+        List<Long> tableIds = new ArrayList<>();
+        int requestCount = pendingRequestSize(referenceBucket);
+        for (int index = 0; index < requestCount; index++) {
+            tableIds.add(getWriteRequestTableId(getRequest(referenceBucket, index)));
+        }
+        return tableIds;
+    }
+
+    private static long getWriteRequestTableId(ApiMessage request) {
+        if (request instanceof ProduceLogRequest) {
+            return ((ProduceLogRequest) request).getTableId();
+        }
+        if (request instanceof PutKvRequest) {
+            return ((PutKvRequest) request).getTableId();
+        }
+        throw new IllegalArgumentException(
+                "Expected a write request but found " + request.getClass().getName());
+    }
+
+    private void failRequest(TableBucket referenceBucket, int index, Throwable throwable) {
+        TestTabletServerGateway gateway =
+                (TestTabletServerGateway)
+                        metadataUpdater.newTabletServerClientForNode(
+                                metadataUpdater.leaderFor(DATA1_TABLE_PATH, referenceBucket));
+        gateway.failRequest(index, throwable);
+    }

Review Comment:
   `failRequest` hardcodes `DATA1_TABLE_PATH` when resolving the leader node, even though it is used to fail requests for potentially different tables (the new tests mix table IDs). This can make the tests incorrect if tables are routed to different leaders. Prefer resolving the gateway using the failing request’s actual `TablePath` (e.g., pass `TablePath`/`TableInfo` into `failRequest`), or resolve the destination node directly from the request being failed.



##########
fluss-client/src/test/java/org/apache/fluss/client/write/SenderTest.java:
##########
@@ -998,6 +1116,14 @@ private TestingMetadataUpdater initializeMetadataUpdater() {
         return new TestingMetadataUpdater(tableInfos);
     }
 
+    private void addTableToMetadata(TableInfo tableInfo) {
+        Map<TablePath, TableInfo> tableInfos = new HashMap<>();
+        tableInfos.put(DATA1_TABLE_PATH, DATA1_TABLE_INFO);
+        tableInfos.put(DATA1_TABLE_PATH_PK, DATA1_TABLE_INFO_PK);
+        tableInfos.put(tableInfo.getTablePath(), tableInfo);
+        metadataUpdater.updateTableInfos(tableInfos);
+    }

Review Comment:
   `addTableToMetadata` suggests an additive update, but it actually replaces the metadata map with a newly constructed one (keeping only two baseline tables plus the new one). Either rename this to reflect replacement semantics (e.g., `setTableInfosForTest`) or implement it as a true 'add' by merging into the existing table info set before calling `updateTableInfos`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@fluss.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org