Repository navigation
[Store] Sync HA applied sequence metric with recovered standby baseline - #4402
Conversation
Signed-off-by: pjdurden <prajjwalchittori1@gmail.com>
he-yufeng
left a comment
There was a problem hiding this comment.
Maintainer pass on this since it sits in the same HA metrics correctness area as my #3806.
I walked the coverage question the fix has to answer: which applied_seq_id_.store sites can leave the gauge stale. On current main there are six. The four you patched (both branches of PrepareBootstrapBaselineLocked, LoadBatchOpLogSnapshotBaselineLocked, RebootstrapBatchOpLog) are exactly the baseline-installation points where no ApplyOpLogEntry runs afterward, so the gauge would otherwise keep its initial value. The two you did not touch check out as not needing it: PreparePromotionLocked only runs after final catch-up, and final catch-up applies through the applier, which already moves the gauge per entry; the two stores in the poll loop mirror oplog_applier_->GetExpectedSequenceId() after the applier has already published each entry to the gauge. The provider-level Recover() calls in batch_oplog_snapshot_provider.cpp are always followed by one of your patched service-level baseline stores, so covering the service layer covers them too. Coverage looks complete for the issue's scope.
The tests do the two things that matter here. SnapshotBootstrapWithoutSuffixSetsAppliedMetric is the issue's exact repro (snapshot with an empty incremental tail), and the snapshot-only case that presets the gauge to 42 and expects 0 pins overwrite semantics rather than "only sets when previously zero", which is the failure mode that would regress silently if someone later guarded the setter.
One scope note for the record: this pins the gauge to the standby's own recovery position. Anything consuming the gauge as a lag signal during promotion still reads it through the promotion path's own timing, which is unchanged here.
Verification on my side was static mechanism review of the patch against current main plus your green CI (CTest passes the HA suites); I did not rebuild locally. Commenting rather than approving so another maintainer can take the formal pass.
|
Checked the coverage claim against the tree, and it holds: the four sites here are exactly the baseline commits that bypass the applier. The other
The snapshot-only test resetting a stale 42 down to 0 is the right pin: the gauge should track the committed baseline, not preserve history. One adjacent thing surfaced while checking the writers: |
Drop the snapshot-only bootstrap hunk and its test, removed upstream by kvcache-ai#4406. Also set the applied-sequence gauge on the preserved promotion cursor restart path added by kvcache-ai#4559, which installs a baseline without going through the applier.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Merged main in (4d7c2e9). #4406 removed the snapshot-only bootstrap path, so that hunk and its test are gone. #4559 added a fifth baseline install that skips the applier, the preserved promotion cursor restart in |
|
Thanks for updating this after the bootstrap changes on main. Keeping the new gauge writes at the points where the service installs a recovered baseline makes sense, especially since Could you please address a few remaining items?
As an optional improvement, the no-suffix test could also check the recovered batch cursor and The temporary-applier metric publication issue already documented in the description seems reasonable to track in a separate follow-up. The requests above focus on completing the coverage and validation for this baseline fix. |
Signed-off-by: pjdurden <prajjwalchittori1@gmail.com>
Signed-off-by: pjdurden <prajjwalchittori1@gmail.com>
|
Merged main in (b994803, includes #4729) and extended the warm-start tests in 5c7c314. |
Icedcoco
left a comment
There was a problem hiding this comment.
LGTM. One non-blocking test gap: ExpectRecovered() checks the gauge after replaying a suffix, but ApplyOpLogEntry() already updates it. A successful rebootstrap with no suffix would directly cover the explicit baseline metric update.
…ffix Signed-off-by: pjdurden <prajjwalchittori1@gmail.com>
|
added RebootstrapWithoutSuffixSetsAppliedMetric for the no-suffix case. it publishes a snapshot covering batch 4, zeroes the gauge, then runs |
Issue #4399: HA snapshot recovery does not update applied sequence metric
1. Root cause
The
ha_oplog_applied_sequence_idgauge is only written inOpLogApplier::ApplyOpLogEntry(). When a standby installs a recovered baseline(batch OpLog snapshot bootstrap, warm start from local state, an empty
baseline, the preserved promotion cursor on restart, or a runtime
re-bootstrap), the applier position is set with
OpLogApplier::Recover()andHotStandbyServicestores the baseline inapplied_seq_id_/primary_seq_id_.Neither step touches the gauge. If no OpLog entries follow the baseline, the
gauge keeps its initial or stale value while
GetSyncStatus().applied_seq_idreports the real position.
2. Fix
HotStandbyServicenow sets the gauge wherever it installs a recoveredbaseline as the live standby state:
PrepareBootstrapBaselineLocked, preserved promotion cursor restartPrepareBootstrapBaselineLocked, shared path (warm start from local state,or the zero baseline from
LoadSnapshotBaselineLocked)LoadBatchOpLogSnapshotBaselineLocked(batch OpLog snapshot bootstrap)RebootstrapBatchOpLog, after swapping in the candidate stateThe write is not in
OpLogApplier::Recover(). The batch snapshot providercalls
Recover()on temporary candidate appliers, includingRecover(0)aftera failed attempt, so a write there would move the gauge while the old standby
state is still serving. The other
applied_seq_id_stores (promotion, thereplication loop) follow entries the applier already published.
3. Files changed
mooncake-store/src/hot_standby_service.cpp: gauge writes at the fourbaseline installation sites above.
mooncake-store/tests/ha/snapshot/batch_oplog/rebootstrap_test.cpp:SnapshotBootstrapWithoutSuffixSetsAppliedMetric: batch snapshot at seq 1with no OpLog tail. The gauge and the snapshot
applied_batchare resetbefore start; after start the gauge reads 1,
applied_batchis 1, andGetSyncStatus()reportsapplied_seq_id == 1andlag_entries == 0.RestartResumesPreservedPromotionCursor: gauge reset to 0 before restartand must read 50 after.
ExpectRecovered: gauge reads 4 after re-bootstrap plus suffix replay.mooncake-store/tests/ha/standby/hot_standby_service_test.cpp:TestWarmStart_WithLocalState: gauge reset afterStop(); the restarthas no new entries, so only the recovered baseline can bring it back to 1.
TestWarmStart_WithoutLocalState: gauge seeded with a stale 42 beforeStart(); both the gauge andGetSyncStatus().applied_seq_idmust read 0.4. Risk
applied_seq_id_stores, no controlflow change.
HAMetricManageris a process-wide singleton. Temporary candidate appliersstill update the gauge through
ApplyOpLogEntrywhile a re-bootstrap replaysa suffix. That is existing behavior and is left for a follow-up.
5. Verification
git clang-format --diff origin/mainis clean on the changed lines.touched tests (
hot_standby_service_test,batch_oplog_snapshot_rebootstrap_test).