Skip to content

HBASE-30231 LoadIncrementalHFiles failed for MetricsException: Metrics source RegionServer,Sub=IO already exists - #8834

Merged
anmolnar merged 3 commits into
apache:masterfrom
anmolnar:HBASE-30231
Nov 5, 2026
Merged

anmolnar merged 3 commits into
apache:masterfrom
anmolnar:HBASE-30231

Conversation

@anmolnar

@anmolnar anmolnar commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

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.

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

  • the fallback on a MetricsException and on a LinkageError
  • IO metrics being off by default
  • MetricsIO.enable() switching to the real source
  • TestMasterNoCluster.testMasterEnablesMetricsIO starts an HMaster with no RegionServer in the same JVM and checks that IO metrics are on.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the IO metrics initialization fallback and server-only enablement changes.

No open issues 🎉

What changed in this PR

This PR prevents IO metrics initialization failures from breaking HFile reads and writes. It also limits IO metrics reporting to server processes while preserving lazy initialization.

Changes:

  • Fall back to a no-op metrics source when initialization throws a runtime exception or linkage error.
  • Enable IO metrics through HBaseServerBase, covering both RegionServers and Masters.
  • Add tests for disabled defaults, enablement, failure fallback, and Master-only startup.
File Description
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​master/​TestMasterNoCluster.java Verifies that Master startup enables IO metrics.
hbase-server/​src/​test/​java/​org/​apache/​hadoop/​hbase/​io/​TestMetricsIO.java Tests enablement, disabled behavior, and initialization fallback.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​io/​MetricsIO.java Adds server opt-in and a no-op fallback for initialization failures.
hbase-server/​src/​main/​java/​org/​apache/​hadoop/​hbase/​HBaseServerBase.java Enables IO metrics during shared server construction.

Review effort: Balanced

@anmolnar
anmolnar merged commit 9ea48c1 into apache:master Nov 5, 2026
8 checks passed
anmolnar added a commit that referenced this pull request Nov 5, 2026
…: Metrics source RegionServer,Sub=IO already exists (#8834)"

This reverts commit 9ea48c1.
anmolnar added a commit that referenced this pull request Nov 5, 2026
…s source RegionServer,Sub=IO already exists (#8834)

MetricsIO.getInstance() lazily registers the "RegionServer,sub=IO" metrics
source on the first HFile read or write. Hadoop's MetricsSystemImpl.register()
reserves the source name before registration has fully completed, so if
anything fails after that point the singleton is never assigned and every
later call fails with "Metrics source RegionServer,sub=IO already exists!".
This breaks all HFile reads and writes for the rest of the JVM's life, as
seen in a bulk load client splitting HFiles in LoadIncrementalHFiles.

- If creating the source fails, log a warning once and use a MetricsIO
  backed by a no-op MetricsIOSource, so a metrics problem can never fail
  HFile I/O.
- Make IO metrics opt-in: MetricsIO.getInstance() returns a shared no-op
  instance until MetricsIO.enable() is called, which HBaseServerBase does in
  its constructor, covering both HRegionServer and HMaster (the master reads
  and writes HFiles through its local MasterRegion). Clients and tools that
  read or write HFiles (bulk load, MapReduce and Spark tasks,
  HFilePrettyPrinter, ...) no longer start the Hadoop metrics system or
  register a RegionServer source. The real source is still created lazily on
  first use (HBASE-27966), so server behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Wellington Chevreuil <[email protected]>
Signed-off-by: Xiao Liu <[email protected]>
Signed-off-by: David Paksy <[email protected]>
anmolnar added a commit that referenced this pull request Nov 5, 2026
…s source RegionServer,Sub=IO already exists (#8834)

MetricsIO.getInstance() lazily registers the "RegionServer,sub=IO" metrics
source on the first HFile read or write. Hadoop's MetricsSystemImpl.register()
reserves the source name before registration has fully completed, so if
anything fails after that point the singleton is never assigned and every
later call fails with "Metrics source RegionServer,sub=IO already exists!".
This breaks all HFile reads and writes for the rest of the JVM's life, as
seen in a bulk load client splitting HFiles in LoadIncrementalHFiles.

- If creating the source fails, log a warning once and use a MetricsIO
  backed by a no-op MetricsIOSource, so a metrics problem can never fail
  HFile I/O.
- Make IO metrics opt-in: MetricsIO.getInstance() returns a shared no-op
  instance until MetricsIO.enable() is called, which HBaseServerBase does in
  its constructor, covering both HRegionServer and HMaster (the master reads
  and writes HFiles through its local MasterRegion). Clients and tools that
  read or write HFiles (bulk load, MapReduce and Spark tasks,
  HFilePrettyPrinter, ...) no longer start the Hadoop metrics system or
  register a RegionServer source. The real source is still created lazily on
  first use (HBASE-27966), so server behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Wellington Chevreuil <[email protected]>
Signed-off-by: Xiao Liu <[email protected]>
Signed-off-by: David Paksy <[email protected]>
(cherry picked from commit 242e81e)
anmolnar added a commit that referenced this pull request Nov 5, 2026
…s source RegionServer,Sub=IO already exists (#8834)

MetricsIO.getInstance() lazily registers the "RegionServer,sub=IO" metrics
source on the first HFile read or write. Hadoop's MetricsSystemImpl.register()
reserves the source name before registration has fully completed, so if
anything fails after that point the singleton is never assigned and every
later call fails with "Metrics source RegionServer,sub=IO already exists!".
This breaks all HFile reads and writes for the rest of the JVM's life, as
seen in a bulk load client splitting HFiles in LoadIncrementalHFiles.

- If creating the source fails, log a warning once and use a MetricsIO
  backed by a no-op MetricsIOSource, so a metrics problem can never fail
  HFile I/O.
- Make IO metrics opt-in: MetricsIO.getInstance() returns a shared no-op
  instance until MetricsIO.enable() is called, which HBaseServerBase does in
  its constructor, covering both HRegionServer and HMaster (the master reads
  and writes HFiles through its local MasterRegion). Clients and tools that
  read or write HFiles (bulk load, MapReduce and Spark tasks,
  HFilePrettyPrinter, ...) no longer start the Hadoop metrics system or
  register a RegionServer source. The real source is still created lazily on
  first use (HBASE-27966), so server behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Wellington Chevreuil <[email protected]>
Signed-off-by: Xiao Liu <[email protected]>
Signed-off-by: David Paksy <[email protected]>
(cherry picked from commit 242e81e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants