Skip to content

[Store] Add V6 object write generations, SSD task fencing, and HA durable retirement - #5791

Draft
MaskVulcan wants to merge 8 commits into
kvcache-ai:mainfrom
MaskVulcan:ssd/pr5-v6-generation-and-ha
Draft

MaskVulcan wants to merge 8 commits into
kvcache-ai:mainfrom
MaskVulcan:ssd/pr5-v6-generation-and-ha

Conversation

@MaskVulcan

@MaskVulcan MaskVulcan commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Part 5 of 5 in the SSD Offload series tracked in RFC #5768.

Independent PR directly based on main (orthogonal to PR 1–4; consolidates earlier drafts #5774 and #5775 together with generation wire codec, SSD task fencing, and HA durable retirement).

Summary

Adds object write-generation fencing and HA durability hardening for native SSD offload so stale offload/promotion tasks, same-key overwrites, local restarts, and HA failovers cannot resurrect deleted or overwritten data:

  1. Ordered OpLog callback finalization (ordered_oplog_writer.*): separates durable log advancement from completion callback finalization so synchronous retirement waits for callbacks cleanly.
  2. Atomic bucket metadata publication (storage_backend.*): publishes SSD bucket metadata via temp file + fsync + atomic rename + directory fsync, with failpoint restart tests.
  3. Compatible generation wire fields & physical SSD key codec (offload_storage_key.h, replica.h, object_metadata.h, rpc_types.h, HA standby/metadata structs): uses struct_pack::compatible fields so wire structs remain backwards-compatible while scoping physical SSD records by object generation.
  4. Bucket carryover flush & BatchQueryReadOnly hook (storage_backend.*, file_storage.*, client_service.*): retains ungrouped partial offload batches cleanly across heartbeats without losing pending task accounting on cancellation/wipe.
  5. Primary write generations, SSD task fencing, and HA durable retirement (master_service.*, file_storage.*, real_client.*, client_service.*, docs/source/design/store/ssd-generations.md): enforces generation authority on offload/promotion/eviction/restore, rejects resurrection of REMOVED replicas, releases unallocated from_prefetch slots on promotion failure under DRAM pressure, and documents the deployment/upgrade contract.

Size & Scope

  • 5 linear commits on main, 75 files (+2604/-912 prod, +7230/-1895 tests, +91 docs).
  • Zero Transfer Engine / TENT / Owner-Push dependencies; can be reviewed and merged independently of PR 1–4.

Series Overview (RFC #5768)

Part PR Scope Dependency
TE Fix (c) #5855 Compare tcp_proto_version in SegmentDesc::operator== Independent (main)
TE Fix (b) #5856 Serialize unpooled TCP initiation on socket executor & track shutdown Independent (main)
PR 1 #5773 Route-driven TransferEngine::submitReceiverVisibleWrite() & Status::ProtocolUnsupported (classic TCP v2 opt-in) Independent (main)
PR 2 #5788 Bounded local SSD streaming read pipeline & optional io_uring workers Independent (main)
PR 3 #5789 TCP owner-push SSD read engine & FileStorage::ReadOwnerStreaming Depends on #5773 + #5788
PR 4 #5790 Hardened HMAC-SHA256 control RPC, peer directory, RealClient & Python _store Depends on #5789
PR 5 #5791 (this PR) V6 object write generations, SSD task fencing & HA durable retirement Independent (main)

Local Validation

  • 20+ CTest suites 100% PASS: ssd_generation_codec_test, ssd_generation_master_test, storage_backend_test, file_storage_config_test, file_storage_promotion_test, master_service_ha_test, master_metrics_test, master_service_ssd_test, master_service_ssd_scenario_test, master_service_offload_scenario_test, prefetch_task_master_test, ranged_disk_lease_test, oplog_applier_test, oplog_batch_codec_test, oplog_batch_auditor_test, oplog_batch_standby_reader_test, oplog_batch_storage_test, oplog_types_test, batch_oplog_snapshot_codec_test, batch_oplog_snapshot_promotion_test (plus prior full V6 integration passes on pybind_client_test, client_integration_test, file_storage_test, master_service_test, promotion_on_hit_test, and Sphinx -W).
  • Formatting, spelling & DCO: clang-format 20.1.8 0 diff, typos 1.30.2 0 issues, DCO verified.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add the length-delimited physical SSD storage-key codec
(offload_storage_key.h) and forward/backward-compatible
struct_pack::compatible generation/task fields on RPC and HA metadata
payloads (LocalDiskDescriptor, Replica::Descriptor, ObjectMeta,
GetReplicaListResponse, PromotionAllocStartResponse, OffloadTaskItem,
PromotionTaskItem, StandbyObjectMetadata, MetadataPayload).

Purely additive wire and codec foundation with zero runtime behavior
change; includes round-trip codec and legacy-vs-new struct_pack
serialization compatibility tests.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
… offload

Extend BucketStorageBackend and StorageBackendInterface with a BatchQuery
hook, an UngroupedOffloadingObjects accessor, and an explicit
flush_previous_carryover option so FileStorage can retain generation-scoped
OffloadTaskItems across bucket grouping cycles without dropping tasks.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
…urable retirement

Implement the generation-scoped SSD recovery and HA retirement stage of
RFC kvcache-ai#5768 on top of the compatible wire/codec foundation and prerequisites
- Mint per-write generations on PutStart/UpsertStart and enforce matching
  captured grants on PutEnd/PutRevoke and batch/session variants.
- Key SSD offload records with length-delimited generation storage keys,
  fence offload and promotion completion/failure notifications by object
  generation and task_id (allowing holder release of unallocated prefetch
  tasks), and prevent stale scans from resurrecting deleted/removed objects.
- Wait for ordered OpLog durability and callback finalization before
  retiring overwritten/removed allocations in HA mode, bounded by
  oplog_durable_wait_timeout_ms.
- Add docs/source/design/store/ssd-generations.md, unit/integration tests,
  and adapt existing tests to forward captured primary write grants.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
…restore, and legacy fallback

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
@MaskVulcan
MaskVulcan force-pushed the ssd/pr5-v6-generation-and-ha branch from 572f683 to 4f6203f Compare November 26, 2026 05:23
…te metrics test

- Update SsdPrefetcher::TriggerPrefetch() and RunLocalPrefetch() to resolve the active LOCAL_DISK replica's physical storage_key (falling back to the logical key for legacy masters) before calling FileStorage::LookupLocalObjectSize(), fixing SSD prefetch-on-exist and demand-kick promotion under V6 generation keys.
- Update master_metrics_test.cpp to call WrappedMasterService::PutRevokeV2() / BatchPutRevokeV2() for ObjectMeta requests and initialize ObjectMeta::write_generation.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Resolve merge conflicts with kvcache-ai#5711 (bucket reclaim) in file_storage.cpp and file_storage_test.cpp, and make FileStorage::FindDeadKeys() and FileStorageReclaimTest V6 physical storage_key / generation-aware so live V6 buckets are preserved while removed or superseded generations are reclaimed.

Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation run-ci size/L 1001+ changed lines (additions + deletions) Store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant