anmolnar opened a new pull request, #8834: URL: https://github.com/apache/hbase/pull/8834
## What's the problem HFile reads and writes record latency metrics through `MetricsIO`. The first time this runs in a process, it registers a `RegionServer,sub=IO` metrics source. If that registration fails partway through, the source name stays reserved but the `MetricsIO` singleton is never set. Every later HFile read or write then fails for the rest of the JVM's life with: ``` org.apache.hadoop.metrics2.MetricsException: Metrics source RegionServer,sub=IO already exists! ``` The reporter hit this in a bulk-load client. Full analysis is in [HBASE-30231](https://issues.apache.org/jira/browse/HBASE-30231). ## What this PR changes - **Fall back to a no-op `MetricsIOSource` when initialization fails.** `MetricsIO.getInstance()` catches the failure once, logs a warning and uses a source that ignores updates. A metrics problem can no longer fail HFile I/O, on clients or servers. - **Only report IO metrics from server processes.** `MetricsIO` now does nothing until `MetricsIO.enable()` is called, which `HRegionServer` (and so `HMaster`) does in its constructor. Bulk-load clients, MapReduce tasks and tools like `HFilePrettyPrinter` no longer start the Hadoop metrics system or register a "RegionServer" source. Server behaviour is unchanged: the source is still created on first use, as HBASE-27966 requires. > [!NOTE] > The first change is the bug fix. The second is a small behaviour change: anything writing HFiles without being an `HRegionServer` stops reporting `RegionServer,sub=IO` metrics. HBase's own code doesn't depend on that, but it's worth a release note. ## Tests New cases in `TestMetricsIO` cover: - the fallback on a `MetricsException` and on a `LinkageError` - IO metrics being off by default - `MetricsIO.enable()` switching to the real source ## Splitting The two changes are independent, so I'm happy to split them into separate commits and Jira tickets if reviewers prefer. The fallback would stay on HBASE-30231, and the server-only change would go to a new sub-task. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
