tkhurana commented on PR #2650:
URL: https://github.com/apache/phoenix/pull/2650#issuecomment-6670333417

   Thanks for chasing this down. The replay-after-demotion sequence in the 
description is real, and the write-up of the procedure JSON format and the SCP 
state machine was useful. After going through the HBase SCP and assignment 
code, though, I don't think a pre-failover SCP check is the right mitigation, 
whether it blocks or only warns. My suggestion is to drop the SCP lookup and 
keep this PR to a small change: print time markers. Here's the reasoning.
   
   **1. The check runs before the risky point, so it can't cover the risk.**
   - **When replayed edits stop being sent.** Step 2 runs before 
`ACTIVE_IN_SYNC_TO_STANDBY` is written. But in that state the role is 
`ACTIVE_TO_STANDBY` (`isActive()` is true), and replayed edits are still sent 
to the peer. They stop being sent only when this cluster moves to STANDBY, 
which happens once the peer reaches ACTIVE_IN_SYNC, later and outside the 
tool's control.
   - **So the SCPs that matter are those still pending at that moment.** An SCP 
pending at Step 2 that finishes before the demotion has already sent its edits. 
One that starts after Step 2 is never seen.
   
   **2. It misses cases even at the moment it runs.**
   - **A RegionServer that has died but isn't expired yet.** Until its 
ZooKeeper session times out (`zookeeper.session.timeout`, 90 s by default), the 
master has no SCP for it. In the sequence from the description, where the RS 
dies just before the failover, this may be the most likely version.
   - **A region the SCP doesn't assign itself.** In 
`ServerCrashProcedure#assignRegions`, a region whose location no longer matches 
the crashed server, or that already has a procedure attached, is skipped or 
handed to that procedure (`regionNode.getProcedure().serverCrashed(...)`). It 
is not added as a child, so the SCP can reach SUCCESS while that region's 
recovered edits, written during `SERVER_CRASH_SPLIT_LOGS`, are still waiting to 
be replayed.
   
   **3. It fires on harmless SCPs.** Every RegionServer exit gets an SCP, 
including a clean stop: `RegionServerTracker` sees the ephemeral node go away 
and `ServerManager#expireServer` calls `submitServerCrash(serverName, true, 
...)`. A clean stop flushes every region on close, so those SCPs have nothing 
to replay.
   - **If it blocks:** failovers get rejected throughout a rolling restart, and 
operators learn to add `--force`. That flag then also skips the real crash 
case, and `-F` already means something different on `create`/`update`.
   - **If it only warns:** the warning is mostly noise.
   
   **4. Listing SCPs doesn't change what the operator does.** After a failover 
the operator has to:
   - wait for the old cluster to quiesce, with no pending SCPs and no regions 
in transition;
   - check for divergence (edits replayed after the demotion can be detected on 
the RegionServer at replay time, wherever in the timeline the crash happened);
   - repair with PhoenixSyncTableTool, from the new active to the old one over 
the affected time window, so the old cluster ends up "not written", which 
matches the error the client got.
   
   A list of SCPs taken at Step 2 doesn't change any of those steps. Because of 
(2), "none listed" also doesn't mean "nothing to check".
   
   **5. The lookup has its own costs.**
   - **Permissions:** a second HBase connection that needs ADMIN.
   - **Timeouts:**
     - The 60 s cap is only checked between retries. Each attempt can still 
wait on the master-stub setup and on `hbase.rpc.timeout`.
     - `createConnection` waits on the cluster id with no timeout.
   - **Parsing:** it relies on HBase's internal procedure JSON, including exact 
class names and string-typed `procId`. `toProcedureJson` also puts error 
strings in place of procedures it can't convert.
   - **Tests:** about 370 lines of IT that hold a master region lock, all to 
maintain.
   
   **Suggested change:**
   - **Repurpose PHOENIX-8037 and this PR** as "PhoenixHAAdminTool: print 
failover time markers". Update the JIRA title and description, and the PR 
title. Keep the scenario write-up in the JIRA as the motivation: the 
post-failover divergence check is what deals with that scenario, and these 
markers give the time window to scope it.
   - **Drop the lookup.** Remove the SCP lookup, `--force` on 
`initiate-failover`, and `PhoenixHAAdminToolServerCrashIT`.
   - **Print timestamped markers** so the operator has exact times to scope 
that check. One line per event, grep-friendly, written to stdout and to 
`LOG.info`:
     ```
     PHOENIX_HA_FAILOVER_MARKER marker=<NAME> group=<g> ts=<epoch ms> 
ts_utc=<ISO-8601>
     ```
     - `FAILOVER_START`: after argument parsing, before Step 1.
     - `FAILOVER_COMPLETE` or `FAILOVER_TIMEOUT`: at the end of 
`pollForStateTransition`.
     - `ABORT_START` and `ABORT_COMPLETE`/`ABORT_TIMEOUT` for `abort-failover`.
   - **Tests:** a unit test for the line format, and a check in the 
`PhoenixHAAdminToolIT` happy path that the start marker comes before the 
complete marker.
   
   Happy to talk through any of this.
   


-- 
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]

Reply via email to