From e865c852c0e9a1e9b55b9d1512d379072d3e7a7b Mon Sep 17 00:00:00 2001 From: szucsvillo <81696283+szucsvillo@users.noreply.github.com> Date: Tue, 11 Jun 2024 23:03:33 +0200 Subject: [PATCH] HBASE-28652 Backport HBASE-21785 master reports open regions as RITs and also messes up rit age metric (#5978) Signed-off-by: Duo Zhang Signed-off-by: Andrew Purtell Co-authored-by: Sergey Shelukhin --- .../hbase/master/MetricsAssignmentManagerSourceImpl.java | 4 ++-- .../hadoop/hbase/master/assignment/AssignmentManager.java | 8 +++++++- .../hadoop/hbase/master/assignment/RegionStateNode.java | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java index 5512e906b67a..819445bd5861 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java @@ -117,8 +117,8 @@ public void setRITCountOverThreshold(final int ritCount) { } @Override - public void setRITOldestAge(final long ritCount) { - ritOldestAgeGauge.set(ritCount); + public void setRITOldestAge(final long ritOldestAge) { + ritOldestAgeGauge.set(ritOldestAge); } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java index a46f220f6db0..5e06e5a48205 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java @@ -1666,7 +1666,13 @@ protected void update(final AssignmentManager am) { private void update(final Collection regions, final long currentTime) { for (RegionState state : regions) { totalRITs++; - final long ritTime = currentTime - state.getStamp(); + final long ritStartedMs = state.getStamp(); + if (ritStartedMs == 0) { + // Don't output bogus values to metrics if they accidentally make it here. + LOG.warn("The RIT {} has no start time", state.getRegion()); + continue; + } + final long ritTime = currentTime - ritStartedMs; if (ritTime > ritThreshold) { if (ritsOverThreshold == null) { ritsOverThreshold = new HashMap(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java index 2c61d3d427b5..91c0222facd1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java @@ -178,7 +178,11 @@ public boolean isSplit() { public long getLastUpdate() { TransitRegionStateProcedure proc = this.procedure; - return proc != null ? proc.getLastUpdate() : lastUpdate; + if (proc != null) { + long lastUpdate = proc.getLastUpdate(); + return lastUpdate != 0 ? lastUpdate : proc.getSubmittedTime(); + } + return lastUpdate; } public void setLastHost(final ServerName serverName) {