PHOENIX-7966 :- Fix flaky HA IT transitClusterRole: expect the settled peer role#2583
Open
lokiore wants to merge 1 commit into
Open
PHOENIX-7966 :- Fix flaky HA IT transitClusterRole: expect the settled peer role#2583lokiore wants to merge 1 commit into
lokiore wants to merge 1 commit into
Conversation
…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))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 expectedClusterRoleRecordto both clusters and thenwaitFors 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 aSTANDBYpeer toSTANDBY_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 roleSTANDBY_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 theACTIVE_TO_STANDBYcluster pair and must complete without error. The now-unused single-argumenttestOneClusterATSRole(ClusterRole)overload is removed.The
transitClusterRoleJavadoc 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
waitForequality check against a role pair that a live peer autonomously advances past will intermittently never match, producing aTimeoutExceptionunrelated 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:applyclean; test-compileBUILD SUCCESS.ParallelPhoenixConnectionIT#testOneClusterATSRoleWithStandbyrun in isolation:Tests run: 1, Failures: 0, Errors: 0, zeroTimed outoccurrences. Verified non-vacuous — the log shows the group reachingACTIVE_IN_SYNC_TO_STANDBYwhile the parallel connection ran.testOneClusterATSRoleWithStandby(5×) plustestOneClusterATSRoleWithActiveandtestBothClusterATSRole: 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))