Skip to main content

v0.2 → v1.0 迁移指南 / v0.2 → v1.0 Migration Guide

发布状态 / Release Status

v1.0.0 是第一个稳定 MAJOR 版本。本页覆盖正式 v0.2.0 → v1.0.0;后续 1.x 遵循标准 Semantic Versioning。

v1.0.0 is the first stable MAJOR release. This page covers the released v0.2.0 → v1.0.0 path; subsequent 1.x releases follow standard Semantic Versioning.

部署迁移边界 / Deployment Migration Boundary​

不要原地滚动或全停后恢复 / No In-Place Rolling or Full-Stop Restore

正式 stock v0.2.0 的 Raft 日志只在内存中,单节点 data_dir 离线备份不包含完整 Raft 日志,不能独立重建原集群。 本版本不提供通用 in-place 滚动升级或 backup/restore 迁移承诺。不要先停止全部旧节点,也不要把旧备份恢复到空 data_dir 后假设集群可以重建。

The released stock v0.2.0 keeps Raft logs in memory. A single-node offline data_dir backup omits the complete Raft log and cannot independently reconstruct the cluster. v1.0.0 does not claim a generic in-place rolling or backup/restore migration path. Never stop every old node first or assume that restoring an old backup into an empty data_dir recreates the cluster.

支持的通用路径是 side-by-side 应用迁移:保持旧集群在线和健康,在不同集群名、端口、etcd 命名空间和数据目录 中建立新的 v1.0.0 集群,由应用导出并重放业务数据,验证后切换客户端。Rr 的应用 payload 对框架是不透明字节, 因此业务导出/导入必须由应用的 Service 或专用工具实现。

The supported generic path is side-by-side application migration. Keep the old cluster online and healthy, create a separate v1.0.0 cluster with a different cluster name, ports, etcd namespace, and data directories, then export and replay application data before switching clients. Rr treats application payloads as opaque bytes, so export/import belongs to the application's Service or a dedicated application tool.

自定义 v0.2 部署若另有持久化 Raft 日志和经过验证的滚动流程,应使用自己的运行手册;本页不覆盖该非 stock 形态。

Custom v0.2 deployments with separately durable Raft logs and a validated rolling procedure must follow their own runbook; this page does not cover that non-stock shape.

Side-by-Side 步骤 / Side-by-Side Procedure​

  1. 固定依赖。 所有 Rust crate 使用 v1.0.0,Java SDK 使用 1.0.0,并按 外部项目引入指南 添加同 tag 的 openraft [patch.crates-io]。提交 lockfile, 用 cargo tree -i openraft 确认补丁来源。

  2. 保持旧集群可用并停写。 确认健康 leader、完整 voter 集合和客户端读取正常,停止 membership、快照清理和 其他非必要管理变更。本指南采用停写迁移:在最终导出前 fence 旧集群的全部业务写入,并在导出、导入、验证和 切换期间始终保持 fence;旧集群进程继续运行并提供读取。在线双写/变更捕获需要另一份经过验证的专用运行手册。

  3. 准备独立新集群。 按 部署指南 和 Kubernetes 指南 使用 Genesis 建立全新 v1.0.0 集群。不要对旧集群运行 Genesis,不要复用旧集群名、lifecycle 记录或数据目录。

  4. 迁移应用数据。 在写 fence 生效后,通过线性一致读取或应用定义的一致性快照执行最终导出,记录明确的 导出水位;再向新集群导入。记录条目数、校验和及失败重试。不得在导出后放开旧集群写入;框架没有通用业务 数据导入器。

  5. 验证并切换。 对比新旧集群的业务读取、数据量、校验和、leader/voter、/ready 和客户端错误率。只有 新集群完整导入并追平最终导出水位后,才解除客户端写屏蔽并只向新集群写入;旧集群继续保持写 fenced。

  6. 保留回退能力。 在整个回退窗口内,旧集群必须保持运行、可读且写 fenced。只有明确关闭回退窗口后才能停止 旧集群;停止后的离线备份只用于取证,不能作为 stock v0.2.0 的独立 Raft 恢复归档。

  7. Pin dependencies. Use v1.0.0 for every Rust crate and 1.0.0 for the Java SDK, with the same-tag openraft [patch.crates-io] from the consumer guide. Commit the lockfile and verify the patch source with cargo tree -i openraft.

  8. Keep the old cluster available and stop writes. Verify a healthy leader, the complete voter set, and normal client reads. Pause membership changes, snapshot cleanup, and other nonessential administration. This guide uses a stop-write migration: fence every application write before the final export and keep that fence through export, import, validation, and cutover. Old-cluster processes remain running and readable. Online dual-write/change capture requires a separately validated runbook.

  9. Prepare an independent new cluster. Use Genesis from the deployment guide and Kubernetes guide. Never run Genesis against the old cluster or reuse its cluster name, lifecycle records, or data directories.

  10. Migrate application data. After the write fence is effective, take the final export through linearizable reads or an application-defined consistent snapshot and record its explicit watermark. Import into the new cluster and record item counts, checksums, and retry failures. Never reopen old-cluster writes after export. Rr has no generic business-data importer.

  11. Validate and cut over. Compare application reads, item counts, checksums, leader/voters, /ready, and client error rates. Only after the new cluster has imported and caught up with the final export watermark, unblock client writes exclusively to the new cluster. The old cluster remains write-fenced.

  12. Retain rollback capability. Throughout the rollback window, keep the old cluster running, readable, and write-fenced. Stop it only after explicitly closing that window. Offline backups taken after shutdown are for forensics, not standalone stock-v0.2.0 Raft recovery archives.

