You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ta...@apache.org on 2024/01/18 12:25:20 UTC

(flink) 03/03: [hotfix] Add logs for ProfilingServiceTest

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

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

commit 4bee4e6e8ddb41ae9933d04bf21183223db6c2de
Author: Yu Chen <yu...@gmail.com>
AuthorDate: Fri Jan 12 18:15:31 2024 +0800

    [hotfix] Add logs for ProfilingServiceTest
---
 .../apache/flink/runtime/util/profiler/ProfilingService.java |  3 ++-
 .../flink/runtime/util/profiler/ProfilingServiceTest.java    | 12 ++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/util/profiler/ProfilingService.java b/flink-runtime/src/main/java/org/apache/flink/runtime/util/profiler/ProfilingService.java
index 5af2dfd6336..9f3c42cfa03 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/util/profiler/ProfilingService.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/util/profiler/ProfilingService.java
@@ -168,9 +168,10 @@ public class ProfilingService implements Closeable {
             if (!scheduledExecutor.isShutdown()) {
                 scheduledExecutor.shutdownNow();
             }
-            instance = null;
         } catch (Exception e) {
             LOG.error("Exception thrown during stopping profiling service. ", e);
+        } finally {
+            instance = null;
         }
     }
 
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/util/profiler/ProfilingServiceTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/util/profiler/ProfilingServiceTest.java
index d3487a1fbb8..cf07c91e63d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/util/profiler/ProfilingServiceTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/util/profiler/ProfilingServiceTest.java
@@ -113,7 +113,7 @@ public class ProfilingServiceTest extends TestLogger {
                     ProfilingInfo.ProfilingMode.ITIMER, DEFAULT_PROFILING_DURATION, true);
         }
         // Due to the configuration of MAX_PROFILING_HISTORY_SIZE=2,
-        // the profiling result directory should container no more than 2 files.
+        // the profiling result directory shouldn't contain more than 2 files.
         verifyRollingDeletionWorks();
     }
 
@@ -162,7 +162,15 @@ public class ProfilingServiceTest extends TestLogger {
         Set<String> resultFileNames = new HashSet<>();
         File configuredDir = new File(profilingService.getProfilingResultDir());
         for (File f : Objects.requireNonNull(configuredDir.listFiles())) {
-            resultFileNames.add(f.getName());
+            if (f.getName().startsWith(RESOURCE_ID)) {
+                resultFileNames.add(f.getName());
+            }
+        }
+        if (profilingList.size() != resultFileNames.size()) {
+            log.error(
+                    "Found unexpected profiling file size: profilingList={},resultFileNames={}",
+                    profilingList,
+                    resultFileNames);
         }
         Assertions.assertEquals(profilingList.size(), resultFileNames.size());
         for (ProfilingInfo profilingInfo : profilingList) {