>From Murtadha Hubail <[email protected]>: Murtadha Hubail has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18843 )
Change subject: [ASTERIXDB-3500][STO] Fix streaming reads for Google Cloud Storage(GCS) ...................................................................... [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]> --- M asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java 1 file changed, 31 insertions(+), 4 deletions(-) Approvals: Murtadha Hubail: Looks good to me, approved Jenkins: Verified; Verified 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 a74e7d3..62ca4ec 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.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 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 @@ private String stripCloudPrefix(String objectName) { return objectName.substring(config.getPrefix().length()); } -} +} \ No newline at end of file -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18843 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Change-Id: I172f0044112777aec7200a0c6ae906751ffdc5f4 Gerrit-Change-Number: 18843 Gerrit-PatchSet: 5 Gerrit-Owner: Mohammad Nawazish Khan <[email protected]> Gerrit-Reviewer: Anon. E. Moose #1000171 Gerrit-Reviewer: Hussain Towaileb <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Murtadha Hubail <[email protected]> Gerrit-MessageType: merged
