spuru9 commented on code in PR #27969:
URL: https://github.com/apache/flink/pull/27969#discussion_r3174856621
##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -152,11 +156,16 @@ private RefCountedFile
downloadToCacheFile(FileStateHandle fileHandle) {
private FileInputStream openAndSeek(RefCountedFile refCountedFile, long
offset)
throws IOException {
FileInputStream fin = new FileInputStream(refCountedFile.getFile());
- if (offset != 0) {
- LOG.trace("seek to {}", offset);
- fin.getChannel().position(offset);
+ try {
+ if (offset != 0) {
+ LOG.trace("seek to {}", offset);
+ fin.getChannel().position(offset);
+ }
+ return fin;
+ } catch (Exception e) {
Review Comment:
nit: narrow catch (Exception) to catch (IOException)
##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -152,11 +156,16 @@ private RefCountedFile
downloadToCacheFile(FileStateHandle fileHandle) {
private FileInputStream openAndSeek(RefCountedFile refCountedFile, long
offset)
throws IOException {
FileInputStream fin = new FileInputStream(refCountedFile.getFile());
- if (offset != 0) {
- LOG.trace("seek to {}", offset);
- fin.getChannel().position(offset);
+ try {
+ if (offset != 0) {
+ LOG.trace("seek to {}", offset);
+ fin.getChannel().position(offset);
+ }
+ return fin;
+ } catch (Exception e) {
+ IOUtils.closeQuietly(fin);
+ throw e;
Review Comment:
nit: if the inner openAndSeek throws, we never release the retain from
getRefCountedFile — cache entry gets stuck above NO_USING_REF_COUNT and never
cleaned. Can release in a catch in the calling function. refer to the function
wrapStream finally block.
##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -144,6 +144,10 @@ private RefCountedFile downloadToCacheFile(FileStateHandle
fileHandle) {
return new RefCountedFile(file);
} catch (IOException e) {
+ LOG.warn("Failed to download cache file. Deleting partially
downloaded file {}", file.getPath(), e);
+ if (!file.delete()) {
Review Comment:
nit: Files.deleteIfExists() is already used in the file. Can use the same
pattern.
##########
flink-dstl/flink-dstl-dfs/src/main/java/org/apache/flink/changelog/fs/ChangelogStreamHandleReaderWithCache.java:
##########
@@ -144,6 +144,10 @@ private RefCountedFile downloadToCacheFile(FileStateHandle
fileHandle) {
return new RefCountedFile(file);
} catch (IOException e) {
+ LOG.warn("Failed to download cache file. Deleting partially
downloaded file {}", file.getPath(), e);
Review Comment:
can remove e, would produce redundant stack-trace logging before
ExceptionUtils.rethrow.
--
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]