tkhurana opened a new pull request, #2581: URL: https://github.com/apache/phoenix/pull/2581
## Summary A `ReplicationLogGroup` is a **writer** and should exist only where the local cluster is active for the HA group. Previously it was created unconditionally — lazily on first mutation and eagerly at RS startup — which let non-active clusters start writers and re-ship (split-brain risk), and let a cutover writer deadlock standby failover by continuously rotating files into the peer's shard directory. ## Changes - **Role-gated creation** — `ReplicationLogGroup.get(...)` now returns `Optional` and creates a group only when the local role is active. A non-active role returns empty and is **not cached**, so the next call after promotion re-checks. Live write path (`preBatchMutate`) throws on empty (split-brain guard); replay path (`preWALRestore`) skips re-ship on empty. - **Skip eager init on non-active clusters** — `PhoenixRegionServerEndpoint` only eager-inits where the local role is active; others init lazily on promotion. - **Failover deadlock fix** — a new `failoverPending` flag (set on entry to the `ACTIVE_IN_SYNC_TO_STANDBY` cutover gate, cleared on abort) suspends log rotation and turns a SYNC-write failure into an RS abort instead of the illegal cutover→SAF transition. `init()` seeds the flag on restart-in-cutover. - **Consolidated state listeners** — all LOCAL state subscriptions moved into `subscribeToStateChanges()`, each paired with its unsubscribe so `close()` leaks no watchers; handles cutover suspend, `STANDBY`/`DEGRADED_STANDBY` close, and SYNC ↔ SYNC_AND_FORWARD flips. - **Constructor overload** — `init()` reuses the record the role gate already read. ## Tests 9 new unit tests in `ReplicationLogGroupTest` plus 2 integration tests (`testWriterClosesOnDemotionToStandby`, `testCutoverSuspendsAndResumesRotation`). ## Note Behavioral change: a sync-path write to a non-active cluster now throws rather than silently creating a writer — the intended split-brain guard. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
