Petr Fedchenkov created IMPALA-15849:
----------------------------------------
Summary: Statestored HA: make active version announcements robust
to clock skew
Key: IMPALA-15849
URL: https://issues.apache.org/jira/browse/IMPALA-15849
Project: IMPALA
Issue Type: Improvement
Components: Backend
Reporter: Petr Fedchenkov
h2. Problem
With statestored HA, subscribers verify active-status announcements by
comparing {{active_statestored_version}} values (IMPALA-15575). These versions
are host-local {{UnixMicros()}} election stamps, so comparing announcements
from two statestoreds assumes their clocks are roughly in sync. A cross-host
clock skew larger than the failover detection window, or a clock step-back on a
statestored between two of its elections, makes a valid new active announcement
carry a version below the one a subscriber already knows. The subscriber then
ignores the announcement: if the previously followed statestored stays down,
the subscriber keeps following it until it returns, a later election stamps a
higher version, or the subscriber restarts — there is no self-correction.
h2. Proposal
Carry the active version in the statestored HA heartbeat
({{TStatestoreHaHeartbeatRequest}}) and make the version ordering robust
against clock skew:
* A statestored that wins an election stamps its promotion as
max({{UnixMicros()}}, max(local active version, known peer version) + 1), where
the peer version is learned through the new heartbeat field (it is not carried
today), so a skewed winner still announces a version higher than anything
already announced. Carrying the version in {{TStatestoreHaHandshakeResponse}}
as well would cover the peer-reachable startup and recovery paths.
* A statestored that hears a heartbeat with a higher peer version stands down
immediately (within one heartbeat round) instead of counting received peer
heartbeats while active ({{MAX_NUM_RECEIVED_HEARTBEAT_IN_ACTIVE}}, ~11 rounds
at the default cadence); the exact transition — entering recovery mode or
stepping down to standby — can be decided at implementation.
Limitations: if the peer never became active (its known version is 0, e.g. both
statestoreds start fresh), the bump falls back to {{UnixMicros()}} and the skew
window remains. Rolling upgrade: the new field is optional; peers that do not
send it fall back to the existing counting path.
Subscriber-side guards stay unchanged.
h2. Origin
Review discussion on IMPALA-15575 (Gerrit 25153): the version guard added there
turns a skewed failover announcement into an ignored one; previously a release
build applied it (silently regressing the version) and a debug build crashed on
the {{DCHECK}}. Related: IMPALA-15597, IMPALA-15798.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)