WencongLiu commented on code in PR #23100:
URL: https://github.com/apache/flink/pull/23100#discussion_r1283977912
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -236,15 +254,24 @@ private boolean checkSegmentExist(
partitionId,
subpartitionId.getSubpartitionId(),
segmentId);
- boolean isExist;
+ boolean isExist = false;
try {
isExist = remoteFileSystem.exists(segmentPath);
- } catch (IOException e) {
- throw new RuntimeException("Failed to check segment file. " +
segmentPath, e);
+ currentRetryTime = 0;
+ } catch (Throwable t) {
+ currentRetryTime++;
+ throwException(t, "Failed to check the status of segment file.");
}
return isExist;
}
+ private void throwException(Throwable t, String logMessage) {
+ LOG.error(logMessage);
Review Comment:
`LOG.error` has been modified to `LOG.warn`
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -236,15 +254,24 @@ private boolean checkSegmentExist(
partitionId,
subpartitionId.getSubpartitionId(),
segmentId);
- boolean isExist;
+ boolean isExist = false;
try {
isExist = remoteFileSystem.exists(segmentPath);
- } catch (IOException e) {
- throw new RuntimeException("Failed to check segment file. " +
segmentPath, e);
+ currentRetryTime = 0;
+ } catch (Throwable t) {
+ currentRetryTime++;
+ throwException(t, "Failed to check the status of segment file.");
Review Comment:
`throwException ` can be modified to `tryThrowException`
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -236,15 +254,24 @@ private boolean checkSegmentExist(
partitionId,
subpartitionId.getSubpartitionId(),
segmentId);
- boolean isExist;
+ boolean isExist = false;
try {
isExist = remoteFileSystem.exists(segmentPath);
- } catch (IOException e) {
- throw new RuntimeException("Failed to check segment file. " +
segmentPath, e);
+ currentRetryTime = 0;
+ } catch (Throwable t) {
Review Comment:
The type of exceptions is various when the code `remoteFileSystem.exists` is
execute because the `remoteFileSystem` can be implemented by OSS, S3, etc. I
think using `Throwable` is also acceptable because there is a `MAX_RETRY_TIME`.
WDYT? 🤔
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -236,15 +254,24 @@ private boolean checkSegmentExist(
partitionId,
subpartitionId.getSubpartitionId(),
segmentId);
- boolean isExist;
+ boolean isExist = false;
try {
isExist = remoteFileSystem.exists(segmentPath);
- } catch (IOException e) {
- throw new RuntimeException("Failed to check segment file. " +
segmentPath, e);
+ currentRetryTime = 0;
+ } catch (Throwable t) {
Review Comment:
The type of exceptions is various when the code `remoteFileSystem.exists` is
execute because the `remoteFileSystem` can be implemented by OSS, S3, etc. I
think using `Throwable` is also acceptable because there is a `MAX_RETRY_TIME`.
WDYT? 🤔
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -207,20 +222,23 @@ private void scanMaxSegmentId(
Path segmentFinishDir =
getSegmentFinishDirPath(
baseRemoteStoragePath, partitionId,
subpartitionId.getSubpartitionId());
- FileStatus[] fileStatuses;
+ FileStatus[] fileStatuses = new FileStatus[0];
try {
if (!remoteFileSystem.exists(segmentFinishDir)) {
return;
}
fileStatuses = remoteFileSystem.listStatus(segmentFinishDir);
- } catch (IOException e) {
- throw new RuntimeException(
- "Failed to list the segment finish file. " +
segmentFinishDir, e);
+ currentRetryTime = 0;
+ } catch (Throwable t) {
+ if (t instanceof java.io.FileNotFoundException) {
+ return;
+ }
+ currentRetryTime++;
+ throwException(t, "Failed to list the segment finish file.");
}
- if (fileStatuses.length == 0) {
+ if (fileStatuses.length != 1) {
Review Comment:
This behavior depends on the types of various FileSystem.
There is one situation, for example, the FileSystem first create a new file
and delete the old file.
For another FileSystem, the behavior may be different.
Anyway, I think `if (fileStatuses.length != 1)` can cover all cases.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -109,7 +118,11 @@ private FileSystem createFileSystem() {
/** Start the executor. */
public void start() {
- scannerExecutor.schedule(this, lastInterval, TimeUnit.MILLISECONDS);
+ synchronized (scannerExecutor) {
Review Comment:
The volatile variable cannot promise sync operations. Therefore, volatile
variable cannot prevent the thread in the thread pool submitting task when the
pool is destroyed.
##########
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/partition/hybrid/tiered/tier/remote/RemoteStorageScanner.java:
##########
@@ -144,7 +157,9 @@ public void watchSegment(
/** Close the executor. */
public void close() {
- scannerExecutor.shutdownNow();
+ synchronized (scannerExecutor) {
+ scannerExecutor.shutdownNow();
Review Comment:
Done. I have added `scannerExecutor .awaitTermination`.
--
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]