timothyw553 commented on code in PR #18903:
URL: https://github.com/apache/iceberg/pull/18903#discussion_r4724844806


##########
core/src/main/java/org/apache/iceberg/rest/RESTTableOperations.java:
##########
@@ -240,6 +252,38 @@ public void commit(TableMetadata base, TableMetadata 
metadata) {
     updateCurrentMetadata(response);
   }
 
+  /**
+   * Sends a commit request, reporting a transport failure as an unknown 
commit state.
+   *
+   * <p>If the connection fails once the request may have been sent (no 
response, a reset, a read
+   * timeout), the server may have applied the commit, so the outcome is 
unknown just as for a 5xx
+   * response. Failures that happen before anything is sent stay ordinary 
failures. Any other
+   * transport failure is treated as unknown: reporting a commit that was 
applied as failed invites
+   * a retry that applies it twice, while reporting one that wasn't as unknown 
at worst leaves
+   * orphan files.
+   */
+  static <T> T commitRequest(Supplier<T> request) {
+    try {
+      return request.get();
+    } catch (RESTException e) {
+      if (e.getCause() instanceof IOException && 
!failedBeforeSending(e.getCause())) {

Review Comment:
   doesn't this only inspect the last http attempt? if a keyed post reaches the 
server, loses the response, and then fails to connect on an automatic retry, 
the final connection error makes `failedBeforeSending` return true and throws 
`RESTException` instead of `CommitStateUnknownException`. could we track 
attempt history on the request's `HttpContext` and pass it from `HTTPClient` 
(or drop `!failedBeforeSending` as a fallback), and add a real `HTTPClient` 
test for a lost keyed-post reply followed by connection refusal?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to