This is an automated email from the ASF dual-hosted git repository.
keith-turner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push:
new 1b3fb1a3ae improved logging and metrics for compactions (#6653)
1b3fb1a3ae is described below
commit 1b3fb1a3ae842502a11b56c14bfd31f7c3028aed
Author: Keith Turner <[email protected]>
AuthorDate: Tue Nov 17 10:12:56 2026 -0500
improved logging and metrics for compactions (#6653)
Bad compaction config could cause logging on the tablet servers running
filtering iterators on behalf of the manager. However, no logging would
occur on the manager. Updated the filtering iterator the manager uses to
propogate info back to the manager such that it will log compaction
config errors and also update tablet error metrics.
Also updated the tablet error metric gauge to update at the end of each
full metadata scan. It used to increment for each error seen, so the
gauge would forever grow. The new behavior is more useful as someone can
know how many tablets in the system currently have errors. Also this
behavior matches the log recovery guage metric.
---
.../org/apache/accumulo/core/metrics/Metric.java | 12 ++--
.../server/compaction/CompactionJobGenerator.java | 39 +++++++++----
.../compaction/ProvisionalCompactionPlanner.java | 67 ----------------------
.../manager/state/TabletManagementIterator.java | 6 +-
.../accumulo/manager/TabletGroupWatcher.java | 25 ++++----
5 files changed, 55 insertions(+), 94 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/metrics/Metric.java
b/core/src/main/java/org/apache/accumulo/core/metrics/Metric.java
index 17946dc1d9..c94f115321 100644
--- a/core/src/main/java/org/apache/accumulo/core/metrics/Metric.java
+++ b/core/src/main/java/org/apache/accumulo/core/metrics/Metric.java
@@ -375,22 +375,22 @@ public enum Metric {
MetricDocSection.MANAGER, "Balancer Migrations Needed", null, NUMBER),
MANAGER_ROOT_TGW_ERRORS("accumulo.tabletmgmt.root.errors", MetricType.GAUGE,
"Error count encountered by the TabletGroupWatcher for the ROOT data
level.",
- MetricDocSection.MANAGER, "Root Tablet Watcher Errors", null, NUMBER),
+ MetricDocSection.MANAGER, "Root Tablet Errors", null, NUMBER),
MANAGER_ROOT_TGW_RECOVERY("accumulo.tabletmgmt.root.recovery",
MetricType.GAUGE,
"Recovery count encountered by the TabletGroupWatcher for the ROOT data
level.",
- MetricDocSection.MANAGER, "Root Tablet Watcher Recoveries", null,
NUMBER),
+ MetricDocSection.MANAGER, "Root Tablet Recoveries", null, NUMBER),
MANAGER_META_TGW_ERRORS("accumulo.tabletmgmt.meta.errors", MetricType.GAUGE,
"Error count encountered by the TabletGroupWatcher for the META data
level.",
- MetricDocSection.MANAGER, "Meta Tablet Watcher Errors", null, NUMBER),
+ MetricDocSection.MANAGER, "Meta Tablet Errors", null, NUMBER),
MANAGER_META_TGW_RECOVERY("accumulo.tabletmgmt.meta.recovery",
MetricType.GAUGE,
"Recovery count encountered by the TabletGroupWatcher for the META data
level.",
- MetricDocSection.MANAGER, "Meta Tablet Watcher Recoveries", null,
NUMBER),
+ MetricDocSection.MANAGER, "Meta Tablet Recoveries", null, NUMBER),
MANAGER_USER_TGW_ERRORS("accumulo.tabletmgmt.user.errors", MetricType.GAUGE,
"Error count encountered by the TabletGroupWatcher for the USER data
level.",
- MetricDocSection.MANAGER, "User Tablet Watcher Errors", null, NUMBER),
+ MetricDocSection.MANAGER, "User Tablet Errors", null, NUMBER),
MANAGER_USER_TGW_RECOVERY("accumulo.tabletmgmt.user.recovery",
MetricType.GAUGE,
"Recovery count encountered by the TabletGroupWatcher for the USER data
level.",
- MetricDocSection.MANAGER, "User Tablet Watcher Recoveries", null,
NUMBER),
+ MetricDocSection.MANAGER, "User Tablet Recoveries", null, NUMBER),
MANAGER_GOAL_STATE("accumulo.manager.goal.state", MetricType.GAUGE,
"Manager goal state: -1=unknown, 0=CLEAN_STOP, 1=SAFE_MODE, 2=NORMAL.",
MetricDocSection.MANAGER, "Manager Goal State", null, NUMBER),
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
b/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
index 7e812ac872..7bf47a942c 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/compaction/CompactionJobGenerator.java
@@ -18,6 +18,7 @@
*/
package org.apache.accumulo.server.compaction;
+import java.io.Serial;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collection;
@@ -101,7 +102,22 @@ public class CompactionJobGenerator {
this.steadyTime = steadyTime;
}
- public Collection<CompactionJob> generateJobs(TabletMetadata tablet,
Set<CompactionKind> kinds) {
+ public static class CompactionConfigurationException extends
RuntimeException {
+
+ @Serial
+ private static final long serialVersionUID = 985194026258001525L;
+
+ private CompactionConfigurationException(String msg) {
+ super(msg);
+ }
+
+ private CompactionConfigurationException(String msg, Exception e) {
+ super(msg, e);
+ }
+ }
+
+ public Collection<CompactionJob> generateJobs(TabletMetadata tablet,
Set<CompactionKind> kinds)
+ throws CompactionConfigurationException {
Collection<CompactionJob> systemJobs = Set.of();
log.trace("Planning for {} {} {}", tablet.getExtent(), kinds,
this.hashCode());
@@ -174,11 +190,12 @@ public class CompactionJobGenerator {
+ " the table compaction dispatcher configuration. No
compactions will happen"
+ " until the configuration is fixed. This log message is
temporarily suppressed.",
tablet.getExtent().tableId(), serviceId, kind);
- return Set.of();
+ throw new CompactionConfigurationException(
+ "Table configuration " + tablet.getExtent().tableId()
+ + " points to nonexistent compaction service " + serviceId);
}
- CompactionPlanner planner =
- planners.computeIfAbsent(serviceId, sid ->
createPlanner(tablet.getTableId(), serviceId));
+ CompactionPlanner planner = planners.computeIfAbsent(serviceId,
this::createPlanner);
// selecting indicator
// selected files
@@ -308,7 +325,7 @@ public class CompactionJobGenerator {
return planCompactions(planner, params, serviceId);
}
- private CompactionPlanner createPlanner(TableId tableId, CompactionServiceId
serviceId) {
+ private CompactionPlanner createPlanner(CompactionServiceId serviceId) {
CompactionPlanner planner;
String plannerClassName = null;
@@ -316,18 +333,19 @@ public class CompactionJobGenerator {
try {
plannerClassName =
servicesConfig.getPlanners().get(serviceId.canonical());
options = servicesConfig.getOptions().get(serviceId.canonical());
- planner = env.instantiate(tableId, plannerClassName,
CompactionPlanner.class);
+ planner = env.instantiate(plannerClassName, CompactionPlanner.class);
CompactionPlannerInitParams initParameters = new
CompactionPlannerInitParams(serviceId,
servicesConfig.getPlannerPrefix(serviceId.canonical()),
servicesConfig.getOptions().get(serviceId.canonical()),
(ServiceEnvironment) env);
planner.init(initParameters);
} catch (Exception e) {
PLANNING_INIT_ERROR_LOG.trace(
- "Failed to create compaction planner for service:{} tableId:{} using
class:{} options:{}. Compaction "
+ "Failed to create compaction planner for service:{} using class:{}
options:{}. Compaction "
+ "service will not start any new compactions until its
configuration is fixed. This log message is "
+ "temporarily suppressed.",
- serviceId, tableId, plannerClassName, options, e);
- planner = new ProvisionalCompactionPlanner(serviceId);
+ serviceId, plannerClassName, options, e);
+ throw new CompactionConfigurationException(
+ "Failed to create compaction planner for service:" + serviceId, e);
}
return planner;
}
@@ -342,7 +360,8 @@ public class CompactionJobGenerator {
+ " new compactions until this issue is resolved. Duplicates of
this log message are temporarily"
+ " suppressed.",
serviceId, params.getKind(), params.getTableId(),
params.getExecutionHints(), e);
- return Set.of();
+ throw new CompactionConfigurationException(
+ "Failed to plan compactions for service:" + serviceId);
}
}
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/compaction/ProvisionalCompactionPlanner.java
b/server/base/src/main/java/org/apache/accumulo/server/compaction/ProvisionalCompactionPlanner.java
deleted file mode 100644
index efef42c11f..0000000000
---
a/server/base/src/main/java/org/apache/accumulo/server/compaction/ProvisionalCompactionPlanner.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.accumulo.server.compaction;
-
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.accumulo.core.spi.compaction.CompactionPlan;
-import org.apache.accumulo.core.spi.compaction.CompactionPlanner;
-import org.apache.accumulo.core.spi.compaction.CompactionServiceId;
-import org.slf4j.LoggerFactory;
-
-/**
- * A compaction planner that makes no plans and is intended to be used
temporarily when a compaction
- * service has no compaction planner because it is misconfigured.
- */
-public class ProvisionalCompactionPlanner implements CompactionPlanner {
-
- private final CompactionServiceId serviceId;
- private final AtomicLong lastWarnNanoTime = new
AtomicLong(System.nanoTime());
-
- public ProvisionalCompactionPlanner(CompactionServiceId serviceId) {
- this.serviceId = serviceId;
- }
-
- @Override
- public void init(InitParameters params) {
-
- }
-
- @Override
- public CompactionPlan makePlan(PlanningParameters params) {
- var nanoTime = System.nanoTime();
- var updatedTime = lastWarnNanoTime.updateAndGet(last -> {
- if (nanoTime - last > TimeUnit.MINUTES.toNanos(5)) {
- return nanoTime;
- }
-
- return last;
- });
-
- if (updatedTime == nanoTime) {
- LoggerFactory.getLogger(ProvisionalCompactionPlanner.class)
- .error("The compaction service "
- + "'{}' is currently disabled, likely because it has bad
configuration. No "
- + "compactions will occur on this service until it is fixed.",
serviceId);
- }
-
- return params.createPlanBuilder().build();
- }
-}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletManagementIterator.java
b/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletManagementIterator.java
index 89e20dba28..e13637ecb8 100644
---
a/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletManagementIterator.java
+++
b/server/base/src/main/java/org/apache/accumulo/server/manager/state/TabletManagementIterator.java
@@ -336,7 +336,11 @@ public class TabletManagementIterator extends
WholeRowIterator {
} catch (NullPointerException e) {
LOG.info(
"Unable to determine if tablet {} should split or compact, maybe
table was deleted?",
- tm.getExtent());
+ tm.getExtent(), e);
+ } catch (CompactionJobGenerator.CompactionConfigurationException e) {
+ // Logging was already done for this so no additional logging is
needed here. Return tablet
+ // as needs compacting so the manager will see the same error and log
it.
+ reasonsToReturnThisTablet.add(ManagementAction.NEEDS_COMPACTING);
}
}
}
diff --git
a/server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java
b/server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java
index 4c0a3fc8a8..5a7072b24c 100644
---
a/server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java
+++
b/server/manager/src/main/java/org/apache/accumulo/manager/TabletGroupWatcher.java
@@ -98,6 +98,7 @@ import org.apache.accumulo.manager.state.TableStats;
import org.apache.accumulo.manager.upgrade.UpgradeCoordinator;
import org.apache.accumulo.server.ServiceEnvironmentImpl;
import org.apache.accumulo.server.compaction.CompactionJobGenerator;
+import
org.apache.accumulo.server.compaction.CompactionJobGenerator.CompactionConfigurationException;
import org.apache.accumulo.server.conf.CheckCompactionConfig;
import org.apache.accumulo.server.conf.TableConfiguration;
import org.apache.accumulo.server.fs.VolumeUtil;
@@ -153,8 +154,8 @@ abstract class TabletGroupWatcher extends
AccumuloDaemonThread {
this.level = level;
}
- public void incrementTabletGroupWatcherError() {
- errorsGauge.incrementAndGet();
+ public void setTabletGroupWatcherErrors(long errors) {
+ errorsGauge.set(errors);
}
public void setTabletGroupWatcherRecovery(long recoveries) {
@@ -573,7 +574,6 @@ abstract class TabletGroupWatcher extends
AccumuloDaemonThread {
LOG.warn(
"Error on TabletServer trying to get Tablet management information
for metadata tablet. Error message: {}",
mtiError);
- this.metrics.incrementTabletGroupWatcherError();
tableMgmtStats.tabletsWithErrors++;
continue;
}
@@ -704,7 +704,7 @@ abstract class TabletGroupWatcher extends
AccumuloDaemonThread {
final boolean needsSplit =
actions.contains(ManagementAction.NEEDS_SPLITTING);
if (!currentlyUpgrading && needsSplit) {
- LOG.debug("{} may need splitting.", tm.getExtent());
+ LOG.trace("{} may need splitting.", tm.getExtent());
manager.getSplitter().initiateSplit(tm.getExtent());
}
@@ -713,10 +713,15 @@ abstract class TabletGroupWatcher extends
AccumuloDaemonThread {
// Check if tablet needs splitting, priority should be giving to
splits over
// compactions because it's best to compact after a split
if (!needsSplit) {
- var jobs = compactionGenerator.generateJobs(tm,
- TabletManagementIterator.determineCompactionKinds(actions));
- LOG.debug("{} may need compacting adding {} jobs", tm.getExtent(),
jobs.size());
- compactionJobClient.addJobs(tm, jobs);
+ try {
+ var jobs = compactionGenerator.generateJobs(tm,
+ TabletManagementIterator.determineCompactionKinds(actions));
+ LOG.trace("{} may need compacting adding {} jobs", tm.getExtent(),
jobs.size());
+ compactionJobClient.addJobs(tm, jobs);
+ } catch (CompactionJobGenerator.CompactionConfigurationException e) {
+ // Logging was already done, no more logging is needed
+ tableMgmtStats.tabletsWithErrors++;
+ }
} else {
LOG.trace("skipping compaction job generation because {} may need
splitting.",
tm.getExtent());
@@ -792,12 +797,12 @@ abstract class TabletGroupWatcher extends
AccumuloDaemonThread {
}
}
- this.metrics.setTabletGroupWatcherRecovery(tabletsNeedingRecovery);
-
flushChanges(tLists);
if (isFullScan) {
this.filteredServersToShutdown = Set.copyOf(filteredServersToShutdown);
+ this.metrics.setTabletGroupWatcherRecovery(tabletsNeedingRecovery);
+
this.metrics.setTabletGroupWatcherErrors(tableMgmtStats.tabletsWithErrors);
}
return tableMgmtStats;