Skip to content

[Store] Add batch OpLog snapshot coordinator - #3794

Merged
ykwd merged 2 commits into
kvcache-ai:mainfrom
Icedcoco:dev/oplog-ha-prs/N06
Sep 1, 2026
Merged

ykwd merged 2 commits into
kvcache-ai:mainfrom
Icedcoco:dev/oplog-ha-prs/N06

Conversation

@Icedcoco

Copy link
Copy Markdown
Collaborator

Description

PR-N06 adds the standalone BatchOpLogSnapshotCoordinator for the new batch OpLog standby snapshot path. It composes the existing N02 capture, N03 artifact writer, N04 maintenance lease/publisher, and N05 standby cursor state into one coordinator with periodic scheduling and explicit lifecycle state.

The coordinator is inert when only HotStandbyService is constructed. It is not wired into public configuration or the default production path; N08 will perform that integration after the complete snapshot mode is ready.

Scheduling and lifecycle

  • Uses the existing 600-second default snapshot interval.
  • Starts only when the local durable batch cursor is newer than the published latest/fallback cursor, the previous catch-up target has been applied, and no attempt is already running.
  • Acquires the N04 maintenance lease, then re-reads the published pointer and local cursor before capture. A busy lease skips the cycle without stopping OpLog apply.
  • Generates an immutable <batch-id>-<lease-id> candidate prefix and reuses the existing chunk writer and fenced publisher.
  • Records the durable prefix observed when capture releases standby state, so the next attempt waits for that catch-up target.
  • Cancels capture on promotion/stop. Once capture has released standby state, promotion does not cancel the remaining artifact verification or publish work.
  • Object-store failures and worker exceptions are contained in the coordinator; they do not terminate the OpLog apply loop or publish an invalid pointer.

Compatibility

  • Legacy snapshot provider/manager and public master configuration are unchanged.
  • All new snapshot headers, implementation, and tests live under the ha/snapshot/batch_oplog/ namespace, with only a compatibility include at the snapshot root.

Module

  • Mooncake Store (mooncake-store)

Type of Change

  • New feature
  • Refactor

How Has This Been Tested?

Test commands:

cmake --build /tmp/mooncake-n06-build \
  --target batch_oplog_snapshot_coordinator_test \
  -j32

/tmp/mooncake-n06-build/mooncake-store/tests/batch_oplog_snapshot_coordinator_test \
  --gtest_color=no

/tmp/mooncake-n06-build/mooncake-store/tests/batch_oplog_snapshot_writer_test \
  --gtest_color=no
/tmp/mooncake-n06-build/mooncake-store/tests/batch_oplog_snapshot_provider_test \
  --gtest_color=no
/tmp/mooncake-n06-build/mooncake-store/tests/batch_oplog_snapshot_publisher_test \
  --gtest_color=no
/tmp/mooncake-n06-build/mooncake-store/tests/hot_standby_service_test \
  --gtest_color=no

pre-commit run --files \
  mooncake-store/include/hot_standby_service.h \
  mooncake-store/src/CMakeLists.txt \
  mooncake-store/src/hot_standby_service.cpp \
  mooncake-store/tests/CMakeLists.txt \
  mooncake-store/include/ha/snapshot/batch_oplog/batch_oplog_snapshot_coordinator.h \
  mooncake-store/include/ha/snapshot/batch_oplog_snapshot_coordinator.h \
  mooncake-store/src/ha/snapshot/batch_oplog/batch_oplog_snapshot_coordinator.cpp \
  mooncake-store/tests/ha/snapshot/batch_oplog/coordinator_test.cpp

Test results:

  • Unit tests pass
  • Integration tests pass (not applicable; N08 owns production/E2E wiring)
  • Manual testing done

The coordinator test passed 2/2 tests. Existing batch snapshot writer passed 6/6, provider 5/5, publisher 12/13 with the real-etcd case skipped because no local etcd endpoint was available, and HotStandbyService passed 31 tests with 14 existing etcd-dependent cases skipped.

Checklist

  • I have performed a self-review of my own code
  • I have formatted my code using ./scripts/code_format.sh
  • I have run pre-commit on the files changed in this PR and all hooks pass
  • I have updated the documentation (not applicable; production wiring is intentionally deferred to N08)
  • I have added tests to prove my changes are effective
  • For changes >500 LOC: I have filed an RFC issue

The implementation follows the PR-N06 snapshot coordinator design spec; add the corresponding RFC/issue link here if the maintainer requires one for this development branch.

AI Assistance Disclosure

  • No AI tools were used
  • AI tools were used (implementation and test drafting assistance)

The human submitter must review every changed line and be able to explain and defend the coordinator lifecycle, promotion/stop behavior, lease fencing, and test coverage.

@Icedcoco
Icedcoco marked this pull request as ready for review September 1, 2026 02:16

@Aionw Aionw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ykwd
ykwd merged commit 82a90a9 into kvcache-ai:main Sep 1, 2026
40 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants