laskoviymishka commented on code in PR #2553:
URL: https://github.com/apache/iceberg-go/pull/2553#discussion_r4556877560
##########
catalog/rest/rest.go:
##########
@@ -634,13 +655,22 @@ func doPost[Payload, Result any](ctx context.Context,
baseURI *url.URL, path []s
if rsp.ContentLength == 0 {
if cfg.requireBody {
- return ret, fmt.Errorf("%w: empty response body on %s
%s", ErrRESTError, req.Method, req.URL.Path)
+ err = fmt.Errorf("%w: empty response body on %s %s",
ErrRESTError, req.Method, req.URL.Path)
+ if cfg.unknownCommitStateOnTransport {
+ err = fmt.Errorf("%w: %w",
ErrCommitStateUnknown, err)
+ }
+
+ return ret, err
}
return ret, err
}
if err = decodeJSONResponse(rsp.Body, &ret); err != nil {
Review Comment:
The 200-body branches are new behavior the release note promises: invalid or
trailing JSON on all three endpoints, an empty body on
`CommitTable`/`UpdateTable` via `requireBody`, and an empty 200 still returning
nil on `CommitTransaction`. The new tests all go through the hijacked
connection, though. Could we add a small table test that serves `{"metadata":`
and an empty 200 and asserts `ErrorIs(err, rest.ErrCommitStateUnknown)` (and
`NoError` for the empty-200 transaction)?
##########
catalog/rest/rest.go:
##########
@@ -615,8 +622,22 @@ func doPost[Payload, Result any](ctx context.Context,
baseURI *url.URL, path []s
return ret, err
}
+ // If the caller canceled before dispatch, nothing could have been
+ // committed. Cancellation after dispatch is still outcome-unknown.
+ if cfg.unknownCommitStateOnTransport {
+ if err := ctx.Err(); err != nil {
+ return ret, err
+ }
+ }
+
rsp, err = cl.Do(req)
if err != nil {
+ if cfg.unknownCommitStateOnTransport {
+ // A dial failure may follow an earlier attempt whose
response was
+ // lost when the HTTP transport retries the request.
+ return ret, fmt.Errorf("%w: %w", ErrCommitStateUnknown,
err)
Review Comment:
Should failures from inside `sessionTransport.RoundTrip` land here too? An
`AuthManager` error or a `SignRequest` error returns before anything is written
([L366-L380](https://github.com/apache/iceberg-go/blob/03f623331f3574b0c7c43fe656d10cbd289bef48/catalog/rest/rest.go#L366-L380)),
but `cl.Do` hands it back and we wrap it as unknown. A repro with an auth
manager that fails on the commit call gets `errors.Is(err,
ErrCommitStateUnknown) == true` with zero hits on the server. A first-attempt
connection refused behaves the same.
One way to keep the retry case and drop these: attach an
`httptrace.ClientTrace` and only wrap once `WroteRequest` has fired. The dial
failure in `TestCommitRetryDialFailureHasUnknownState` would still be unknown,
since the first attempt wrote. If the broad rule is intentional, a line in this
comment saying so would be enough.
--
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]