Himanshu-g81 commented on code in PR #2577:
URL: https://github.com/apache/phoenix/pull/2577#discussion_r3638948503
##########
phoenix-core-server/src/main/java/org/apache/phoenix/replication/reader/ReplicationLogDiscoveryReplay.java:
##########
@@ -139,7 +150,15 @@ public void init() throws IOException {
clusterType == ClusterType.LOCAL
&& HAGroupStoreRecord.HAGroupState.STANDBY.equals(toState)
) {
- replicationReplayState.set(ReplicationReplayState.SYNCED_RECOVERY);
+ // compareAndSet from DEGRADED only, not an unconditional set():
DEGRADED is the only
+ // state whose lastRoundInSync lags lastRoundProcessed, hence the
only state a recovery
+ // to STANDBY must rewind from. A STANDBY event that lands while
already SYNC (e.g.
+ // ABORT_TO_STANDBY -> STANDBY after a prior rewind, or a
cache-reconnect redelivery)
+ // would otherwise flip SYNC -> SYNCED_RECOVERY and needlessly
re-process the frontier
+ // round. Symmetric with triggerFailoverListner below; contrast
degradedListener above,
+ // whose unconditional fail-closed set() is intentional.
+ replicationReplayState.compareAndSet(ReplicationReplayState.DEGRADED,
Review Comment:
We just want to ensure we don't do any un-desirable state change and avoid
race conditions. Have logged it also (in one of the existing log line)
##########
phoenix-core-server/src/main/java/org/apache/phoenix/replication/reader/ReplicationLogDiscoveryReplay.java:
##########
@@ -151,6 +170,13 @@ public void init() throws IOException {
clusterType == ClusterType.LOCAL
&&
HAGroupStoreRecord.HAGroupState.STANDBY_TO_ACTIVE.equals(toState)
) {
+ // Direct DEGRADED_STANDBY -> STANDBY_TO_ACTIVE skips the STANDBY
event that normally
+ // drives recovery. If we are DEGRADED, schedule the rewind so
replay() re-syncs from
+ // lastRoundInSync before shouldTriggerFailover() (which gates on
SYNC) can promote.
+ // compareAndSet, not set: a listener firing while already SYNC
(healthy failover) or
+ // SYNCED_RECOVERY (rewind already pending) must not clobber a good
state.
+ replicationReplayState.compareAndSet(ReplicationReplayState.DEGRADED,
Review Comment:
https://github.com/apache/phoenix/pull/2577#discussion_r3638948503
--
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]