From 2369f0cddbb5e2ce20882d819760a58deeb13583 Mon Sep 17 00:00:00 2001 From: LiuGuH <444506464@qq.com> Date: Fri, 5 Jan 2024 18:36:28 +0800 Subject: [PATCH] HDFS-17309. RBF: Fix Router Safemode check condition error (#6390) Contributed by liuguanghua. Reviewed-by: Inigo Goiri Reviewed-by: Simbarashe Dzinamarira Signed-off-by: Shilun Fan --- .../hdfs/server/federation/router/RouterSafemodeService.java | 2 +- .../hadoop/hdfs/server/federation/store/StateStoreService.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterSafemodeService.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterSafemodeService.java index 35ed854065..c50f6dc469 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterSafemodeService.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterSafemodeService.java @@ -169,7 +169,7 @@ public void periodicInvoke() { } StateStoreService stateStore = router.getStateStore(); long cacheUpdateTime = stateStore.getCacheUpdateTime(); - boolean isCacheStale = (now - cacheUpdateTime) > this.staleInterval; + boolean isCacheStale = (cacheUpdateTime == 0) || (now - cacheUpdateTime) > this.staleInterval; // Always update to indicate our cache was updated if (isCacheStale) { diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/StateStoreService.java b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/StateStoreService.java index 74997e86be..b198d969bb 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/StateStoreService.java +++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/store/StateStoreService.java @@ -132,6 +132,8 @@ public StateStoreService() { // Caches to maintain this.cachesToUpdateInternal = new ArrayList<>(); this.cachesToUpdateExternal = new ArrayList<>(); + + this.cacheLastUpdateTime = 0; } /**