Skip to content

PHOENIX-7819 HighAvailabilityGroup.URLS inner Set must be thread-safe - #2437

Open
apurtell wants to merge 1 commit into
apache:masterfrom
apurtell:PHOENIX-7819
Open

apurtell wants to merge 1 commit into
apache:masterfrom
apurtell:PHOENIX-7819

Conversation

@apurtell

@apurtell apurtell commented May 1, 2026

Copy link
Copy Markdown
Contributor

When multiple threads register HA URL infos for the same HAGroupInfo, computeIfAbsent() returns the same HashSet instance to every thread, which then concurrently call add() on it. java.util.HashSet is not thread-safe. Concurrent add() is undefined behavior and can lose entries.

@palashc

palashc commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

@palashc
palashc requested a review from lokiore July 17, 2026 17:16
@apurtell

Copy link
Copy Markdown
Contributor Author

Posted by Claude Code (an AI assistant) on behalf of Andrew Purtell.

The 5.4 stabilization sweep traced this failure to the race that this PR fixes: FailoverPhoenixConnectionIT.testHAGroupMappingsWithDifferentPrincipalsOnDifferentThreads fails with expected:<5> but was:<6> and expected:<6> but was:<5> at line 779. It failed in 2 recent master branch builds on HBase 2.6 (NeedsOwnMiniClusterTest D-K): runs 44824116658 and 44992193332. Many threads change the plain HashSet in HighAvailabilityGroup.URLS, so an add can be lost or an entry can be duplicated. The concurrent set in this PR removes the race.

The branch is rebased onto the latest master (81e0d02fdf), and spotless is clean. Docker check of the rebased branch, JDK 11: FailoverPhoenixConnectionIT and HighAvailabilityGroupIT each passed 3 of 3 runs on HBase 2.6 and 3 of 3 runs on HBase 2.5.

@virajjasani, could you take a look?

🤖 Generated with Claude Code

@apurtell
apurtell requested a review from virajjasani November 25, 2026 06:20
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.

4 participants