Hello Yida Wu, Wenzhe Zhou, Impala Public Jenkins,

I'd like you to reexamine a change. Please visit

    https://gerrit.cloudera.org/25153

to look at the new patch set (#12).

Change subject: IMPALA-15575: Choose the active statestored from the current 
stub state
......................................................................

IMPALA-15575: Choose the active statestored from the current stub state

StatestoreSubscriber::Start() sets the active statestored from the
answers of its two registrations. Both answers can say active and be
stale: if the active statestored fails over after the first registration
and before the second one, no UpdateStatestoredRole RPC reaches the
subscriber in between, and Start() follows the first statestored
although it is gone or standby. Similarly, after a failover the stub of
the standby statestored can keep a stale active flag, so the
subscriber's metrics show both statestoreds as active (IMPALA-15575).

This patch adds ReconcileRoles(), called at the end of Start() when both
registrations report active, and after every re-registration. It follows the 
registered stub that reports
active with the highest active version and clears a stale active flag on
the other stub. If no registered stub reports active, it keeps the
current choice, so that a role update from the other statestored is
still handled as a failover. When the followed statestored is elected
again, UpdateStatestoredRole() now also clears the standby flag of its
last registration. The DCHECK in Start() that at most one answer says
active is removed, since both can. The failover swap in
UpdateStatestoredRole() now checks the roles again under the lock, so
that the recovery thread and the role RPC of the same statestored do not
both swap and switch back to the old statestored.

A statestored that lost the election can still report itself as active
with the version of its old active period, e.g. when it resumes from a
pause during a failover. The registration response handling and the
failover swap in UpdateStatestoredRole() now ignore an active status
with an out-of-date or non-positive version instead of applying it:
applying it could trip the DCHECK on the active version of a stub and
regress the version. These checks are turned off with
--statestore_subscriber_ha_role_checks=false.

When both statestoreds designate themselves as active and the
already-active one wins the HA negotiation as the responder, it also
keeps the version of its old active period and notifies nobody, so the
subscribers keep following the other statestored, which is standby by
then, and stop receiving topic updates. The responder now refreshes its
active version and notifies the subscribers, like a requester that wins
the negotiation.

Testing:
 - Added test_statestored_failover_between_startup_registrations. It
   failed with --statestore_subscriber_ha_role_checks=false (the
   catalogd kept following the killed statestored) and passed 4 times
   with the fix.
 - Added test_stale_active_statestored_on_startup (suggested in
   IMPALA-15575): a statestored paused during a failover reports its old
   active version to a catalogd that registers with it on startup and
   to subscribers that re-register with it. The test hit the DCHECK on
   the active version on the previous patch set, and without the
   version refresh of the negotiation winner its final phase failed:
   every subscriber kept following the other statestored, which is
   standby by then. It passed 8 times with the fix.
 - Ran test_statestored_ha.py and test_catalogd_ha.py with the core
   exploration strategy, and all tests passed.

Change-Id: I4f0c999a0eb4c8049b97223aba902dd55da708f0
Assisted-by: Claude Opus 5.5 (Claude Code)
---
M be/src/statestore/statestore-subscriber.cc
M be/src/statestore/statestore-subscriber.h
M be/src/statestore/statestore.cc
M tests/custom_cluster/test_statestored_ha.py
4 files changed, 313 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/53/25153/12
--
To view, visit https://gerrit.cloudera.org/25153
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4f0c999a0eb4c8049b97223aba902dd55da708f0
Gerrit-Change-Number: 25153
Gerrit-PatchSet: 12
Gerrit-Owner: Petr Fedchenkov <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Petr Fedchenkov <[email protected]>
Gerrit-Reviewer: Wenzhe Zhou <[email protected]>
Gerrit-Reviewer: Yida Wu <[email protected]>

Reply via email to