Petr Fedchenkov has uploaded this change for review. ( 
https://gerrit.cloudera.org/25620


Change subject: IMPALA-15849: Statestored HA: make active version announcements 
robust to clock skew
......................................................................

IMPALA-15849: Statestored HA: make active version announcements robust to clock 
skew

With statestored HA, subscribers validate active-status announcements by
comparing active_statestored_version values (IMPALA-15575). Because
these versions are host-local UnixMicros() timestamps, cross-host clock
skew larger than the failover window, or a local clock step-back between
elections, can cause a newly elected active statestored to announce a
version lower than one a subscriber already knows. The subscriber then
ignores the announcement until the old statestored returns, a later
election stamps a higher version, or the subscriber restarts.

This change adds an optional active_statestored_version field to
TStatestoreHaHeartbeatRequest and makes active-version ordering robust
to clock skew:

- Centralize election stamping in Statestore::UpdateActiveVersion(),
  which sets active_version_ to max(UnixMicros(), max(active_version_,
  peer_active_version_) + 1), where peer_active_version_ tracks the
  highest version seen in peer HA heartbeats. This guarantees
  monotonic versions across failovers even with skewed clocks, and
  also resets num_received_heartbeat_in_active_ (previously missed by
  three promotion paths).

- In Statestore::HaHeartbeatRequest(), a statestored receiving a higher
  peer version steps down to standby immediately instead of counting
  heartbeats up to MAX_NUM_RECEIVED_HEARTBEAT_IN_ACTIVE. On a lower
  (stale) peer version, it re-enables HA heartbeats (setting
  found_peer_ = true if needed) so the stale peer receives the higher
  version and steps down.

- Because the new Thrift field is optional, older peers during a rolling
  upgrade (version 0) fall back to the existing counting path.
  Subscriber-side guards are unchanged.

Testing:
- Added unit test StatestoreTest.HaHeartbeatVersionHandling covering
  immediate stand-down on a higher version, monotonic stamping under a
  skewed peer version, and the unversioned counting fallback.
- Added e2e test test_split_brain_stand_down_on_higher_active_version
  covering split brain when a paused active statestored resumes.

Assisted-by: GLM-5.4 (ZCode)
Assisted-by: Gemini 4 Neon (Antigravity)
Change-Id: Ieebb5b2447c1680b93c1dfb4ead991ca13e27802
---
M be/src/statestore/statestore-test.cc
M be/src/statestore/statestore.cc
M be/src/statestore/statestore.h
M common/thrift/StatestoreService.thrift
M tests/custom_cluster/test_statestored_ha.py
5 files changed, 220 insertions(+), 29 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/20/25620/1
--
To view, visit https://gerrit.cloudera.org/25620
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieebb5b2447c1680b93c1dfb4ead991ca13e27802
Gerrit-Change-Number: 25620
Gerrit-PatchSet: 1
Gerrit-Owner: Petr Fedchenkov <[email protected]>

Reply via email to