Repository navigation
[RFC]OpenViking 多存储介质 V2版本:分区化元数据与异步备份架构/OpenViking Multi-Write V2: Partitioned Metadata and Async Backup Architecture
#5863
Closed
baojun-zhang
started this conversation in
RFC
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
中文版 / Chinese Version
🔍 待评审事项
以下内容已在设计中收敛,本 Discussion 只保留整体架构和关键取舍:目录级 sidecar 淘汰、Checkpoint + Segment、provider 抽象、目录事件按状态通知处理。
Context
当前 OpenViking 多存储介质元数据使用“每目录一个 sidecar + 全局
next_seq”的模式。这个模式在大规模文件场景下有明显上限:
next_seqV2 的目标是把同步状态从“目录维度”改成“account 内部分区维度”。
1. 目标与非目标
目标:
10^9文件量级的多存储介质元数据管理。非目标:
2. 关键约束
V2 的第一条边界是:多存储介质元数据只存 primary。
这些路径不复制到 backup:
这意味着:
V2 追求的是:primary 主流程不被多存储介质拖慢,backup 最终收敛。
3. 架构概览
V2 把一个 account 的多存储介质元数据拆成固定物理分区。每个 partition 使用两类数据:
SegmentWrite、Remove、RemoveTree、MoveTree。Checkpoint核心目录形态:
运行时组件:
FlushWorkerCatchUpWorkerCheckpoint TaskGC前台写入流程:
ACK 不等待事件入队、Segment 持久化、backup 写入或 checkpoint 生成。
4. 分区与序列
每个文件使用完整的 mount-relative path 作为 hash 输入:
关键点:
VBUCKETS固定为65536,不是用户配置。initial_partitions只在 account 首次初始化时生效,默认16。V2 不再使用全局裸
u64序号。每个 partition 有自己的序列空间:判断某个 backup 是否追平某个状态时,必须先比较
scope,再比较seq。不同 scope 的 seq 禁止直接比较。5. 目录语义与追平
V2 把事件视为“状态失效通知”,不是历史命令。
普通文件事件:
Write(path):backup 读取 primary 当前内容并写入。Remove(path):如果 primary 当前不存在,则从 backup 删除。Write(new_path)+Remove(old_path)。目录事件:
目录删除和目录移动不会展开子文件。V2 给每个 partition 写一条 marker,后台按 primary 当前前缀状态对齐 backup。
这样单次目录操作的元数据成本是
O(partition_count),不是O(descendant_files)。CatchUpWorker 每轮按 partition 处理:
synced_seq和当前tail_seq。backend_states[backend_id].synced_seq。6. Provider、配置与迁移
MultiWriteProvider只负责单个 partition 的段存储:next_seq、sealed 段摘要、backend_states.ovsg、Checkpoint、Partitions Manifest本期 provider:
filesystemcache用户可感知配置:
initial_partitions16checkpoint_interval_secs86400providerfilesystemV2 固定异步,废弃旧同步状态能力:
system_sync_status、system_sync_retry。/api/v1/system/backend/sync-status、sync-retry、/api/v1/system/sync/{path}等接口。ov system backend sync-status、ov system backend sync-retry。数据迁移使用:
启动行为:
V2/migrating,启动全量导入。V2/migratingV2/stable全量导入只把 primary 当前存在的文件按正常
Write事件写入分区化 Segment。导入中断后重跑允许重复Write,后续 checkpoint 会自然折叠。7. 风险与边界
cacheprovider 的 head /backend_states可能丢失;不承诺误清后的自动无损恢复。initial_partitions不触发扩容。8. 总结
V2 的核心取舍是:牺牲旧版同步写入和目录级状态接口,换取更简单的 primary 主路径和可扩展的元数据结构。
最终模型:
请重点评审:
English Version / 英文版
🔍 Review Items
This Discussion only keeps the architecture and key tradeoffs: directory sidecars are removed, metadata becomes Checkpoint + Segment, providers are abstracted, and directory operations become state notifications.
Context
The current OpenViking multi-write metadata model is based on “one sidecar per directory + one global
next_seq”.This has clear limits at large file scale:
next_seqV2 moves sync state from “directory scope” to “account-local partition scope”.
1. Goals and Non-goals
Goals:
10^9file scale.Non-goals:
2. Key Constraint
The first V2 boundary is: multi-write metadata lives only on primary.
These paths are not replicated to backups:
This means:
V2 optimizes for: primary path stays fast, backups eventually converge.
3. Architecture Overview
V2 splits each account’s multi-write metadata into fixed physical partitions. Each partition uses two data types:
SegmentWrite,Remove,RemoveTree, andMoveTree.CheckpointCore layout:
Runtime components:
FlushWorkerCatchUpWorkerCheckpoint TaskGCForeground write flow:
ACK does not wait for event enqueue, Segment persistence, backup write, or checkpoint generation.
4. Partitioning and Sequence
Each file uses the full mount-relative path as hash input:
Key points:
VBUCKETSis fixed to65536; it is not user-configurable.initial_partitionsonly applies when an account is first initialized. Default is16.V2 no longer uses one global bare
u64sequence. Each partition has its own sequence space:To decide whether a backup has caught up with a state, compare
scopefirst andseqsecond. Sequences from different scopes must not be compared directly.5. Directory Semantics and Catch-up
V2 treats events as “state invalidation notifications”, not historical commands.
Normal file events:
Write(path): backup reads primary current content and writes it.Remove(path): if primary current state does not exist, backup removes it.Write(new_path)+Remove(old_path).Directory events:
Directory delete and directory move do not expand descendant files. V2 writes one marker per partition, and background workers reconcile backup from primary current prefix state.
This makes metadata cost for one directory operation
O(partition_count), notO(descendant_files).Each CatchUpWorker round handles partitions independently:
synced_seqand currenttail_seq.backend_states[backend_id].synced_seqfor this partition.6. Provider, Config, and Migration
MultiWriteProvideronly owns per-partition segment storage:next_seq, sealed segment descriptors,backend_states.ovsg, Checkpoints, Partitions ManifestProviders in this phase:
filesystemcacheUser-visible configs:
initial_partitions16checkpoint_interval_secs86400providerfilesystemV2 is always async and removes legacy sync status management:
system_sync_statusandsystem_sync_retry./api/v1/system/backend/sync-status,sync-retry,/api/v1/system/sync/{path}, and related APIs.ov system backend sync-statusandov system backend sync-retry.Data migration uses:
Startup behavior:
V2/migrating, then start full import.V2/migratingV2/stableFull import writes existing primary files into partitioned Segment as normal
Writeevents. If import is interrupted and retried, duplicateWriteevents are allowed and later checkpoints fold them naturally.7. Risks and Boundaries
cacheprovider, head /backend_statesmay be lost; automatic lossless recovery is not promised.initial_partitionsdoes not trigger expansion.8. Summary
V2 trades legacy synchronous writes and directory-level status APIs for a simpler primary path and scalable metadata layout.
Final model:
Please review:
All reactions