Skip to content

PHOENIX-7966 :- Fix flaky HA IT transitClusterRole: expect the settled peer role#2583

Open
lokiore wants to merge 1 commit into
apache:PHOENIX-7562-feature-newfrom
lokiore:flaky-transit-settled-role
Open

PHOENIX-7966 :- Fix flaky HA IT transitClusterRole: expect the settled peer role#2583
lokiore wants to merge 1 commit into
apache:PHOENIX-7562-feature-newfrom
lokiore:flaky-transit-settled-role

Conversation

@lokiore

@lokiore lokiore commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fixes intermittent timeouts in the HA integration-test helper transitClusterRole (~1 in 5 runs) when a group transitions with both clusters live. The helper writes an expected ClusterRoleRecord to both clusters and then waitFors the refreshed record to equal it. When the local cluster moves toward standby (ACTIVE_TO_STANDBY), a live peer's failover-management listener autonomously advances a STANDBY peer to STANDBY_TO_ACTIVE. Naming the transient pre-advance role in the wait races that autonomous transition and intermittently never matches, timing out at the 10s poll deadline.

Two complementary, deterministic fixes, each matching its call site's intent:

  • FailoverPhoenixConnectionIT, HAGroupMetricsIT (setup-then-assert sites): the {ACTIVE_TO_STANDBY, STANDBY} transit is only a stepping stone to a later settled state the test actually asserts on. Keep the settle-wait but name the settled peer role STANDBY_TO_ACTIVE — a fixed point in the peer/local transition maps — so the record matches on the first poll regardless of listener timing.
  • ParallelPhoenixConnectionIT.testOneClusterATSRoleWithStandby (asserts on the transient pair itself): {ACTIVE_TO_STANDBY, STANDBY} is the state under test and is not reachable as a stable pair with both clusters live, so no settled role can be named without changing what the test exercises. Skip the settle-wait (doRefresh=false) instead; the parallel connection is still exercised against the ACTIVE_TO_STANDBY cluster pair and must complete without error. The now-unused single-argument testOneClusterATSRole(ClusterRole) overload is removed.

The transitClusterRole Javadoc and the cluster-down / cluster-restart variants are annotated to document the peer-advance exposure and why each is or is not subject to it.

Why are the changes needed?

The tests are flaky: the waitFor equality check against a role pair that a live peer autonomously advances past will intermittently never match, producing a TimeoutException unrelated to any product defect. This erodes trust in the HA IT suite and causes spurious CI failures.

Does this PR introduce any user-facing change?

No. Test-only change; no production code is touched.

How was this patch tested?

  • mvn spotless:apply clean; test-compile BUILD SUCCESS.
  • ParallelPhoenixConnectionIT#testOneClusterATSRoleWithStandby run in isolation: Tests run: 1, Failures: 0, Errors: 0, zero Timed out occurrences. Verified non-vacuous — the log shows the group reaching ACTIVE_IN_SYNC_TO_STANDBY while the parallel connection ran.
  • Loop of testOneClusterATSRoleWithStandby (5×) plus testOneClusterATSRoleWithActive and testBothClusterATSRole: all green, zero timeouts/failures/errors.

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

Generated-by: Claude Code (Opus 4.8 (1M context))

…d peer role

HA integration tests intermittently time out (~1 in 5 runs) inside the
transitClusterRole test helper when a group transitions under the FAILOVER or
PARALLEL policy with both clusters live. The helper writes an expected
ClusterRoleRecord to both clusters and then waits for the refreshed record to
equal it. When the local cluster moves toward standby (ACTIVE_TO_STANDBY), a
live peer's failover-management listener autonomously advances a STANDBY peer to
STANDBY_TO_ACTIVE. Naming the transient pre-advance role in the wait therefore
races that autonomous transition and intermittently never matches, timing out.

Two complementary, deterministic fixes, each matching its call site's intent:

* FailoverPhoenixConnectionIT and HAGroupMetricsIT (setup-then-assert sites):
  the {ACTIVE_TO_STANDBY, STANDBY} transit is only a stepping stone to a later
  settled state that the test actually asserts on, so keep the settle-wait but
  name the SETTLED peer role STANDBY_TO_ACTIVE -- a fixed point in the
  peer/local transition maps -- so the record matches on the first poll
  regardless of listener timing.

* ParallelPhoenixConnectionIT.testOneClusterATSRoleWithStandby (assert-on-the-
  transient-pair site): {ACTIVE_TO_STANDBY, STANDBY} is itself the state under
  test and is not reachable as a stable pair with both clusters live, so no
  settled role can be named without changing what the test exercises. Skip the
  settle-wait (doRefresh=false) instead; the parallel connection is still
  exercised against the ACTIVE_TO_STANDBY cluster pair and must complete without
  error. The now-unused single-argument overload is removed.

The transitClusterRole Javadoc and the cluster-down / cluster-restart variants
are annotated to document the peer-advance exposure and why each is or is not
subject to it.

Test-only change; no production code is touched.

Generated-by: Claude Code (Opus 4.8 (1M context))
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.

1 participant