[ https://issues.apache.org/jira/browse/HIVE-24824?focusedWorklogId=558659&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-558659 ]
ASF GitHub Bot logged work on HIVE-24824: ----------------------------------------- Author: ASF GitHub Bot Created on: 26/Feb/21 18:00 Start Date: 26/Feb/21 18:00 Worklog Time Spent: 10m Work Description: klcopp commented on a change in pull request #2016: URL: https://github.com/apache/hive/pull/2016#discussion_r583819228 ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/AcidMetricService.java ########## @@ -0,0 +1,157 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.hadoop.hive.metastore.metrics; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.MetaStoreThread; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.ShowCompactRequest; +import org.apache.hadoop.hive.metastore.api.ShowCompactResponse; +import org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.txn.TxnStore; +import org.apache.hadoop.hive.metastore.txn.TxnUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + +/** + * Collect and publish ACID and compaction related metrics. + */ +public class AcidMetricService extends Thread implements MetaStoreThread { Review comment: Why not include this in metastore.task.threads.always and implement MetastoreTaskThread? ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/metrics/AcidMetricService.java ########## @@ -0,0 +1,157 @@ +/* + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.hadoop.hive.metastore.metrics; + +import com.google.common.annotations.VisibleForTesting; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.MetaStoreThread; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.ShowCompactRequest; +import org.apache.hadoop.hive.metastore.api.ShowCompactResponse; +import org.apache.hadoop.hive.metastore.api.ShowCompactResponseElement; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.txn.TxnStore; +import org.apache.hadoop.hive.metastore.txn.TxnUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; + +/** + * Collect and publish ACID and compaction related metrics. + */ +public class AcidMetricService extends Thread implements MetaStoreThread { + + private static final Logger LOG = LoggerFactory.getLogger(AcidMetricService.class); + private Configuration conf; + private int threadId; + private AtomicBoolean stop; + private TxnStore txnHandler; + private long checkInterval; + + @Override + public void setThreadId(int threadId) { + setPriority(MIN_PRIORITY); + this.threadId = threadId; + } + + @Override + public void init(AtomicBoolean stop) throws Exception { + setDaemon(true); // the process will exit without waiting for this thread + + this.stop = stop; + checkInterval = MetastoreConf.getTimeVar(conf, MetastoreConf.ConfVars.METASTORE_ACIDMETRICS_CHECK_INTERVAL, TimeUnit.MILLISECONDS); + // Get our own instance of the transaction handler + txnHandler = TxnUtils.getTxnStore(conf); + } + + @Override + public void run() { + LOG.info("Starting AcidMetricService thread"); + try { + do { + long startedAt = System.currentTimeMillis(); + + boolean metricsEnabled = MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.METRICS_ENABLED) && + MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.METASTORE_ACIDMETRICS_THREAD_ON); + if (!metricsEnabled) { + // Make it possible to disable metrics collection without a restart + LOG.debug("AcidMetricService is running but metric collection is not enabled"); + if (!stop.get()) { + Thread.sleep(checkInterval); + } + continue; + } + try { + collectMetrics(); + } catch (Exception ex) { + LOG.error("Caught exception in AcidMetricService loop", ex); + } + + long elapsedTime = System.currentTimeMillis() - startedAt; + LOG.info("AcidMetricService thread finished one loop in {} seconds.", elapsedTime / 1000); Review comment: I vote for debug level here (yes this is hypocritical :) ) ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 558659) Time Spent: 20m (was: 10m) > Define metrics for compaction observability > ------------------------------------------- > > Key: HIVE-24824 > URL: https://issues.apache.org/jira/browse/HIVE-24824 > Project: Hive > Issue Type: Improvement > Reporter: Peter Varga > Assignee: Peter Varga > Priority: Major > Labels: pull-request-available > Time Spent: 20m > Remaining Estimate: 0h > > Many times if there are failures in the Compaction background processes > (Initiator, Worker, Cleaner) it is hard notice the problem until it causes > serious performance degradation. > We should create new JMX metrics, that would make it easier to monitor the > compaction health. Examples are: > * number of failed / initiated compaction > * number of aborted txns, oldest aborted txns > * tables with disabled compactions and writes > * Initiator and Cleaner cycle runtime > * Size of ACID metadata tables that should have ~ constant rows > (txn_to_writeId, completed_txns) > -- This message was sent by Atlassian Jira (v8.3.4#803005)