This is an automated email from the ASF dual-hosted git repository.

alsuliman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 685603ab56 [ASTERIXDB-3500][STO] Fix streaming reads for Google Cloud 
Storage(GCS)
685603ab56 is described below

commit 685603ab56f4e1c3f2d048cdc54bdd29d5626aa3
Author: Mohammad Nawazish Khan <[email protected]>
AuthorDate: Fri Sep 6 23:41:28 2024 +0530

    [ASTERIXDB-3500][STO] Fix streaming reads for Google Cloud Storage(GCS)
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    
    The GCS client was prematurely closing the ReadChannel when streaming parts 
of
    the Object required to serve the query.
    
    Ext-ref: MB-63405
    
    Change-Id: I172f0044112777aec7200a0c6ae906751ffdc5f4
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18843
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Jenkins <[email protected]>
    Reviewed-by: Murtadha Hubail <[email protected]>
---
 .../asterix/cloud/clients/google/gcs/GCSCloudClient.java      | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git 
a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java
 
b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java
index a74e7d390b..62ca4ecf3f 100644
--- 
a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java
+++ 
b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java
@@ -43,6 +43,7 @@ import 
org.apache.asterix.cloud.clients.profiler.IRequestProfilerLimiter;
 import org.apache.asterix.cloud.clients.profiler.RequestLimiterNoOpProfiler;
 import org.apache.hyracks.api.exceptions.HyracksDataException;
 import org.apache.hyracks.api.io.FileReference;
+import org.apache.hyracks.api.util.CleanupUtils;
 import org.apache.hyracks.api.util.IoUtil;
 import org.apache.hyracks.control.nc.io.IOManager;
 
@@ -157,11 +158,13 @@ public class GCSCloudClient implements ICloudClient {
     public InputStream getObjectStream(String bucket, String path, long 
offset, long length) {
         guardian.checkReadAccess(bucket, path);
         profilerLimiter.objectGet();
-        try (ReadChannel reader = gcsClient.reader(bucket, config.getPrefix() 
+ path).limit(offset + length)) {
+        ReadChannel reader = null;
+        try {
+            reader = gcsClient.reader(bucket, config.getPrefix() + 
path).limit(offset + length);
             reader.seek(offset);
             return Channels.newInputStream(reader);
-        } catch (StorageException | IOException e) {
-            throw new IllegalStateException(e);
+        } catch (StorageException | IOException ex) {
+            throw new RuntimeException(CleanupUtils.close(reader, ex));
         }
     }
 
@@ -284,4 +287,4 @@ public class GCSCloudClient implements ICloudClient {
     private String stripCloudPrefix(String objectName) {
         return objectName.substring(config.getPrefix().length());
     }
-}
+}
\ No newline at end of file

Reply via email to