Skip to content

PHOENIX-7992 Add replay-side performance metrics for HA replication - #2607

Draft
Himanshu-g81 wants to merge 3 commits into
apache:PHOENIX-7562-feature-newfrom
Himanshu-g81:PHOENIX-7992
Draft

PHOENIX-7992 Add replay-side performance metrics for HA replication#2607
Himanshu-g81 wants to merge 3 commits into
apache:PHOENIX-7562-feature-newfrom
Himanshu-g81:PHOENIX-7992

Conversation

@Himanshu-g81

@Himanshu-g81 Himanshu-g81 commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Adds six per-HA-group standby replay-side performance metrics (replay lag, pickup lag, mutations replayed + per-file, rename-failed count, slow-round count) for HA replication — new observability surface, no behavioral change.

Adds six standby replay-side performance metrics, each inheriting the
per-haGroup dimension from its metric source.

ReplicationLogDiscoveryReplay:
  - endToEndReplayLagMs (histogram): round-eligible -> replay finished
  - pickupLagMs (histogram): round-eligible -> file claimed (rename into
    the in-progress directory)

ReplicationLogDiscovery (shared base):
  - roundsExceedingRoundTime (counter): rounds whose new-file processing
    duration exceeded roundTimeMills

ReplicationLogProcessor:
  - mutationsReplayedCount (counter): replay throughput across all files
  - mutationsPerFile (histogram): per-file mutation count, recorded only
    for files that replayed at least one mutation so rotation-only files
    do not skew the distribution toward zero

ReplicationLogTracker:
  - markFileInProgressCollisionCount (counter): claim renames lost to a
    competing process, a strict subset of the request count

The lag metrics use the round-eligible instant (round end + waiting
buffer) as the zero reference, so they exclude the fixed built-in wait
rather than measuring raw file age.

Tests: metric-source plumbing for all six metrics, plus recording-site
tests for the collision metric (rename-loses vs rename-wins) and the
slow-round metric (fast round vs slow round).
Record pickupLag only on a file's first claim, skipping in-progress reclaims
that re-stamp the rename timestamp; anchor round-boundary files to the earlier
round in getRoundEligibleTime; and rename two counters to match what they
actually measure: mutationsReplayedCount -> successfulFileMutationsReplayedCount
and markFileInProgressCollisionCount -> markFileInProgressRenameFailedCount.
Adds ReplicationLogDiscoveryReplayProcessFileTest covering the eligibility math,
first-claim-only pickup lag, and mid-replay failure handling.
…fy metric docs

Follow-up addressing review feedback on apache#2607.

Tests (C1): drive ReplicationLogProcessor.processLogFile end to end to guard the
per-file mutation-metric recording sites, and add a mid-replay-failure case
proving mutations applied before a failure are not counted (the writes sit
before the catch). Assert the reset-immune successfulFileMutationsReplayedCount
counter rather than the mutationsPerFile histogram max: MutableHistogram.getMax()
is reset to 0 by the metrics system's periodic snapshot(), so a positive max is
not stable to read after a multi-second real replay. Zero-mutation and failed
files still assert a 0 histogram max, which is stable.

Reclaim path (S1): convert the unchecked NumberFormatException from
getFileTimestamp on a malformed in-progress file name into an IOException, so a
single bad name is isolated to processOneRandomFile's per-file handler (marked
failed and retry-counted) instead of escaping as a RuntimeException that aborts
the whole in-progress sweep for the cycle. Adds a unit test.

Docs:
- roundsExceedingRoundTime lives on the shared discovery base, so clarify it is
  emitted on both the forwarder and replay sides, not replay-only (A5).
- Note the endToEndReplayLag / pickupLag histograms are survivorship-biased
  (sampled only on success / first claim) and should be read alongside the
  failure and staleness signals (D1).
- Note markFileInProgressRenameFailedCount counts only rename() == false, not an
  IOException thrown during the rename (D2).
- Note endToEndReplayLag samples rotation-only / zero-mutation files that
  mutationsPerFile excludes, so the two cover different file populations (C2).
- Fix stale processFile(Path) Javadoc to processFile(Path, boolean) (C4).
- Log a breadcrumb when a first-claim file carries no rename timestamp (D4).
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