lokiore opened a new pull request, #2650:
URL: https://github.com/apache/phoenix/pull/2650
### What changes were proposed in this pull request?
This PR is for the **Consistent Failover feature branch**
(`PHOENIX-7562-feature-new`). `PhoenixHAAdminTool initiate-failover` does not
start a failover while a ServerCrashProcedure (SCP) is pending on the active
cluster.
- A new `[Step 2]` runs after the `ACTIVE_IN_SYNC` check, before the tool
writes `ACTIVE_IN_SYNC_TO_STANDBY`. It gets the procedure list from the local
HMaster with `Admin#getProcedures()`.
- A pending SCP is a `ServerCrashProcedure` or `HBCKServerCrashProcedure`
whose state is not `SUCCESS` and not `ROLLEDBACK`. `HBCKServerCrashProcedure`
is the subclass that HBCK2 `scheduleRecoveries` and
`Admin#scheduleServerCrashProcedure` submit. The tool compares the full class
names; it does not use a suffix match.
- If an SCP is pending, the tool shows the procedure ID, the state and the
crashed server, and returns `RET_VALIDATION_ERROR`. The HA group stays in
`ACTIVE_IN_SYNC`.
- A new `-F/--force` option on `initiate-failover` starts the failover in
this case (an ungraceful failover). The tool shows a warning that some writes
can be only on this cluster, and that they must be repaired after the failover
(for example with PhoenixSyncTableTool).
- If the procedure lookup fails, the tool does not start the failover. With
`--force`, it shows a warning and continues.
- The lookup has a limit of 60 s (`hbase.client.operation.timeout`). Without
the limit, an HMaster that does not respond can delay a `--force` failover for
the default 20 minutes.
- The help text and the Javadoc are updated.
### Why are the changes needed?
A RegionServer can stop after it writes a mutation to the WAL and before it
sends the mutation to the standby cluster. The client receives an error for the
write. The SCP then replays the WAL on the active cluster.
`IndexRegionObserver#preWALRestore` sends a replayed edit to the standby only
while the local cluster role is active.
Testing found this sequence:
1. A RegionServer stops in this window.
2. A failover starts before the SCP replays the WAL.
3. The replay applies the edit on the old active cluster only. The two
clusters then have different data.
4. A failover back to the old active cluster shows a write that the client
thinks failed.
To repair such writes is out of scope for this PR.
### Does this PR introduce _any_ user-facing change?
Yes, on this feature branch.
- `initiate-failover` now returns `RET_VALIDATION_ERROR` while an SCP is
pending on the active cluster, or when the procedure lookup fails.
- The new `-F/--force` option bypasses the check for an ungraceful failover.
- The output now has a `[Step 2]` for the check. The later steps are now 3
to 5.
Output with a pending SCP and without `--force`:
```
[Step 2] Checking for pending ServerCrashProcedures...
✗ Cannot initiate failover: 1 ServerCrashProcedure(s) pending on this
cluster:
procId=148, state=WAITING, server=<host>,<port>,<startCode>
Edits of a crashed RegionServer are sent to the standby only when its WAL
is replayed while this cluster is active.
Wait for the procedures to finish and retry, or use --force for an
ungraceful failover.
```
### How was this patch tested?
Test counts are read from the surefire/failsafe reports.
- `PhoenixHAAdminToolTest` (11 tests, all pass). New tests cover:
- the procedure filter for each `ProcedureState`;
- the `HBCKServerCrashProcedure` match, and that an unrelated class name
that ends with `ServerCrashProcedure` does not match;
- non-SCP procedures and string elements in the procedure list;
- a missing server name and unexpected JSON;
- parsing of `-F`/`--force`;
- the pending, `--force` and lookup-failure paths.
- New `PhoenixHAAdminToolServerCrashIT` (2 tests, all pass) uses a real
pending SCP, not a stub:
1. It starts an extra RegionServer and moves the region of a new table to
it.
2. It holds a master region lock and kills the RegionServer. The SCP then
waits at its assign step.
3. Without `--force`, the failover is rejected and both clusters keep
their state. With `--force`, the failover completes.
4. A second test checks that a finished SCP (`SUCCESS`) does not block the
failover.
The extra RegionServer starts without the Phoenix RegionServer endpoint.
With the endpoint, the RegionServer stop can wait behind the HA prewarm thread,
and it also stops the replay service that the test JVM shares.
- `PhoenixHAAdminToolIT` (20 tests, all pass).
- The procedure JSON format comes from the HBase 2.5.14 source and from a
real HMaster in the IT:
- `@type` keys are removed.
- `procId` and `startCode` are strings.
- The server name is in a later `stateMessage` element, not in the first
one.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5.5)
--
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]