Skip to content

PHOENIX-7562 Add HAGroupStore Metrics2 observability#2576

Merged
tkhurana merged 3 commits into
apache:PHOENIX-7562-feature-newfrom
ritegarg:hagroupstore-metrics
Jul 24, 2026
Merged

PHOENIX-7562 Add HAGroupStore Metrics2 observability#2576
tkhurana merged 3 commits into
apache:PHOENIX-7562-feature-newfrom
ritegarg:hagroupstore-metrics

Conversation

@ritegarg

@ritegarg ritegarg commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Expose focused per-HA-group observability without coupling metrics to HA decisions.

What changes were proposed in this pull request?

  • Add a process-lifetime Hadoop Metrics2 source per HA group with 5 gauges, 6 counters, and 1 listener-latency histogram.
  • Export zero-is-good local-cache and peer-visibility status gauges, stable non-ordinal HA state codes, and selected episode/failure counters.
  • Tag each source by HA group and safely quote its JMX identity.
  • Add focused unit and two-cluster integration coverage for the exported contract and runtime behavior.

Why are the changes needed?

HAGroupStore currently relies on logs for cache health, peer reachability, state divergence, fail-closed behavior, background failures, and slow synchronous listeners. These metrics provide alertable current state and targeted diagnostics while remaining independent of HA control flow.

Does this PR introduce any user-facing change?

Yes. RegionServers expose new HAGroupStore Metrics2/JMX metrics. There is no SQL, JDBC, or HA decision behavior change.

How was this patch tested?

  • Unit tests:
    mvn -pl phoenix-core -am -DskipITs -Dtest=HAGroupStoreRecordTest,HAGroupStoreMetricsSourceImplTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false test
  • Integration tests:
    mvn -pl phoenix-core -am -Dtest=NoSuchUnitTest -Dsurefire.failIfNoSpecifiedTests=false -DfailIfNoTests=false -Dit.test=HAGroupStoreMetricsIT -DskipParallelStatsEnabledTests=true -DskipParallelStatsDisabledTests=true verify
  • Result: 27 unit tests and 9 integration tests passed.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Cursor 3.9.16

Ritesh Garg and others added 2 commits July 16, 2026 22:05
Expose a focused per-group health, state, failure, and listener-latency contract without coupling metrics to HA decisions.

Co-authored-by: Cursor <cursoragent@cursor.com>
Reset gauges after late initialization failures and clarify the exported monitoring contract, metric lifetimes, and accepted best-effort semantics.

Co-authored-by: Cursor <cursoragent@cursor.com>
pstmt.executeUpdate();
conn.commit();
} catch (Exception e) {
metricsSource.incrementSystemTableSyncFailedCount();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this metric is only accounting for write failures but it is ignoring all other failures which can happen before the call even reaches here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 64a625c. The metric now covers the complete synchronization attempt: failures while preparing or writing SYSTEM.HA_GROUP are counted in the helper, while periodic failures before the write are counted by the outer sync handler. The paths are mutually exclusive, so each failed attempt increments once.

} catch (IOException | SQLException e) {
long syncIntervalSeconds = conf.getLong(HA_GROUP_STORE_SYNC_INTERVAL_SECONDS,
DEFAULT_HA_GROUP_STORE_SYNC_INTERVAL_SECONDS);
LOGGER.error("Failed to sync ZK data to system table for HA group on best effort basis {},"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just noticed that we are not logging the exception here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 64a625c. Both synchronization error logs now pass the exception as the trailing SLF4J argument, so the full stack trace and root cause are preserved.

@@ -880,4 +890,4 @@
} catch (IOException | SQLException e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are other reasons which can cause exceptions but the metric is not tracking that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 64a625c. Periodic synchronization now catches and counts ZK reads, peer reads, policy/URL preparation, system-table comparison, and write failures. Write-helper failures are swallowed after counting and return false, preventing double-counting and false success logs.

Count preparation and write failures exactly once, preserve periodic retries after runtime errors, and include exception stack traces in sync logs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ritegarg
ritegarg requested a review from tkhurana July 24, 2026 06:43
@tkhurana
tkhurana merged commit 956c751 into apache:PHOENIX-7562-feature-new Jul 24, 2026
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.

2 participants