Repository navigation
HBASE-30547 Master active time can go backwards after a failover to a master whose clock is behind - #8898
HBASE-30547 Master active time can go backwards after a failover to a master whose clock is behind#8898SpookyJumpyBeans wants to merge 2 commits into
Conversation
… master whose clock is behind
There was a problem hiding this comment.
I see the merit of storing the active master's start time. However, if a new master starts up and detects the clock has gone backwards, I think it would be better to fail startup, rather than inventing a new startup time that has no relationship to the system clock. Clocks are not supposed to go backwards, so it would be better to expose that issue than paper over it.
|
@charlesconnell, thanks for taking a look! I agree a real clock problem should be visible rather than hidden. My concern with failing startup is that this case doesn't need a clock going backwards on one host. It only needs the backup master's clock to be behind the old master's by more than the time between the two becoming active, which in a fast failover can be a few seconds. HBase already accepts that much skew between servers: How about doing both: if the stored active time is ahead of the new master's clock by more than |
That sounds great |
… more than the max clock skew
|
Thanks! Pushed it. If the stored active time is ahead of the new master's clock by more than One consequence worth knowing: if a master's clock was ever far ahead, the time it stored stays ahead, so later masters with correct clocks will refuse to start until the wall clock passes it. That seems in line with exposing the problem, but let me know if you'd want a way around it. |
https://issues.apache.org/jira/browse/HBASE-30547
Since HBASE-28690 a master rejects a report whose initiating master active time is greater than its own. The active time comes from the wall clock, so after a failover to a master whose clock is behind, the new master can have a lower active time than the old one and rejects every report for a procedure the old master started. For a region open, the region server keeps retrying OPENED with the old active time and ignores the new master's re-dispatch of the same procedure, so the region stays in OPENING while the new master is active.
Changes
MasterActiveTimeStore, aMasterStateStoreholding the last active master's active time in the master local region.HMaster.finishActiveMasterInitializationstill reads the clock as before, then, right after opening the master local region, sets the active time tomax(now, last stored + 1)and stores it:Opening the master local region renames the previous master's WAL directory and recovers the lease on its WAL files, so the previous master can no longer write to it. The procedure executor is created after this point, so no remote procedure carries the earlier value, and reports are only checked once
serviceStartedis set, also later. A warning is logged when the stored time is used, since it means the masters' clocks disagree.hbase.master.maxclockskew(30s by default, the same limitServerManageruses for region servers), startup fails with aClockOutOfSyncExceptionand nothing is stored. Below that, the stored time plus one is used and a warning is logged. The 30s default is nowServerManager.DEFAULT_MAX_CLOCK_SKEW_MS.masterActiveTimeis nowvolatile, since RPC handlers read it and it is now written twice during initialization.getCurrentTimeForActiveTime(), so a test can simulate a master whose clock is behind.Limits
hbase.master.maxclockskewahead, the time it stored stays ahead, so later masters with correct clocks fail to start until the wall clock passes it.MasterStateStore.Other approaches I looked at: the master start code comes from the same clock; the zxid of the active master znode is monotonic but on a different scale, which would break comparisons with older masters during an upgrade; and the initiating active time is not persisted with the procedures, so it can't be recovered from the procedure store.
Tests
TestOpenRegionReportAfterFailoverToMasterWithClockBehind: holds the OPENED report on the active master, fails over to a master whose clock is behind (through an override ofgetCurrentTimeForActiveTime()), and releases the report. Without this change the new master keeps rejecting the report ("initiatingMasterAT 1794786260006 received on master with activeTime 1794786200028", thousands of times per run) and the open never finishes. With this change the open finishes on the new master.TestMasterActiveTimeStore: unit tests foradvance, including a malformed stored value and the max clock skew check.I ran these on Linux (WSL) with JDK 21: the new test passed 5 of 5 runs with this change and fails without it. These also pass with it:
TestMasterActiveTimeStore,TestOpenRegionProcedureHang,TestReportRegionStateTransitionRetry,TestServerRemoteProcedure,TestMasterFailover,TestMasterMetrics,TestMasterMetricsWrapper,TestMasterNoCluster,TestMasterRegionInitialize,TestSnapshotCleanupStateStore.