kunwp1 opened a new issue, #9347:
URL: https://github.com/apache/texera/issues/9347

   ### What happened?
   
   Reading a large dataset file (≈1.3 GB `.arrow`) through a scan operator 
fails intermittently with a format error, not a download error:
   
   ```
   java.lang.RuntimeException: Failed to read the .arrow file. Please ensure it 
is a valid Arrow file.
   Caused by: org.apache.arrow.vector.ipc.InvalidArrowFileException: missing 
Magic number [43, 52, 10, -3, 105, 107, -78, 114, -32, 42]
   ```
   
   The bytes in the "magic number" change on every attempt, and a retry 
sometimes succeeds. The file is fine: the reader is being handed a **truncated 
copy** of it. On the affected computing units, `/tmp/versionedFile*.tmp` held 
several complete copies (1,313,583,050 bytes) alongside partial ones (438 MB, 
667 MB, 780 MB).
   
   There are two problems, and together they produce this:
   
   1. **The RustFS gateway route has no request timeout set**, so Envoy Gateway 
applies its 15s default (`bin/k8s/templates/base/gateway/gateway-routes.yaml`, 
`texera-rustfs-route`). When presigned URLs point at the gateway hostname, any 
download still running after 15s is cut off mid-body. A single uncontended 1.3 
GB download takes about 4s and passes. It fails when the reader is slow: a 
small JVM heap, GC pauses, or several compiles downloading at once.
   2. **`LakeFSFileDocument` accepts the cut-off body as the whole file.** It 
opens presigned URLs with `new URL(url).openStream()`. `HttpURLConnection` 
reports a connection closed before `Content-Length` as an ordinary end of 
stream (`read` returns -1, no exception). `asFile()` then saves the partial 
bytes as the file, and the error only surfaces later as a misleading format 
error. A failed copy also leaves its temp file behind.
   
   Expected: the download either completes, or fails with an error that says it 
was cut off.
   
   ### How to reproduce?
   
   **Gateway timeout:** with presigned URLs routed through the gateway, 
download a multi-GB object from inside the cluster at a limited rate:
   
   ```
   curl -s --limit-rate 20M -o /dev/null -w "http=%{http_code} 
bytes=%{size_download} secs=%{time_total}\n" "<presigned url>"
   # http=200 bytes=324435968 secs=15.2   (curl exit 18: partial transfer)
   ```
   
   The connection is cut at exactly 15s. With `timeouts.request: "0s"` on the 
route, the same command downloads all 1,313,583,050 bytes in about 62s.
   
   **Silent truncation in Java:** read the same URL with `new 
URL(url).openStream()` and a slow consumer. The read loop ends normally at 
about 356 MB with no exception. In a unit test, an `HttpServer` stub that 
declares a `Content-Length` and closes after sending half the body shows the 
same behavior through `LakeFSFileDocument.asInputStream()` and `asFile()`.
   
   ### Version/Branch
   
   1.4.0-incubating-SNAPSHOT (main)
   
   ### Commit Hash (Optional)
   
   bb6136d
   
   ### Relevant log output
   
   ```
   java.lang.RuntimeException: Failed to read the .arrow file. Please ensure it 
is a valid Arrow file.
        at 
org.apache.texera.amber.operator.source.scan.arrow.ArrowSourceOpDesc$$anonfun$inferSchema$4.applyOrElse(ArrowSourceOpDesc.scala:102)
        at 
org.apache.texera.amber.operator.source.scan.arrow.ArrowSourceOpDesc.inferSchema(ArrowSourceOpDesc.scala:97)
   Caused by: org.apache.arrow.vector.ipc.InvalidArrowFileException: missing 
Magic number [69, 29, -72, 1, 90, -72, 83, -21, -23, -49]
        at 
org.apache.arrow.vector.ipc.ArrowFileReader.readSchema(ArrowFileReader.java:97)
   ```
   


-- 
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]

Reply via email to