持久化格式 / Durable Formats​

正式 v0.2.0 不包含 SnapshotStore,不会生成 sm-snapshot.bin 或 sm-membership.bin,因此正式 tag 之间的迁移 不需要处理这两个文件。v1.0.0 在新集群中使用带 magic/version 的 \0rrPST01 和 \0rrMBR01 envelope。

The released v0.2.0 has no SnapshotStore and does not produce sm-snapshot.bin or sm-membership.bin, so the released-tag migration has no such files to convert. v1.0.0 creates \0rrPST01 and \0rrMBR01 magic/version envelopes in the new cluster.

只有运行过正式 tag 之间的 interim 构建时才可能存在旧裸文件。这类部署不在本指南覆盖范围内;不要套用通用 node-reset 或删除快照步骤,应根据实际 commit、日志持久化方式和应用恢复能力制定专用运行手册。

Only interim builds between released tags may contain legacy raw files. Such deployments are outside this guide. Do not apply generic node-reset or snapshot-deletion steps; create a specific runbook based on the actual commit, log persistence, and application recovery capability.

Rust API 变更 / Rust API Changes​

DurabilityPolicy 旧别名已删除 / Legacy DurabilityPolicy aliases removed​

Balanced 和 Fast 已删除,配置字符串 balanced 和 fast 也不再接受。分别改用 ReplicatedOnly / replicated_only 和 TestOnly / test_only。生产默认并保持 Strict / strict。

Balanced and Fast have been removed, as have the balanced and fast configuration strings. Use ReplicatedOnly / replicated_only and TestOnly / test_only. Production should keep Strict / strict.

线性一致读结果使用显式枚举 / Linearizable read results are an explicit enum​

LinearizableReadResult 现在区分 Served(payload) 和 NotLeader { leader_node_id, leader_addr },不再把 leader-unknown 表示成可能伪装成成功的空 payload。直接实现 ClientDispatch 或匹配该类型的下游代码必须处理 两个枚举分支;只使用 RrClient 的调用方无需改动。

LinearizableReadResult now distinguishes Served(payload) from NotLeader { leader_node_id, leader_addr } instead of representing an unknown leader as an empty payload that could look successful. Downstream implementations of ClientDispatch and direct matches on this type must handle both variants. Callers using only RrClient need no change.

Admin descriptor 字段改名 / Admin descriptor field rename​

NodeDescriptorResponse.descriptor 和 NodeDirectoryEntry.descriptor 改名为 node_descriptor,以避免 Java protobuf 生成的 getDescriptor() 冲突。字段号 1 和 wire 编码不变;使用生成 Rust 结构体的调用方需要改字段名。

NodeDescriptorResponse.descriptor and NodeDirectoryEntry.descriptor are now node_descriptor, avoiding Java protobuf's generated getDescriptor() collision. Field number 1 and the wire encoding are unchanged; callers using the generated Rust structs must update the field name.

错误类型与字段 / Error types and fields​

  • RaftNode::init_single_node 返回 RrError;删除旧的 Box<dyn Error> 特殊处理。

    RaftNode::init_single_node returns RrError; remove legacy Box<dyn Error> handling.

  • RouterError::GroupNotFound 已删除;删除对应 match 分支。

    RouterError::GroupNotFound was removed; delete its match arm.

  • 相关错误字段使用 NodeId、GroupId、PartitionId 类型别名,而非在下游签名中写裸 u64。

    Related error fields use the NodeId, GroupId, and PartitionId type aliases instead of bare u64 names in downstream signatures.

rr_core::codec::Codec / BincodeCodec 和 RrClient::channel_pool() 仍处于 deprecated,并非本次删除项。 不可信字节应使用 bounded/frame decoder。

rr_core::codec::Codec / BincodeCodec and RrClient::channel_pool() remain deprecated, not removed in this release. Use bounded/frame decoders for untrusted bytes.

