kunwp1 opened a new pull request, #9348:
URL: https://github.com/apache/texera/pull/9348
### What changes were proposed in this PR?
`LakeFSFileDocument` opened presigned URLs with `new URL(url).openStream()`.
When a proxy closes the connection before the declared `Content-Length` (for
example, the gateway's 15s request timeout on a multi-GB download),
`HttpURLConnection` reports an ordinary end of stream. So `asInputStream()`
callers got a short body with no error, and `asFile()` saved it as the file.
The failure then surfaced later as a format error such as Arrow's `missing
Magic number`, with different bytes on every attempt.
This PR:
- Opens presigned URLs through a small `LengthCheckedInputStream`. When the
stream ends short of the declared length, it throws an `IOException` that names
the file and both byte counts. Streams without a declared length pass through
unchanged.
- Uses it on both paths that open a presigned URL (with and without a user
JWT).
- Makes `asFile()` delete its temp file when the copy does not finish, and
close its streams in `finally`, so a failed download no longer leaves a partial
file on disk.
The truncation surfaces during the read, after `asInputStream()` has
returned, so it does not trigger the LakeFS fallback. The caller gets the error.
### Any related issues, documentation, discussions?
Closes #9347
The gateway-side cause (no request timeout on the RustFS route) is fixed
separately in a companion PR.
### How was this PR tested?
Added two cases to `LakeFSFileDocumentSpec`, driven by a new `truncating`
mode in its loopback stub. The mode declares the full `Content-Length`, sends
half the body, and closes:
- `asInputStream` fails the read with an `IOException`, instead of ending it
early.
- `asFile` throws, leaves no `versionedFile*` temp file behind, and a later
read of the same file succeeds in full.
Both fail on `main` ("Expected exception java.io.IOException to be thrown,
but no exception was thrown") and pass with this change.
```
sbt "WorkflowCore/testOnly
org.apache.texera.amber.core.storage.DocumentFactorySpec
org.apache.texera.amber.core.storage.model.*"
# Tests: succeeded 63, failed 0
sbt "scalafixAll --check" scalafmtCheckAll # clean
```
We also confirmed it against a real deployment, where a 1.3 GB `.arrow`
dataset failed intermittently with `missing Magic number`. With the gateway
timeout still in place, the same read now fails with a message saying the
download was cut off.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]