配置与行为变更 / Configuration and Behavioral Changes​

  • Admin 和 metrics 默认 bind 改为 127.0.0.1。远程 Admin 或 Prometheus 必须显式设置合适的 admin_bind_host / metrics_bind_host,并同时配置网络访问控制;不要为图方便无条件暴露到公网。

    Admin and metrics now bind to 127.0.0.1 by default. Remote Admin or Prometheus requires an explicit appropriate admin_bind_host / metrics_bind_host plus network access control; do not expose either publicly for convenience.

  • GetMetricsSummary 返回 UNIMPLEMENTED,不再返回恒零伪数据;SnapshotStatus.snapshot_in_progress 恒为 false。改用 Prometheus /metrics 和 last_snapshot_index / last_snapshot_term。

    GetMetricsSummary returns UNIMPLEMENTED instead of constant zeros; SnapshotStatus.snapshot_in_progress is always false. Use Prometheus /metrics and last_snapshot_index / last_snapshot_term.

  • 自动 learner promotion 默认开启。需要人工控制时显式设置 auto_promote_learners = false,并在成员变更后核对 完整 voter 集合。

    Automatic learner promotion is enabled by default. Set auto_promote_learners = false for manual control and verify the complete voter set after membership changes.

  • rps = 0、grpc_max_frame_size = 0、超过 MAX_ENTRY_BODY 的 frame,以及 grpc_max_concurrent_streams = Some(0) 会被拒绝。修正自定义 embedder 和限流配置。

    rps = 0, zero or oversized gRPC frames, and grpc_max_concurrent_streams = Some(0) are rejected. Correct custom embedder and rate-limit configurations.

  • Kafka topic_pattern 必须包含 {group_id};enable.auto.commit 固定为关闭,auto_commit_interval 是 deprecated no-op。多个 group 不得共享同一输入 topic。

    Kafka topic_pattern must contain {group_id}; enable.auto.commit is pinned off and auto_commit_interval is a deprecated no-op. Multiple groups must not share one input topic.

  • MemConfigProvider.remove_node 会移除 dangling group replicas;冲突的 add_partition 会覆盖并告警。 依赖旧静默行为的测试和工具需要更新。

    MemConfigProvider.remove_node strips dangling group replicas and conflicting add_partition calls overwrite with a warning. Update tests and tools that relied on the old silent behavior.

  • Console 新客户端应使用 /api/v1/console/connections 和 /api/v1/console/connections/{id}/...。旧启动参数仍映射到一个临时连接;无该连接时旧数据路由返回 CONNECTION_REQUIRED。秘密字段 write-only,部署需为 --state-dir 提供持久、独占、可写目录。

    New Console clients should use /api/v1/console/connections and /api/v1/console/connections/{id}/.... Legacy startup flags map to one ephemeral connection; without it, legacy data routes return CONNECTION_REQUIRED. Secret fields are write-only, and deployments must provide a persistent, exclusive, writable --state-dir.

新增能力的采用 / Adopting New Capabilities​

Durable Raft log、managed Genesis/Adopt、client write batching、多 group、deferred response 和多连接 Console 均有显式配置或 opt-in 边界。不要因为升级到 1.0.0 就默认开启批处理、放宽 durability,或把 SeedSpec 当成当前

Raft membership。

Durable Raft logs, managed Genesis/Adopt, client write batching, multiple groups, deferred responses, and the multi-connection Console have explicit configuration or opt-in boundaries. Upgrading to 1.0.0 does not require enabling batching, relaxing durability, or treating SeedSpec as current Raft membership.

回退 / Rollback​

Side-by-side 回退必须让旧集群保持运行、可读、写 fenced 并保留原始目录,同时在切回前 fence 新集群写入。新集群 一旦接受未反向同步的写,就不能直接切回旧集群;需要应用级反向同步或明确的丢失/冲突裁决。旧集群若已停止,其 内存 Raft 日志已经丢失,不再支持通用直接回退。不要把 v1.0.0 数据目录交给 v0.2.0。

Side-by-side rollback requires the old cluster to remain running, readable, write-fenced, and on its original directories, with new-cluster writes fenced before cutback. Once the new cluster accepts writes that were not synchronized back, direct cutback is unsafe; use application-level reverse synchronization or an explicit loss/conflict decision. If the old cluster has stopped, its in-memory Raft log is lost and generic direct rollback is no longer supported. Never give a v1.0.0 data directory to v0.2.0.

回退前还必须停止 client write batching。旧二进制会把 \0rrBAT01 批帧当作一条不透明 payload,也不能读取 v1.0.0 envelope 快照。

Disable client write batching before any rollback. Old binaries treat \0rrBAT01 batch frames as one opaque payload and cannot read v1.0.0 enveloped snapshots.