From 875a371f6bab7a4a459ddabaeee4f738be702600 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Nov 2026 19:20:50 +0000 Subject: [PATCH 1/5] Consolidate status wording from docs PRs 27-31 Describe Baidu production figures and the listdir P99 as paper data, not results of this tree. Label the status matrix by design claim, crate test, or missing multi-process rehearsal, and stop describing role-split Stage 3 or jumbo host moves as something this binary does. Record the checked-in Format timeout of 90 minutes and the package timeout of 45 minutes without saying workflows are enabled. Co-authored-by: RustFS --- Architecture.md | 94 ++++++++++++++++--------- README.md | 52 +++++++------- docs/en/ci-and-release-gates.md | 12 ++-- docs/en/operations.md | 2 +- docs/guides/de/deployment.md | 35 +++++---- docs/guides/de/operations-and-tuning.md | 2 +- docs/guides/en/README.md | 29 ++++---- docs/guides/en/deployment.md | 47 +++++-------- docs/guides/fr/deployment.md | 35 +++++---- docs/guides/fr/operations-and-tuning.md | 2 +- docs/guides/ja/deployment.md | 37 ++++++---- docs/guides/ja/operations-and-tuning.md | 2 +- docs/guides/zh/deployment.md | 58 ++++++++------- docs/guides/zh/operations-and-tuning.md | 2 +- 14 files changed, 223 insertions(+), 186 deletions(-) diff --git a/Architecture.md b/Architecture.md index 0140912..918ff53 100644 --- a/Architecture.md +++ b/Architecture.md @@ -17,7 +17,7 @@ Modern exabyte-scale storage systems—including flat object storage (S3/BOS), h **MetaDB** (`rustfs/MetaDB`) is a 100% pure-Rust, file-system structure-aware, semantic-aware, and lifecycle-aware transactional metadata database engine built for [RustFS](https://github.com/rustfs). It is engineered across an 8-crate workspace to support **seamless online evolution from an embedded or standalone single-node deployment (`1-Voter` OpenRaft) to a multi-cell distributed cluster (`3-Voter` Multi-Raft) designed to scale from single-host workloads to 100 billion – 10+ trillion metadata records.** > **Distinguishing Reference Benchmarks from Repository Status**: -> Production scale figures cited from `arXiv:2610.32247v1` (e.g., Baidu's 575-node BOS2 cluster managing 1.848 trillion records) represent empirical results from Baidu's production C++ deployment validating this architecture. `rustfs/MetaDB` is an independent clean-room Rust implementation whose milestone-by-milestone implementation status is tracked transparently in [Section 12](#12-implementation-status-matrix-paper-vs-repository) and [`docs/DEVELOPMENT_PLAN.md`](./docs/DEVELOPMENT_PLAN.md). +> Production scale figures cited from `arXiv:2610.32247v1` (for example, Baidu's 575-node BOS2 cluster managing 1.848 trillion records) are Baidu production metrics, not results of this repository. `rustfs/MetaDB` is an independent clean-room Rust implementation. This document is not a first-launch acceptance record and not a scale-gate record. Status wording is in [Section 12](#12-implementation-status-matrix-paper-vs-repository). Operator behavior on current `main` is in [`docs/en`](./docs/en/README.md). --- @@ -118,7 +118,7 @@ flowchart TB * Each shard owns a `CompositeKeyRange` `[start_key, end_key)` versioned by `ShardEpoch { conf_ver, version }`. Every RPC carries `expected_epoch`; stale routes are fenced both pre-proposal and inside `RaftStateMachine::apply` (`MetaDbError::EpochMismatch`). * When shard size crosses `shard_split_threshold_bytes` (`4 GiB` production default), `PolicyShardSplitter` scans SSTable block-index midpoints (without reading values) to select a clean `PID` boundary `split_pid`, executing a deterministic `RaftCmd::ExecuteSplit` across replicas. 2. **Two-Level Jumbo Shard Defense (`JumboIsolated` + `DualModeFineGrained`)**: - * *Level 1 — Dedicated Node Isolation*: When a single directory dominates `>80%` of an oversized shard (`UnsplittableJumboShard`), `CellLocalManager` transitions the shard to `JumboIsolated`, migrating co-hosted peer shards off that BE node so the jumbo directory gets dedicated CPU and NVMe bandwidth. + * *Level 1 — Route flag, not a host move*: When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent (`crates/metadb-cluster/src/split_worker.rs`), `maybe_split_or_isolate_shard` stores `ShardHealthState::JumboIsolated { dedicated_node, dominant_pid }` on the route. `JumboIsolationPlanner::select_dedicated_node` picks a node id already registered in this cell. It does not move shard directories and does not migrate co-hosted peer shards off a host. With only the bootstrap node registered, the flag names this process. * *Level 2 — Dual-Mode `(PID, name)` Split Fallback*: If a single directory outgrows a dedicated node, policy or `metadb-ctl` switches that `PID` to `DualModeFineGrained`, splitting along `(PID, split_name)` boundaries. Non-anchor sub-shards maintain shard-local `DirShardDelta` (`[0x04][pid: 8B BE]`) records initialized at split time: * `create_file` and `unlink` remain **lock-free `1-RTT` single-shard operations** on `route_composite(pid, name)`. * `dirstat(pid)` performs a `1-hop` parallel scatter-gather across the `K` sub-shards covering `[pid, pid+1)`, summing reconciled `num_children` and `size_bytes` and taking `max(modify_time)`. @@ -151,49 +151,62 @@ flowchart TB * Sealed `ImmMemTable`s wait until `min_active_snapshot_hlc >= imm.max_hlc`, then write **only** the collapsed latest value (`Put`) or a single unversioned physical LSM `Delete` tombstone to a generation-ordered (`flush_generation`) L0 SSTable—mathematically preventing phantom/future-read anomalies while eliminating persisted MVCC tombstones (`~60%` fewer KV writes). 3. **Bottommost-Safe Locality-Aware Compaction (`LocalityCompactor`)**: * Tracks physical tombstone counts and tombstone-to-live ratios per 9-byte `[table_prefix][group_key: 8B]` spatial bucket. - * When a bucket crosses `tombstone_density_threshold` (e.g., consecutive TTL expirations), `LocalityCompactor` triggers a targeted range compaction over `[bucket, bucket + 1)` spanning all overlapping SSTables down to the bottommost level for that range—legally dropping physical tombstones without rewriting cold neighboring directories and keeping `listdir` P99 latency flat (`<4ms`). + * When a bucket crosses `tombstone_density_threshold` (e.g., consecutive TTL expirations), `LocalityCompactor` triggers a targeted range compaction over `[bucket, bucket + 1)` spanning all overlapping SSTables down to the bottommost level for that range—legally dropping physical tombstones without rewriting cold neighboring directories. A flat `listdir` P99 under `<4ms` is a design target in `arXiv:2610.32247v1`, not a measured result of this repository. Latency numbers from the earlier single-node comparison on commit `f325f6a` are not results for this tree and are not repeated here. --- -## 6. Capacity & Trillion-Scale Verification (`100M` to `10T+` Records) +## 6. Capacity Model (`100M` to `10T+` Records) -### 6.1 Reference Production Proof (`arXiv:2610.32247v1`, Table 1) -Baidu's production clusters validate the horizontal scalability of this exact architecture: -* **BOS2 Cluster**: **575 BE nodes**, **1.848 trillion (`1.848 × 10^12`) metadata records**, **909 PB** backing storage, sustaining **2.063M read QPS** and **747K write QPS**. -* **BOS1 & BOS3 Clusters**: **414** and **406 BE nodes** managing **1.343T** and **1.356T** records respectively. -* **Hardware Efficiency**: Cuts metadata server count by `~50%` while delivering `2.2x–4.1x` higher throughput than general-purpose distributed SQL baselines. +This section is not a verification of `rustfs/MetaDB`. Trillion-scale figures in §6.1 are Baidu production metrics from `arXiv:2610.32247v1`, not results of this repository. §6.2 is an arithmetic model from the assumptions stated there. It is not a load measurement, and it is not a first-launch or trillion-scale milestone. This repository has not stored a trillion-record dataset and has not published a trillion-scale benchmark. -### 6.2 Quantitative Capacity Model for `rustfs/MetaDB` +### 6.1 Baidu Production Figures (`arXiv:2610.32247v1`, Table 1) + +The following figures are Baidu's published production results. They do not measure this repository, and they do not describe a cluster this tree has run: + +* **BOS2 cluster (Baidu)**: **575 BE nodes**, **1.848 trillion (`1.848 × 10^12`) metadata records**, **909 PB** backing storage, sustaining **2.063M read QPS** and **747K write QPS**. +* **BOS1 and BOS3 clusters (Baidu)**: **414** and **406 BE nodes** managing **1.343T** and **1.356T** records respectively. +* **Hardware comparison in the paper**: For that Baidu deployment, the paper reports cutting metadata server count by `~50%` while delivering `2.2x–4.1x` higher throughput than the general-purpose distributed SQL baselines in that study. That comparison is Baidu's, not a result of `rustfs/MetaDB`. + +### 6.2 Quantitative Capacity Model (Design Arithmetic) + +The rows below multiply the assumptions in this paragraph. They were not measured on this repository. The `100B`, `1T`, and `10T` rows assume role-trimmed BE fleets and multiple cells. `open_and_serve` rejects those roles, and `RegisterCell` does not create another cell. Assuming `~180 B` average prefix-compressed record footprint across primary + auxiliary tables, `4 GiB` target shard size, `10 bits/key` Bloom filter (`~1.25 B/key`), and sparse 4 KiB block index (`~12 B / 4 KiB` block $\approx 0.54\text{ B/key}$): -| Scale Tier | Total Records | Logical KV Footprint | 3-Replica NVMe Footprint | Shards (@ 4 GiB) | Per-Node RAM (Bloom + Index + MVCC) | Target Cluster Topology | +| Scale Tier | Total Records | Logical KV Footprint | 3-Replica NVMe Footprint | Shards (@ 4 GiB) | Per-Node RAM (Bloom + Index + MVCC) | Design Topology (Not Deployed Here) | | :--- | :--- | :--- | :--- | :--- | :--- | :--- | | **Stage 1: Single-Node** | `100M` (`10^8`) | `~18 GB` | `~18 GB` (`1-Voter`) | `5 – 16` | `< 2 GiB` (`~180 MB` index/Bloom) | **1 `metadbd` Node** (`all-in-one`) | | **100 Billion (`10^11`)** | `100B` | `~18 TB` | `~54 TB` (`3-Voter`) | `~4,500` | `~32 GiB / node` across 20 BE nodes | **1 Cell** (`20 BE nodes`) + `MetaCache` | | **1 Trillion (`10^12`)** | `1T` | `~180 TB` | `~540 TB` (`3-Voter`) | `~45,000` | `~48 GiB / node` across 160 BE nodes | `GlobalManager` + **4 Cells** (`160 BE nodes`) | | **10 Trillion (`10^13`)** | `10T` | `~1.8 PB` | `~5.4 PB` (`3-Voter`) | `~450,000` | `~64 GiB / node` across 1,000 BE nodes | `GlobalManager` + **20 Cells** (`1,000 BE nodes`) | -### 6.3 Why There Is No Central Bottleneck at `10T+` Scale -1. **Data Plane (`<4%` Multi-Shard Txns)**: `group_key = PID` colocation + async `AuxOutbox` eliminate cross-shard 2PC for `>96%` of writes, yielding linear QPS scaling with BE node count. -2. **Control Plane (Two-Tier `GlobalManager` + `CellLocalManager`)**: Partitioning `450,000+` shards into independent **Cells** (`20K–30K` shards per `CellLocalManager`) bounds per-manager Raft heartbeat load while `GlobalManager` tracks `<1,000` coarse Cell range entries. -3. **Timestamps (Decentralized `HLC` with Drift Guard)**: Eliminates central Timestamp Oracle (TSO) network round-trips and single points of write failure; bounded drift checks (`500ms`) protect causal ordering. -4. **Routing (`MetaCache` + Epoch Pull-on-Mismatch)**: Proxies route in `1` hop with `>99.9%` cache hit rate and self-heal on `EpochMismatch` without manager thundering herds. +Only the single-node row matches a process shape this binary runs (`metadbd --role all-in-one`). + +### 6.3 Design Argument: No Central Bottleneck in the `10T+` Model + +The points below are design arguments for the capacity model. They are not measurements of this repository at `10T+`. + +1. **Data plane (`<4%` multi-shard transactions, in the model)**: `group_key = PID` colocation plus async `AuxOutbox` are intended to keep cross-shard 2PC off the common path, so QPS in the model grows with BE node count. +2. **Control plane (two-tier `GlobalManager` + `CellLocalManager`, in the model)**: Partitioning `450,000+` shards into independent cells (`20K–30K` shards per `CellLocalManager`) is how the model bounds per-manager Raft heartbeat load, while `GlobalManager` tracks `<1,000` coarse cell-range entries. +3. **Timestamps (decentralized `HLC` with a drift guard)**: The design avoids a central timestamp oracle. Bounded drift checks (`500ms`) are the causal-order guard in this tree; that guard is not a trillion-record measurement. +4. **Routing (`MetaCache` plus epoch pull-on-mismatch)**: The design routes in one hop from a cache and refreshes on `EpochMismatch`. The `>99.9%` hit rate is a design target, not a hit rate recorded by this repository. --- -## 7. Seamless Three-Stage Evolution: Single-Node to Distributed Cluster +## 7. Three-Stage Evolution: Single-Node Binary and the Intended Cluster + +The stages below are the design path. [Section 12](#12-implementation-status-matrix-paper-vs-repository) records what this tree has exercised. The design keeps one `LsmStorageBackend` and one `openraft` state machine across stages. This repository runs Stage 1, and a second `all-in-one` process can join that same cell. Stage 3 is not a deployment this binary performs. -MetaDB executes the **exact same `LsmStorageBackend` and `openraft` state machine** across every deployment stage: +> **Current binary:** `metadbd` only starts with `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` (`crates/metadb-server/src/lib.rs`) returns an error for `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` (`crates/metadb-server/src/grpc_services.rs`) returns an application error whose text says the RPC is not implemented, and it stores nothing. There is no live multi-process multi-Cell deployment in this tree. 1. **Stage 1 — Single-Node All-in-One (`1-Voter` OpenRaft)**: * A single `metadbd --role all-in-one` binary (or embedded `MetaDbEngine` library) runs `GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy`, and a `1-Voter` OpenRaft group in-process (`0` network hops for `ReadIndex` and consensus commit; sequential disk `fdatasync` only on Raft log segments). 2. **Stage 2 — Dynamic Multi-Shard Split on Single Host**: - * Starts with root shard `[0, u64::MAX)` and automatically executes `RaftCmd::ExecuteSplit` along `group_key = PID` boundaries as directories grow, scaling concurrency across multiple local Multi-Raft groups. -3. **Stage 3 — Zero-Downtime Scale-Out to Multi-Node & Multi-Cell (`1 -> 3 -> N` Nodes)**: - * **Replica Promotion (`1 -> 3` Voters)**: Additional `metadbd --role be` nodes join; `ConfChangeOrchestrator` calls `AddLearner`, streams LSM SSTable snapshots + retained Raft log segments, verifies lag `< threshold`, and promotes learners to `Voter`s via OpenRaft joint consensus with zero write interruption. - * **Shard Balancing & Jumbo Isolation (`3 -> N` Nodes)**: `CellLocalManager` transfers leadership and replicas across nodes and isolates `JumboIsolated` shards onto dedicated hosts. - * **Multi-Cell Federation (`N -> 1,000+` Nodes)**: `GlobalManager` registers new `CellLocalManager` clusters and assigns contiguous key-range partitions as capacity grows. + * Starts with root shard `[0, u64::MAX)` and executes `RaftCmd::ExecuteSplit` along `group_key = PID` boundaries as directories grow, so several local Multi-Raft groups share one process. +3. **Stage 3 — Design target only: multi-node and multi-cell (`1 -> 3 -> N` nodes)**: + * **Replica promotion (`1 -> 3` voters)**: The design joins further processes with `metadbd --role be`, adds them as learners, and promotes them to voters. This binary rejects `--role be`. Same-cell growth, where it exists, is another `all-in-one` process (`crates/metadb-server/tests/join_existing_group.rs`), not a role-trimmed backend, and not a three-VM rehearsal. + * **Shard balancing and jumbo isolation**: The design describes moving leadership and placing jumbo shards on dedicated hosts. This tree does not do that move. `JumboIsolated` stays a route flag. Peer shards stay on their current host. + * **Multi-cell federation (`N` nodes, including the paper's 1,000-node class)**: The design has `GlobalManager` register more `CellLocalManager` clusters and assign key ranges. `RegisterCell` does not do that here. The 1,000-node figure is a design-scale label from the paper, not a cluster this repository has run. --- @@ -256,7 +269,7 @@ rustfs/MetaDB | Failure Mode / Risk | Impact if Unmitigated | Architectural Mitigation | | :--- | :--- | :--- | -| **Extreme Single-Directory Skew (Jumbo Shard)** | Single `PID` with `>500M` files saturates one shared node or exceeds single-host disk. | 1. `JumboIsolated` dedicated-node scheduling evicts peer shards.
2. `DualModeFineGrained` `(PID, name)` splitting with shard-local `DirShardDelta` (`[0x04]`) keeps `create`/`unlink` `1-RTT` lock-free and `dirstat` `1-hop` scatter-gather. | +| **Extreme Single-Directory Skew (Jumbo Shard)** | Single `PID` with `>500M` files saturates one shared node or exceeds single-host disk. | 1. `JumboIsolated` is a route flag. This tree does not evict peer shards or move them onto a dedicated host.
2. `DualModeFineGrained` `(PID, name)` splitting with shard-local `DirShardDelta` (`[0x04]`) keeps `create`/`unlink` `1-RTT` lock-free and `dirstat` `1-hop` scatter-gather. | | **Future-Read Anomaly on Unversioned SSTables** | Reader at `T_1` falls through `MemMvccStore` into an L0 SSTable overwritten at `T_2 > T_1`. | `ActiveSnapshotRegistry` pins `ImmMemTable` flush until `min_active_snapshot_hlc >= imm.max_hlc` (capped at `5s` timeout), proving $read\_hlc \ge H_{\text{disk}}$ for every valid reader. | | **Shadowed-Key Resurrection in Range Compaction** | Dropping a physical tombstone at `L1` resurrects an older value in `L2`. | `LocalityCompactor` includes all overlapping SSTables down to the bottommost level for `[start_key, end_key)` and drops tombstones strictly when no deeper overlapping SSTable exists. | | **Crash Between `AttrDelta` Fold and SSTable Flush** | Truncating Raft log before folded `(PID, "_attr_")` hits disk loses counts. | **Coordinated Flush Barrier**: folded `_attr_` updates up to `M` flush inside the same L0 SSTable + `MANIFEST` `fdatasync` before `attr_flushed_index` advances to `M`. | @@ -279,15 +292,26 @@ Detailed Zero-Decision subsystem blueprints are maintained under [`docs/designs/ ## 12. Implementation Status Matrix (Paper vs. Repository) -| Capability / Subsystem | Baidu Paper (`arXiv:2610.32247v1`) | Current Repository Status (Phases 0–6 Verified) | Crate / Binary | +The Baidu paper [`arXiv:2610.32247v1`](https://arxiv.org/html/2610.32247v1) reports Baidu production figures, including 575+ nodes per cluster and trillion-scale metadata. Those figures are not results of this repository. This matrix is not a first-launch pass and not a scale-gate result. A documentation change is not that pass. + +The paper column stays Baidu production. Each repository cell uses one label, taken from the code and tests on current `main`, and from [`docs/en/operations.md`](./docs/en/operations.md) and [`docs/en/architecture.md`](./docs/en/architecture.md): + +* **design claim** — specified behavior this tree does not perform as an operator procedure. +* **crate-tested** — a test in this workspace exercises the crate. Unless the cell says otherwise, that test runs inside one OS process. +* **multi-process unverified** — the named multi-process rehearsal is not in this tree. A second `metadbd` that joins one group is not a three-`metadbd` voter rehearsal and not a three-VM result. + +This matrix does not withdraw behavior already on `main`. `storage.memtable_size_bytes` seals and flushes the active memtable, and `storage.max_imm_memtables` caps queued immutable tables. A live coordinator renews an in-flight cross-shard 2PC lease before the 3-second TTL, up to 60 seconds. The seeded simulation catalog is an in-memory script plus single-process restarts; see [`docs/en/simulation-testing.md`](./docs/en/simulation-testing.md). None of those is a Baidu production measurement. `ServerTomlConfig.raft_options` is skipped by serde and stays at defaults, so Raft timers are not an operator-settable TOML field. + +| Capability / Subsystem | Baidu production (`arXiv:2610.32247v1`) | This repository | Crate / Binary | | :--- | :--- | :--- | :--- | -| `(PID, "_attr_")` Colocation, `0x01..0x07` Codecs & `HLC` | Production (C++) | **Implemented & Tested** (88B CRC32C `InodeAttr`, 500ms drift & `u16` overflow guards) | `metadb-core` | -| Protobuf v1 / `tonic` gRPC Wire Contracts | Production RPC | **Implemented & Tested** (`MetadataService`, `TransactionService`, `RaftTransportService`, `ControlPlaneService`) | `metadb-proto` | -| Pure-Rust WAL-less Disk LSM (SSTable, Manifest, Bloom, Cache) | Production RocksDB (WAL off) | **Implemented & Tested** (`LsmStorageBackend`, 64B footer, `flush_generation`, 16-shard LRU `BlockCache`) | `metadb-storage` | -| `SnapshotGuard` `ReadCut` MVCC & `LocalityCompactor` | Production (`5s` window) | **Implemented & Tested** (`ActiveSnapshotRegistry` Safe-Flush Gate + bottommost range compaction) | `metadb-storage` | -| Multi-Raft Consensus (`1-Voter -> 3-Voter` + `ReadIndex`) | Production Baidu `braft` | **Implemented & Tested** (`openraft` 0.10 + segmented CRC32C `.raftlog` + 3-watermark purge + SSTable snapshots) | `metadb-raft` | -| `1-RTT` Pushdown, Coordinated `AttrAgg` & `AuxOutbox` Spill | Production | **Implemented & Tested** (`TxStateMachineHandler`, `ViewAtRaftIndex`, `[0x07]` `task_ordinal` spill & `AckAuxTasks`) | `metadb-tx` | -| Crash-Recoverable 2PC (`Rename`, Cross-Shard `Mkdir`/`Rmdir`) | Production 2PC | **Implemented & Tested** (Primary-Anchored `TxnRecord` + `WriteIntent`, POSIX overwrite, `DirRenameLease`) | `metadb-tx` | -| Epoch-Fenced `PID` Split, Jumbo Isolation & `DualMode` | Production | **Implemented & Tested** (3-stage `ExecuteSplit`, `JumboIsolationPlanner`, `DualModeFineGrained` scatter-gather) | `metadb-cluster` | -| Two-Tier Control Plane (`GlobalManager` + `CellLocalManager`) | Production (575+ nodes/cluster) | **Implemented & Tested** (`DurableGlobalManager`, `DurableCellManager`, `CompositeMetaCache`, `DurableIdAllocator`) | `metadb-cluster` | -| 20 Parameterized SQL Templates + `metadbd` & `metadb-ctl` | Production (~20 SQL patterns) | **Implemented & Tested** (`SqlTemplateParser` 20 templates + `PersistentMetaDbCluster` + `metadbd` + `metadb-ctl`) | `metadb-proxy` / `metadb-server` | +| `(PID, "_attr_")` Colocation, `0x01..0x07` Codecs & `HLC` | Production (C++) | **crate-tested**. `metadb-core` unit tests cover the 88B CRC32C `InodeAttr`, the 500ms drift guard, and the `u16` overflow guard. | `metadb-core` | +| Protobuf v1 / `tonic` gRPC Wire Contracts | Production RPC | **crate-tested**. One all-in-one process serves `MetadataService`, `TransactionService`, `RaftTransportService`, and `ControlPlaneService` on one listener. | `metadb-proto` | +| Pure-Rust WAL-less Disk LSM (SSTable, Manifest, Bloom, Cache) | Production RocksDB (WAL off) | **crate-tested**. This tree's `LsmStorageBackend` (64B footer, `flush_generation`, 16-shard LRU `BlockCache`) is covered by storage crate tests. The paper column is Baidu's RocksDB deployment. | `metadb-storage` | +| `SnapshotGuard` `ReadCut` MVCC & `LocalityCompactor` | Production (`5s` window). A flat `listdir` P99 under `<4ms` is a design target, not a measurement of this repository. | **crate-tested**. `ActiveSnapshotRegistry` and bottommost range compaction are covered by storage crate tests. `crates/metadb-storage/tests/first_ship_storage_regressions.rs` covers live-row `listdir` limit pushdown and density rebuild on open. That file is not a launch pass and not a measured P99. Process-restart `listdir` and multi-process 3-voter failover `listdir` with `entries_examined` assertions are not in this tree. | `metadb-storage` | +| Multi-Raft Consensus (`1-Voter -> 3-Voter` + `ReadIndex`) | Production Baidu `braft` | **multi-process unverified**. `multi_raft_failover_tests` runs three tonic listeners and a basic KV state machine inside one OS process. It does not start `metadbd` and does not serve `MetadataService`. `join_existing_group` starts a second `metadbd --role all-in-one` and joins one group. A three-`metadbd` voter rehearsal is outside these tests. | `metadb-raft` | +| `1-RTT` Pushdown, Coordinated `AttrAgg` & `AuxOutbox` Spill | Production | **crate-tested**. Coordinated attribute aggregation and `[0x07]` spill are covered inside one process by `attr_reconcile_race_tests` and `aux_idempotency_tests`. | `metadb-tx` | +| Crash-Recoverable 2PC (`Rename`, Cross-Shard `Mkdir`/`Rmdir`) | Production 2PC | **crate-tested**. Primary-anchored `TxnRecord` and `WriteIntent` recovery are covered by `two_pc_crash_tests`. A live coordinator replicates `Extend2pcLease` before the 3-second deadline, up to 60 seconds; `two_pc_lease_keepalive_tests` covers that renewal. After renewal stops, `TxnRecoveryWorker` aborts a still-`Pending` transaction once `expire_hlc` passes and rolls a committed primary forward. | `metadb-tx` | +| Epoch-Fenced `PID` Split & `DualMode` route flag | Production | **crate-tested**. Epoch-fenced PID split and split-plan resume are covered in-process by `epoch_split_tests` and `split_crash_recovery_tests`. `enable_dual_mode_split` persists `DualModeFineGrained` and `dual_mode_pid` on the route and does not itself copy keys. In-process `dual_mode_jumbo_tests` cover `DirShardDelta` scatter-gather. | `metadb-cluster` | +| Jumbo isolation (dedicated host) | Production | **design claim**. Jumbo isolation in this tree is a route flag. `JumboIsolationPlanner` writes `JumboIsolated { dedicated_node, dominant_pid }` and chooses the node id from nodes already registered in this cell. With one node, the flag names this process. Files stay on this host. Peer shards stay on their current host. An in-process test covers the flag. | `metadb-cluster` | +| Two-Tier Control Plane (`GlobalManager` + `CellLocalManager`) | Production (575+ nodes/cluster). That node count is Baidu production data, not a result of this repository. | **design claim**. One all-in-one process hosts `DurableGlobalManager` and `DurableCellManager` and registers one local cell. `RegisterCell` returns an error and does not create a second Cell. `open_and_serve` accepts only `all-in-one`. `be`, `proxy`, `cell-manager`, and `global-manager` are rejected before listen. | `metadb-cluster` | +| 20 Parameterized SQL Templates + `metadbd` & `metadb-ctl` | Production (~20 SQL patterns) | **crate-tested**. `sql_templates_tests` covers the 20 templates. `metadbd` and `metadb-ctl` run the all-in-one process. Any other role is rejected before listen. | `metadb-proxy` / `metadb-server` | diff --git a/README.md b/README.md index c1df349..d12dfda 100644 --- a/README.md +++ b/README.md @@ -9,10 +9,10 @@ > **Academic & Architectural Attribution**: > The architecture of `rustfs/MetaDB` is inspired by and adapted from Baidu's trillion-scale production metadata center paper: > **Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou**, *"MetaDB: Putting File-System Structure Back into Distributed Databases"*, [arXiv:2610.32247v1](https://arxiv.org/html/2610.32247v1) (Vrije Universiteit Amsterdam, Baidu & Peking University, 2026). -> *(Note: Trillion-record production figures cited from `arXiv:2610.32247v1` reflect Baidu's production deployment; see [Current Implementation Status](#current-implementation-status) below for `rustfs/MetaDB` repository milestones.)* +> *(Note: Trillion-record production figures cited from `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. [Current Implementation Status](#current-implementation-status) does not record a first-launch or trillion-scale pass.)* > > **Spec-Driven Development Methodology**: -> Designed, stress-tested, and verified using Google's [Elephant-Goldfish Model (EGM)](https://github.com/google/elephant-goldfish-model). +> Designed and stress-tested as a specification with Google's [Elephant-Goldfish Model (EGM)](https://github.com/google/elephant-goldfish-model). That review is not a first-launch or scale-gate pass. --- @@ -30,7 +30,7 @@ General-purpose distributed databases (such as TiDB, CockroachDB, and Foundation ### 1. Tree-Topology-Induced Sharding and Execution (`metadb-cluster` & `metadb-tx`) * **Colocated Schema (`(PID, "_attr_")`)**: `MetaTable` is keyed by `(PID, name)` with `group_key = PID`. A directory's own attributes are stored in a reserved child entry `(PID, "_attr_")` physically adjacent to its direct children `(PID, child_name)`. -* **Epoch-Fenced `PID`-Boundary Sharding & Jumbo Defense**: Shards split strictly along `group_key = PID` boundaries under `ShardEpoch` fencing, paired with **Jumbo-Shard Dedicated-Node Isolation** and **`DualModeFineGrained` `(PID, name)` Splitting** (using shard-local `DirShardDelta` records for `1-RTT` writes and `1-hop` scatter-gather `dirstat`). +* **Epoch-Fenced `PID`-Boundary Sharding & Jumbo Defense**: Shards split strictly along `group_key = PID` boundaries under `ShardEpoch` fencing. In this tree, jumbo isolation is a `JumboIsolated` route flag. It does not migrate peer shards to a dedicated host. **`DualModeFineGrained` `(PID, name)` splitting** uses shard-local `DirShardDelta` records for `1-RTT` writes and `1-hop` scatter-gather `dirstat`. * **Single-Shard Pushdown + Crash-Recoverable 2PC**: Executes single-directory Read-Modify-Write (`create`, `unlink`, `setattr`, `lookup`, `dirstat`, `listdir`, and colocated `mkdir`/`rmdir`) in `1 RTT` on the shard leader, reserving Primary-Anchored 2PC (`WriteIntent` + `TxnRecord`) for cross-shard `rename` (`<3%` of workload) and cross-shard `mkdir`/`rmdir`. ### 2. Semantic-Aware Off-Critical-Path Processing (`metadb-tx`) @@ -40,44 +40,44 @@ General-purpose distributed databases (such as TiDB, CockroachDB, and Foundation ### 3. Lifecycle-Aware Pure-Rust Storage Engine (`metadb-storage` & `metadb-raft`) * **WAL-less LSM + 3-Watermark OpenRaft**: Disables local KV WAL files in favor of segmented CRC32C Raft logs (`openraft`), clamping log purge to `min(state_flushed_index, aux_outbox_durable_index, last_snapshot_index)`. * **`SnapshotGuard` In-Memory MVCC**: Retains multi-version chains in memory for the `5s` transaction window, gating unversioned L0 SSTable collapse-flushes on `ActiveSnapshotRegistry` (`min_active_snapshot_hlc >= imm.max_hlc`) to eliminate persisted MVCC tombstones (`~60%` fewer KV writes) with zero future-read anomalies. -* **Bottommost-Safe Locality-Aware Compaction**: Tracks tombstone density per 9-byte prefix bucket and compacts hot deletion ranges down to the deepest overlapping SSTable level to keep `listdir` latency flat. +* **Bottommost-Safe Locality-Aware Compaction**: Tracks tombstone density per 9-byte prefix bucket and compacts hot deletion ranges down to the deepest overlapping SSTable level. A flat `listdir` P99 under `<4ms` is a design target in `arXiv:2610.32247v1`, not a measurement of this repository. --- ## Single-Node to Multi-Cell Evolution -MetaDB runs the **exact same `StorageBackend` and `openraft` state machine** from an embedded single-binary node to a multi-Cell cluster: +The design keeps one `StorageBackend` and one `openraft` state machine from an embedded single-binary node toward a multi-Cell cluster. Stage 3 is a design target. This binary does not deploy it. * **Stage 1 — Single-Node All-in-One (`1-Voter` OpenRaft)**: Zero network coordination; sequential Raft log persistence + embedded Rust SDK or `metadbd --role all-in-one`. -* **Stage 2 — Dynamic Multi-Shard Split**: Automatically splits shards along `group_key = PID` boundaries on a single host. -* **Stage 3 — Multi-Cell Distributed Cluster (`3-Voter` Multi-Raft)**: Online `AddLearner` -> SSTable snapshot catch-up -> joint-consensus `Voter` promotion, decentralized `HLC` clocks, stateless `MetaCache`, and a **Two-Tier Control Plane (`GlobalManager` + `CellLocalManager`)**. +* **Stage 2 — Dynamic Multi-Shard Split**: Splits shards along `group_key = PID` boundaries on a single host. +* **Stage 3 — Multi-Cell Distributed Cluster (design only)**: The design describes `AddLearner`, SSTable snapshot catch-up, joint-consensus voter promotion, decentralized `HLC` clocks, stateless `MetaCache`, and a two-tier control plane. Role-trimmed `be`, `proxy`, `cell-manager`, and `global-manager` processes are not a deployment this tree runs. -`metadbd` today runs Stage 1, plus in-process PID-boundary splits (Stage 2) on that same process. `open_and_serve` rejects every role except `all-in-one`. A second process bootstraps its own cell. `RegisterCell` does not store a second Cell. Learner promotion exists in-process; a three-`metadbd` deployment does not. See [docs/en/operations.md](./docs/en/operations.md). +`metadbd` today runs Stage 1, plus in-process PID-boundary splits (Stage 2) on that same process. `open_and_serve` rejects every role except `all-in-one`. A second `metadbd --role all-in-one` joins the same cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh (`crates/metadb-server/tests/join_existing_group.rs`). Without that join, a new data directory bootstraps its own cell. `RegisterCell` does not store a second Cell. A three-`metadbd` voter rehearsal is not in this tree. See [docs/en/operations.md](./docs/en/operations.md). --- ## 8-Crate Pure-Rust Workspace Architecture -| Crate | Status | Responsibility | +| Crate | In this tree | Responsibility | | :--- | :--- | :--- | -| [`crates/metadb-core`](./crates/metadb-core) | Implemented (Phase 1) | `0x01..0x07` CRC32C binary codecs, `(PID, "_attr_")` keys, `ShardEpoch`, `CompositeKeyRange`, `HLC` (+ drift/overflow guards). | -| [`crates/metadb-proto`](./crates/metadb-proto) | Implemented (Phase 1) | Protobuf v1 schemas & `tonic`/`prost` gRPC contracts (`MetadataService`, `TransactionService`, `RaftTransportService`, `ControlPlaneService`). | -| [`crates/metadb-storage`](./crates/metadb-storage) | Implemented (Phase 2) | `StorageBackend` trait, pure-Rust WAL-less SSTable LSM, `MANIFEST`, 16-shard LRU `BlockCache`, Bloom filter, `SnapshotGuard` `ReadCut` MVCC, `LocalityCompactor`. | -| [`crates/metadb-raft`](./crates/metadb-raft) | Implemented (Phase 3) | `openraft` 0.10 Multi-Raft, segmented CRC32C `.raftlog`, 3-watermark purge gate, batched `ReadIndex`, SSTable snapshots, `1->3` Voter `ConfChange`. | -| [`crates/metadb-tx`](./crates/metadb-tx) | Implemented (Phase 4) | Deterministic `TxStateMachineHandler`, `1-RTT` pushdown, `ReplicatedAttrAggregator`, contiguous `ShardAuxOutbox` + `[0x07]` spill, crash-recoverable 2PC. | -| [`crates/metadb-cluster`](./crates/metadb-cluster) | Implemented (Phase 5) | 3-stage `ExecuteSplit` (`PID` & `DualModeFineGrained`), `ShardEpoch` fencing, Jumbo isolation, `DurableGlobalManager`, `DurableCellManager`, `CompositeMetaCache`, `DurableIdAllocator`. | -| [`crates/metadb-proxy`](./crates/metadb-proxy) | Implemented (Phase 5) | Tokenizing `SqlLexer` & compiler for all 20 parameterized metadata SQL templates + `StatelessProxyRouter`. | -| [`crates/metadb-server`](./crates/metadb-server) | Implemented (Phase 6) | `PersistentMetaDbCluster` & `MetaDbEngine` SDKs + `metadbd` daemon + `metadb-ctl` operator CLI + Prometheus metrics. | +| [`crates/metadb-core`](./crates/metadb-core) | Present (phase label 1) | `0x01..0x07` CRC32C binary codecs, `(PID, "_attr_")` keys, `ShardEpoch`, `CompositeKeyRange`, `HLC` (+ drift/overflow guards). | +| [`crates/metadb-proto`](./crates/metadb-proto) | Present (phase label 1) | Protobuf v1 schemas & `tonic`/`prost` gRPC contracts (`MetadataService`, `TransactionService`, `RaftTransportService`, `ControlPlaneService`). | +| [`crates/metadb-storage`](./crates/metadb-storage) | Present (phase label 2) | `StorageBackend` trait, pure-Rust WAL-less SSTable LSM, `MANIFEST`, 16-shard LRU `BlockCache`, Bloom filter, `SnapshotGuard` `ReadCut` MVCC, `LocalityCompactor`. | +| [`crates/metadb-raft`](./crates/metadb-raft) | Present (phase label 3) | `openraft` 0.10 Multi-Raft, segmented CRC32C `.raftlog`, 3-watermark purge gate, batched `ReadIndex`, SSTable snapshots. In-process `1->3` voter coverage is not a three-VM rehearsal. | +| [`crates/metadb-tx`](./crates/metadb-tx) | Present (phase label 4) | Deterministic `TxStateMachineHandler`, `1-RTT` pushdown, `ReplicatedAttrAggregator`, contiguous `ShardAuxOutbox` + `[0x07]` spill, crash-recoverable 2PC with in-flight lease renewal. | +| [`crates/metadb-cluster`](./crates/metadb-cluster) | Present (phase label 5) | 3-stage `ExecuteSplit` (`PID` & `DualModeFineGrained`), `ShardEpoch` fencing, a `JumboIsolated` route flag, `DurableGlobalManager`, `DurableCellManager`, `CompositeMetaCache`, `DurableIdAllocator`. | +| [`crates/metadb-proxy`](./crates/metadb-proxy) | Present (phase label 5) | Tokenizing `SqlLexer` & compiler for all 20 parameterized metadata SQL templates + `StatelessProxyRouter`. | +| [`crates/metadb-server`](./crates/metadb-server) | Present (phase label 6) | `PersistentMetaDbCluster` & `MetaDbEngine` SDKs + `metadbd` daemon + `metadb-ctl` operator CLI + Prometheus metrics. `metadbd` serves `all-in-one` only. | --- ## Current Implementation Status -Phase completion in the list below means the crates and the tests in [docs/en/testing.md](./docs/en/testing.md) are in this tree. It does not mean a multi-process Cell deployment is supported. +Phase labels below mean the crates and the tests described in [docs/en/testing.md](./docs/en/testing.md) are in this tree. They do not mean a multi-process Cell deployment is supported, and they do not mean a first-launch or scale-gate pass. Trillion-scale figures in `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. The `listdir` P99 `<4ms` figure is a design target from that paper, not a measurement of this tree. Applied memtable settings, in-flight 2PC lease renewal, and the seeded simulation catalog are on this tree. They are not Baidu production measurements. -* **Phases 0–6 Completed & Verified**: - * **Phase 0**: Master `Architecture.md`, EGM subsystem specs, zero-context Goldfish review & resolutions (`B1`–`B18`, `N1`–`N5`), `DEVELOPMENT_PLAN.md`, and 5-language usage guides (`en`, `ja`, `fr`, `zh`, `de`). - * **Phases 1–6**: Full 8-crate 100% pure-Rust implementation (`zero C/C++ FFI`) passing `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace` (including fault-injection suites for SSTable/MANIFEST crash recovery, `SnapshotGuard` `ReadCut` isolation, `LocalityCompactor`, `1-Voter -> 3-Voter` Multi-Raft snapshot promotion & leader failover, `[0x07]` outbox spill/cleanup, 2PC crash recovery, 3-way `DualModeFineGrained` scatter-gather, all 20 SQL templates, and end-to-end gRPC cluster evolution). +* **Phases 0–6 are in this tree; they are not a first-launch or scale-gate verification**: + * **Phase 0**: Master `Architecture.md`, EGM subsystem specs, zero-context Goldfish review & resolutions (`B1`–`B18`, `N1`–`N5`), `DEVELOPMENT_PLAN.md`, and 5-language usage guides (`en`, `ja`, `fr`, `zh`, `de`). The Goldfish review checked the specification. It is not a runtime acceptance test. + * **Phases 1–6**: The 8 crates are a pure-Rust implementation (`zero C/C++ FFI`). The commands checked into the workspace are `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D warnings`, and `cargo test --workspace`. Those suites include fault-injection coverage for SSTable/`MANIFEST` crash recovery, `SnapshotGuard` `ReadCut` isolation, `LocalityCompactor`, in-process `1-Voter -> 3-Voter` snapshot promotion and leader failover, `[0x07]` outbox spill/cleanup, 2PC crash recovery (including lease renewal), 3-way `DualModeFineGrained` scatter-gather, all 20 SQL templates, and the gRPC tests listed in [docs/en/testing.md](./docs/en/testing.md). `crates/metadb-storage/tests/first_ship_storage_regressions.rs` covers live-row `listdir` limit pushdown and density rebuild on open. That file is not a launch pass. Process-restart `listdir` and multi-process 3-voter failover `listdir` with `entries_examined` assertions are not in this tree. --- @@ -95,7 +95,7 @@ Operator and developer guides in English, French, German, Japanese, and Simplifi `cargo test --workspace` includes the persistent topology suites and the stress smoke. T1–T6 still exercise the in-memory `MetaDbEngine::new_single_node` simulator. The persistent suites open a real `data_dir` through `PersistentMetaDbCluster` / `DurableCellManager`. -CI runs those three commands from a clean tree with `--locked` (tests also pass `--no-fail-fast`). See [CI and release packages](#ci-and-release-packages). +`.github/workflows/ci.yml` lists those three commands with `--locked` (tests also pass `--no-fail-fast`). This README does not say that workflow is enabled. See [CI and release packages](#ci-and-release-packages). | Suite | Command | | :--- | :--- | @@ -127,13 +127,13 @@ cargo run -p metadb-server --bin metadb-ctl -- bench --embedded --profile local `stress_crash_restart` stops a single-node process with `PersistentMetaDbCluster::shutdown_without_flush` while creates are still inside Raft propose, reopens the same `data_dir`, and checks listings, `dirstat`, quota, and a secondary index. A second stop covers a joined rename, unlink, and create tail. `three_voter_leader_loss_under_load` runs creates on a 3-voter cell, stops the leader without flushing, checks the new leader, and restarts the stopped voter while creates continue. -`metadb-ctl bench --workload hotspot-create` and `--workload bulk-ttl-delete` still drive a remote gRPC endpoint and report throughput only. `--workload mixed` is the embedded harness. +`metadb-ctl bench --workload hotspot-create` and `--workload bulk-ttl-delete` dial a remote gRPC endpoint and print JSON: a header, then phase reports with `attempted`, `succeeded`, `failed`, and latency percentiles. The process exits non-zero unless every requested operation succeeds. `--workload mixed` and `--embedded` run the in-process stress harness. Numbers from that command are for the machine that ran it; this repository does not record them as a result. -`metadbd` only runs `--role all-in-one`. `topology_distributed` still builds a 3-voter cell in-process. A second OS process can join that cell's Raft groups: `cargo test -p metadb-server --test join_existing_group`. `RegisterCell` does not create a second Cell. CI runs `cargo fmt`, `cargo clippy --locked`, and `cargo test --locked`, times the job out at 45 minutes, cancels a superseded run, and rejects a bare `#[ignore]` attribute. +`metadbd` only runs `--role all-in-one`. `topology_distributed` still builds a 3-voter cell in-process. A second OS process can join that cell's Raft groups: `cargo test -p metadb-server --test join_existing_group`. `RegisterCell` does not create a second Cell. The checked-in `ci.yml` lists `cargo fmt`, `cargo clippy --locked`, and `cargo test --locked`. Job `rust-check-lint-test` has `timeout-minutes: 90`. Job `package` has `timeout-minutes: 45`. The file sets `cancel-in-progress` for a newer push to the same ref and rejects a bare `#[ignore]` attribute. This README does not say that workflow is enabled. ## CI and release packages -[`.github/workflows/ci.yml`](./.github/workflows/ci.yml) is the only workflow. +[`.github/workflows/ci.yml`](./.github/workflows/ci.yml) is the test and package workflow file. The same directory also contains `dependency-audit.yml` and `security-adversarial-regressions.yml`. This section records timeouts checked into `ci.yml`. It does not say any workflow is enabled. | Job | When it runs | What it does | | :--- | :--- | :--- | @@ -142,7 +142,7 @@ cargo run -p metadb-server --bin metadb-ctl -- bench --embedded --profile local | Package `aarch64-unknown-linux-gnu` | Same as the x86_64 package job | Native `ubuntu-24.04-arm` release build. No cross or musl toolchain. | | Publish GitHub Release | Push of a `v*` tag, after tests and both packages succeed | Uploads the archives and checksums. `contents: write` is granted only on this job. | -A new push to the same ref cancels the in-progress run. Each job stops after 45 minutes (15 minutes for the release job). +The file sets `cancel-in-progress` for a newer push to the same ref. Checked-in `timeout-minutes` values are 90 for Format, Clippy & Test (`rust-check-lint-test`), 20 for the CI-scale prefix load (`prefix-load-ci`), 45 for each package job, and 15 for the release job. Package artifacts (also attached to the GitHub Release for a `v*` tag): diff --git a/docs/en/ci-and-release-gates.md b/docs/en/ci-and-release-gates.md index 214abb0..2646381 100644 --- a/docs/en/ci-and-release-gates.md +++ b/docs/en/ci-and-release-gates.md @@ -2,15 +2,15 @@ [Overview](./README.md) -This page describes the gates that exist in this tree today. A green GitHub Actions run is not production readiness, and it is not evidence that the official million-operation load passed. +This page describes the gates checked into this tree. Enabling or disabling workflows is an operator action outside this document. A green run of these jobs is not a first-launch pass, is not production readiness, and is not evidence that the official million-operation load passed. This page does not say GitHub Actions is enabled. ## Current CI -[`.github/workflows/ci.yml`](../../.github/workflows/ci.yml) is the test and package workflow. It runs on pull requests to `main`, on pushes to every branch, and on tags that start with `v`. +[`.github/workflows/ci.yml`](../../.github/workflows/ci.yml) is the test and package workflow file. Its triggers are pull requests to `main`, pushes to every branch, and tags that start with `v`. ### Format, Clippy, and tests -Job `rust-check-lint-test` runs on `ubuntu-24.04` with a **45-minute** timeout. In order, it: +Job `rust-check-lint-test` is configured for `ubuntu-24.04` with `timeout-minutes: 90` (a **90-minute** timeout). Job `prefix-load-ci` is configured with `timeout-minutes: 20`. Job `release` is configured with `timeout-minutes: 15`. In order, `rust-check-lint-test`: 1. Rejects `#[ignore]` tests that have an empty reason (`python3 .github/scripts/reject-bare-ignore.py --self-test crates`). 2. Installs `protobuf-compiler`. @@ -30,7 +30,7 @@ No separate CI job was added for those tests. They run because the existing lock ### Packaging -Job `package` also has a **45-minute** timeout. It runs on pull requests, on pushes to `main`, and on `v*` tags. The matrix builds release binaries with `cargo build --release --locked -p metadb-server --bins` for: +Job `package` still has `timeout-minutes: 45` (a **45-minute** timeout). Its triggers are pull requests, pushes to `main`, and `v*` tags. The matrix builds release binaries with `cargo build --release --locked -p metadb-server --bins` for: - `x86_64-unknown-linux-gnu` on `ubuntu-24.04` - `aarch64-unknown-linux-gnu` on `ubuntu-24.04-arm` @@ -41,7 +41,7 @@ The job then runs `.github/scripts/package-binaries.sh` and uploads the archive. `ci_bounded_prefix_load` is a reduced CI fixture: **4 prefixes × 25 creates, then 50 overwrite/delete operations, at concurrency 4**. It asserts that application `errors` and `correctness_errors` are both zero on that fixture. -CI runs that fixture as part of `cargo test --workspace --locked`. It must not be reported as: +The workspace test step in the checked-in workflow includes that fixture because `cargo test --workspace --locked` builds it. It must not be reported as: - the official load - a 1,000,000-operation load @@ -57,7 +57,7 @@ That restart is same-machine and in-process. It does **not** replace three-VM sc ## Dependency audit workflow -[`.github/workflows/dependency-audit.yml`](../../.github/workflows/dependency-audit.yml) is a separate workflow. It runs on `pull_request` and `push`. It installs `cargo-audit` 0.23.0 and `cargo-deny` 0.21.0, then runs both against this workspace. `cargo audit -D unmaintained -D unsound -D yanked` fails the job on a vulnerability or on an unmaintained, unsound, or yanked advisory. `cargo deny --locked check` still runs when that audit step has already failed, so a license, ban, or source finding is not hidden. The job stays failed if either command fails. `cargo deny` fails on a vulnerability advisory, on an unmaintained advisory anywhere in the graph, on an unsound advisory in a workspace crate, on a license outside the allow list, or on an unknown registry or git source. Yanked crates and duplicate crate versions are warnings in `cargo deny` and do not by themselves fail that command. +[`.github/workflows/dependency-audit.yml`](../../.github/workflows/dependency-audit.yml) is a separate workflow file. Its triggers are `pull_request` and `push`. It installs `cargo-audit` 0.23.0 and `cargo-deny` 0.21.0, then runs both against this workspace. `cargo audit -D unmaintained -D unsound -D yanked` fails the job on a vulnerability or on an unmaintained, unsound, or yanked advisory. `cargo deny --locked check` still runs when that audit step has already failed, so a license, ban, or source finding is not hidden. The job stays failed if either command fails. `cargo deny` fails on a vulnerability advisory, on an unmaintained advisory anywhere in the graph, on an unsound advisory in a workspace crate, on a license outside the allow list, or on an unknown registry or git source. Yanked crates and duplicate crate versions are warnings in `cargo deny` and do not by themselves fail that command. This is an **initial reporting job**. It is not a production-grade supply-chain program. It does not review transitive maintainers, pin a private advisory mirror, attest build provenance, or change who can merge. A green audit job is not proof that the tree is production ready, and a green `ci.yml` run is not that proof either. A red audit job means the tools reported a finding; it does not by itself say the workspace tests failed. diff --git a/docs/en/operations.md b/docs/en/operations.md index ed6a819..ea8cda0 100644 --- a/docs/en/operations.md +++ b/docs/en/operations.md @@ -198,5 +198,5 @@ These items are missing from the product, so this guide cannot describe a proced 2. A second Cell. `RegisterCell` stays an error. Join reaches only the current leader; a follower does not forward it. 3. Placing a jumbo shard on its own machine and moving other shards off that machine. 4. Native TLS. This process does not terminate TLS. Config keys that ask for TLS or a certificate are rejected instead of serving plaintext. Put termination in an external proxy. Raft and metrics use the same bearer as the other services when a secret is set; that bearer is not mutual TLS. A heartbeat-driven control loop is not implemented. -5. A Raft timer that operators can set and observe. +5. A Raft timer that operators can set and observe. `ServerTomlConfig.raft_options` is skipped by serde and stays at defaults. 6. A checked-in service-level result for `metadb-ctl bench`. The command prints numbers for the machine you run it on. This repository does not record one. See [Tests and benches](./testing.md). diff --git a/docs/guides/de/deployment.md b/docs/guides/de/deployment.md index 7329913..0a8167c 100644 --- a/docs/guides/de/deployment.md +++ b/docs/guides/de/deployment.md @@ -2,7 +2,7 @@ * **Zurück zur Übersicht**: [Deutsch Übersicht](./README.md) | [Hub](../../README.md) -MetaDB nutzt über alle Ausbaustufen hinweg **exakt dieselbe WAL-freie LSM-Speicher-Engine und dieselbe OpenRaft-Zustandsmaschine**, sodass ein Einzelknoten im laufenden Betrieb ohne Datenmigration zu einem Multi-Cell-Cluster skaliert werden kann. +The current binary runs a persistent deployment only as `all-in-one`. A second `all-in-one` process can join the same cell. Role-split processes and the multi-cell topology are a design target, not a deployment this repository runs. The `100B`–`10T+` range is a design model, not a measurement of this repository. Trillion-scale figures in `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. --- @@ -48,22 +48,29 @@ metadbd --config /etc/metadb/standalone.toml --- -## Stufe 3: Unterbrechungsfreie Skalierung auf `3-Voter` Multi-Raft & Multi-Cell `[Implementiert]` +## Stage 3: Intended multi-cell topology (not deployable today) -### 3.1 Online-Hochstufung von `1-Voter` auf `3-Voter` HA +Stage 3 is a design target. The current binary does not deploy it. -```bash -metadbd --role be --node-id 2 --listen 10.0.1.12:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb -metadbd --role be --node-id 3 --listen 10.0.1.13:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb +`metadbd` only runs `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` in `crates/metadb-server/src/lib.rs` rejects `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` in `crates/metadb-server/src/grpc_services.rs` returns an application error and does not store a second cell. This tree has no live multi-process multi-Cell deployment. -metadb-ctl raft scale-replicas --cell-id 1 --target-voters 3 -``` +A second `metadbd --role all-in-one` can join the **same** cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh. That path is covered by `crates/metadb-server/tests/join_existing_group.rs`. The joiner is still an all-in-one process. It is not a role-trimmed backend, and the join does not create another cell. See [Operations](../../de/operations.md). + +### Step 3.1: Voters inside one cell + +Do not start `metadbd --role be`. That role exits in `open_and_serve`, so those commands are not a runbook. `metadb-ctl raft scale-replicas` calls `ScaleShardReplicas` and requires the requested voter count to already be registered in the cell. A fresh all-in-one cell has one node, so `--target-voters 3` fails until those nodes exist. The constraints are in [Operations](../../de/operations.md). + +### Step 3.2: Design model for a disaggregated topology (`100B – 10T+` records) + +`100B – 10T+` is a design-model range: arithmetic for how a future multi-cell topology might be sized. It is not a record count this repository has stored. It is also not a Baidu production figure claimed as a result of `rustfs/MetaDB`. Baidu's published sizes, including the BOS2 figure of 1.848 trillion records in `arXiv:2610.32247v1`, are Baidu production metrics, not results of this repository. -Neue Knoten treten zunächst als `Learner` bei, übernehmen per Hardlink erzeugte SSTable-Snapshots (`InstallSnapshot`) sowie `.raftlog`-Einträge und werden anschließend per Joint Consensus ohne Schreibunterbrechung zu `Voter`-Replikaten hochgestuft. +The table is the intended role split. This binary does not run those roles. Jumbo isolation in this tree is a route flag. It does not move peer shards onto a dedicated host. -### 3.2 Zweistufige Multi-Cell-Steuerungsebene (`100 Mrd. – 10 Bio.+` Einträge) +| Role | Design `--role` | Intended responsibility | +| :--- | :--- | :--- | +| **Global Manager** | `global-manager` | Would map coarse `[start_key, end_key)` intervals to `CellId`, allocate `65,536`-ID blocks, and coordinate cross-Cell directory rename leases. | +| **Cell Local Manager** | `cell-manager` | Would process BE heartbeats (`20K–50K` shards/Cell) and orchestrate `PID` splits and membership changes. | +| **Backend Storage (`BE`)** | `be` | Would host Multi-Raft shard groups and the LSM engine on NVMe hosts. | +| **Stateless Proxy** | `proxy` | Would embed `MetaCache`, compile the 20 SQL templates, and coordinate cross-shard 2PC. | -* **`global-manager`**: Grobe Schlüsselbereichs-zu-`CellId`-Zuordnung (`<1.000` Einträge) sowie globale `65.536`-ID-Blockvergabe. -* **`cell-manager`**: Verarbeitung der 3s-BE-Heartbeats (`20K–50K` Shards pro Cell), `PID`-Splits und dedizierte Jumbo-Shard-Isolierung. -* **`be`**: Multi-Raft-Gruppen, `MemMvccStore`, `LsmStorageBackend` und `1-RTT`-Pushdown. -* **`proxy`**: Ein-Hop-Routing über `MetaCache`, Kompilierung der 20 SQL-Vorlagen und 2PC-Koordination. +`metadb-ctl cell register` calls `RegisterCell` and exits non-zero. It does not register a cell. Do not use it as a federation step. diff --git a/docs/guides/de/operations-and-tuning.md b/docs/guides/de/operations-and-tuning.md index 7ed743f..19aad65 100644 --- a/docs/guides/de/operations-and-tuning.md +++ b/docs/guides/de/operations-and-tuning.md @@ -31,7 +31,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 bench --workload hotspot-create --concurren ## 2. Umgang mit Jumbo Shards & Dual-Mode-Splitting -1. **Automatische Knoten-Isolierung (`JumboIsolated`)**: Macht ein einzelnes Verzeichnis (`PID`) mehr als `80 %` eines übergroßen Shards aus, verschiebt der `CellLocalManager` benachbarte Shards auf andere Knoten, damit das Jumbo-Verzeichnis die gesamte NVMe- und CPU-Kapazität eines dedizierten Hosts erhält. +1. **`JumboIsolated` route flag**: When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent, `JumboIsolationPlanner` writes `dedicated_node` from nodes already registered in this cell. It does not migrate co-hosted peer shards onto another host. With one node, the flag names this process. 2. **Feingranulares `DualModeFineGrained`-Splitting `(PID, name)`**: Überschreitet ein Verzeichnis selbst einen dedizierten Host, teilt `DualModeFineGrained` den Bereich entlang `(PID, name)` auf. Dank lokaler `[0x04] DirShardDelta`-Einträge bleiben `create_file` und `unlink` sperrfreie `1-RTT`-Einzel-Shard-Operationen, während `dirstat` per `1-Hop`-Scatter-Gather exakt zusammengeführt wird. --- diff --git a/docs/guides/en/README.md b/docs/guides/en/README.md index 8603807..a2bd56b 100644 --- a/docs/guides/en/README.md +++ b/docs/guides/en/README.md @@ -10,28 +10,31 @@ ## Guide Navigation 1. **Overview & Embedded Quickstart** *(this page)* -2. [**Deployment & Online Cluster Scale-Out**](./deployment.md) — Single-Node `metadbd`, `1-Voter -> 3-Voter` Multi-Raft promotion, and Multi-Cell `GlobalManager` / `CellLocalManager` / `MetaCache` topology. +2. [**Deployment**](./deployment.md) — Single-node `metadbd`. Stage 3 role-split topology is a design note, not a deployment this binary performs. 3. [**Client APIs, gRPC & 20 SQL Templates**](./client-apis-and-sql.md) — Embedded Rust SDK, `tonic` gRPC services, and the complete reference of 20 metadata SQL templates. 4. [**Operations, `metadb-ctl` & Performance Tuning**](./operations-and-tuning.md) — CLI administration, Jumbo Shard isolation & Dual-Mode splitting, `SnapshotGuard` MVCC & `LocalityCompactor` tuning, the embedded stress harness, and troubleshooting. --- -## Feature Readiness Matrix (Phases 1–6 Verified) +## Feature readiness -MetaDB's 8-crate pure-Rust implementation is verified across all core subsystems: +The Baidu paper [`arXiv:2610.32247v1`](https://arxiv.org/html/2610.32247v1) reports Baidu production figures, including 575+ nodes per cluster and trillion-scale metadata. Those figures are not results of this repository. This matrix is not a first-launch pass and not a scale-gate result. + +Each status cell uses one label: **design claim**, **crate-tested**, or **multi-process unverified**. In-tree tests are crate or in-process coverage unless the cell says otherwise. They are not a multi-process 3-voter operator rehearsal and not a three-VM result. Operator detail is in [`docs/en/operations.md`](../../en/operations.md) and [`docs/en/architecture.md`](../../en/architecture.md). Applied memtable settings, in-flight 2PC lease renewal, and the seeded simulation catalog ([`docs/en/simulation-testing.md`](../../en/simulation-testing.md)) are on current `main`. They are not Baidu production measurements. | Feature Area | Repository Status | Implementation Crate / Binary | | :--- | :--- | :--- | -| Embedded Rust SDKs (`PersistentMetaDbCluster` & `MetaDbEngine`) | **Implemented & Tested** (async persistent + sync in-memory) | `metadb-server` | -| `(PID, "_attr_")` Colocation, `0x01..0x07` Codecs & `HLC` | **Implemented & Tested** (88B CRC32C + 500ms drift guard) | `metadb-core` | -| Disk Persistence (Pure-Rust WAL-less SSTable LSM) | **Implemented & Tested** (`LsmStorageBackend`, `MANIFEST`, Bloom, LRU Cache) | `metadb-storage` | -| `SnapshotGuard` `ReadCut` MVCC & `LocalityCompactor` | **Implemented & Tested** (`ActiveSnapshotRegistry` + bottommost compaction) | `metadb-storage` | -| Multi-Raft Consensus (`1-Voter -> 3-Voter` + `ReadIndex`) | **Implemented & Tested** (`openraft` 0.10 + `.raftlog` + `tonic`) | `metadb-raft` | -| `1-RTT` Pushdown, `ReplicatedAttrAggregator` & `AuxOutbox` | **Implemented & Tested** (Coordinated Flush Barrier + `[0x07]` local spill) | `metadb-tx` | -| Cross-Shard 2PC (`Rename`, `Mkdir`, `Rmdir`, `SetAttr`) | **Implemented & Tested** (Primary-Anchored `TxnRecord` + `WriteIntent` recovery) | `metadb-tx` | -| `PID`-Boundary Split, Jumbo Isolation & `DualMode` | **Implemented & Tested** (`ShardEpoch` fencing + `DirShardDelta` scatter-gather) | `metadb-cluster` | -| 20 Parameterized SQL Templates | **Implemented & Tested** (all 20 `?` & escaped SQL templates) | `metadb-proxy` | -| `metadbd` Server Daemon & `metadb-ctl` CLI | **Implemented & Tested** (`crates/metadb-server/src/bin/`) | `metadb-server` | +| Embedded Rust SDKs (`PersistentMetaDbCluster` & `MetaDbEngine`) | **crate-tested**. `PersistentMetaDbCluster` is covered by single-process tests. `MetaDbEngine::new_single_node` is an in-memory simulator with no disk and no Raft. | `metadb-server` | +| `(PID, "_attr_")` Colocation, `0x01..0x07` Codecs & `HLC` | **crate-tested**. `metadb-core` unit tests cover the 88B CRC32C `InodeAttr` and the 500ms drift guard. | `metadb-core` | +| Disk Persistence (Pure-Rust WAL-less SSTable LSM) | **crate-tested**. `LsmStorageBackend`, `MANIFEST`, Bloom, and the LRU block cache are covered by storage crate tests. | `metadb-storage` | +| `SnapshotGuard` `ReadCut` MVCC & `LocalityCompactor` | **crate-tested**. `ActiveSnapshotRegistry` and bottommost compaction are covered by storage crate tests. A flat `listdir` P99 under `<4ms` is a paper design target, not a measurement of this repository. | `metadb-storage` | +| Multi-Raft Consensus (`1-Voter -> 3-Voter` + `ReadIndex`) | **multi-process unverified**. The checked-in 1-voter to 3-voter test runs three tonic listeners and a basic KV state machine inside one OS process. It does not start `metadbd`. `join_existing_group` starts a second `metadbd` and joins one group. A three-`metadbd` voter rehearsal is outside these tests. | `metadb-raft` | +| `1-RTT` Pushdown, `ReplicatedAttrAggregator` & `AuxOutbox` | **crate-tested**. Coordinated flush-barrier aggregation and `[0x07]` local spill are covered by `metadb-tx` tests inside one process. | `metadb-tx` | +| Cross-Shard 2PC (`Rename`, `Mkdir`, `Rmdir`, `SetAttr`) | **crate-tested**. Primary-anchored `TxnRecord` and `WriteIntent` recovery are covered by `two_pc_crash_tests`. A live coordinator renews the 3-second lease up to 60 seconds (`two_pc_lease_keepalive_tests`). | `metadb-tx` | +| `PID`-boundary split & `DualMode` route flag | **crate-tested**. Epoch-fenced PID split is covered in-process. `enable_dual_mode_split` persists a route flag and does not itself copy keys. | `metadb-cluster` | +| Jumbo isolation (dedicated host) | **design claim**. Jumbo isolation in this tree is a route flag plus a node id chosen from the local node map. With one node, the flag names this process. Files stay on this host. Peer shards stay on their current host. | `metadb-cluster` | +| 20 Parameterized SQL Templates | **crate-tested**. `sql_templates_tests` covers all 20 templates. | `metadb-proxy` | +| `metadbd` Server Daemon & `metadb-ctl` CLI | **crate-tested**. The all-in-one binaries live in `crates/metadb-server/src/bin/`. `open_and_serve` accepts only `all-in-one`. | `metadb-server` | --- diff --git a/docs/guides/en/deployment.md b/docs/guides/en/deployment.md index 95cf61b..c2a2026 100644 --- a/docs/guides/en/deployment.md +++ b/docs/guides/en/deployment.md @@ -68,38 +68,29 @@ As metadata grows past `shard_split_threshold_bytes`, `CellLocalManager` and `Po --- -## Stage 3: Multi-Node Raft Tests and Intended Multi-Cell Topology +## Stage 3: Intended multi-cell topology (not deployable today) -### Step 3.1: Zero-Downtime Upgrade from `1-Voter` to `3-Voter` HA +Stage 3 is a design target. The current binary does not deploy it. -> **Current binary**: role-trimmed `be` / `proxy` / `cell-manager` / `global-manager` processes are not implemented. `metadbd` only runs `all-in-one`. The steps below describe the intended topology; launching those roles fails fast instead of silently starting every subsystem. +`metadbd` only runs `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` in `crates/metadb-server/src/lib.rs` rejects `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` in `crates/metadb-server/src/grpc_services.rs` returns an application error and does not store a second cell. This tree has no live multi-process multi-Cell deployment. -1. Start two additional Backend (`be`) nodes pointing to the existing control plane: - ```bash - metadbd --role be --node-id 2 --listen 10.0.1.12:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb - metadbd --role be --node-id 3 --listen 10.0.1.13:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb - ``` -2. Trigger online replica promotion via `metadb-ctl`: - ```bash - metadb-ctl raft scale-replicas --cell-id 1 --target-voters 3 - ``` - **Internal Execution**: - * `ConfChangeOrchestrator` adds Nodes `2` and `3` as non-voting `Learner`s (`AddLearner`). - * Leader triggers a Coordinated Flush Barrier, hard-links an SSTable checkpoint, and streams `InstallSnapshot` + tail `.raftlog` entries. - * Once replication lag drops below `64` entries, OpenRaft executes joint-consensus `ChangeMembership` promoting Nodes `2` and `3` to `Voter`s with **zero write downtime**. +A second `metadbd --role all-in-one` can join the **same** cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh. That path is covered by `crates/metadb-server/tests/join_existing_group.rs`. The joiner is still an all-in-one process. It is not a role-trimmed backend, and the join does not create another cell. See [Operations](../../en/operations.md). -### Step 3.2: Disaggregated Multi-Cell Topology (`100B – 10T+` Records) +### Step 3.1: Voters inside one cell -The following table describes an intended topology, not runnable role-trimmed daemon deployments: +Do not start `metadbd --role be`. That role exits in `open_and_serve`, so those commands are not a runbook. `metadb-ctl raft scale-replicas` calls `ScaleShardReplicas` and requires the requested voter count to already be registered in the cell. A fresh all-in-one cell has one node, so `--target-voters 3` fails until those nodes exist. The constraints are in [Operations](../../en/operations.md). -| Role | `--role` Flag | Recommended Deployment | Responsibility | -| :--- | :--- | :--- | :--- | -| **Global Manager** | `global-manager` | 3-node Raft group | Maps coarse `[start_key, end_key)` intervals to `CellId`; allocates `65,536`-ID blocks; coordinates cross-Cell directory rename leases. | -| **Cell Local Manager** | `cell-manager` | 3-node Raft group per Cell | Processes 3s BE heartbeats (`20K–50K` shards/Cell), orchestrates `PID` splits, Jumbo node isolation, and `ConfChange`. | -| **Backend Storage (`BE`)** | `be` | `12 – 60+` NVMe hosts per Cell | Hosts Multi-Raft shard groups, `MemMvccStore`, `LsmStorageBackend`, `PushdownExecutor`, and `AuxDispatcher`. | -| **Stateless Proxy** | `proxy` | Autoscaled / co-deployed with RustFS | Embeds `MetaCache` (`>99.9%` single-hop hit rate), compiles 20 SQL templates, and coordinates cross-shard 2PC. | +### Step 3.2: Design model for a disaggregated topology (`100B – 10T+` records) -```bash -# Register a new Cell in GlobalManager for horizontal expansion -metadb-ctl cell register --cell-id 2 --endpoints 10.0.2.10:7801,10.0.2.11:7801,10.0.2.12:7801 -``` +`100B – 10T+` is a design-model range: arithmetic for how a future multi-cell topology might be sized. It is not a record count this repository has stored. It is also not a Baidu production figure claimed as a result of `rustfs/MetaDB`. Baidu's published sizes, including the BOS2 figure of 1.848 trillion records in `arXiv:2610.32247v1`, are Baidu production metrics, not results of this repository. + +The table is the intended role split. This binary does not run those roles. Jumbo isolation in this tree is a route flag. It does not move peer shards onto a dedicated host. + +| Role | Design `--role` | Intended responsibility | +| :--- | :--- | :--- | +| **Global Manager** | `global-manager` | Would map coarse `[start_key, end_key)` intervals to `CellId`, allocate `65,536`-ID blocks, and coordinate cross-Cell directory rename leases. | +| **Cell Local Manager** | `cell-manager` | Would process BE heartbeats (`20K–50K` shards/Cell) and orchestrate `PID` splits and membership changes. | +| **Backend Storage (`BE`)** | `be` | Would host Multi-Raft shard groups and the LSM engine on NVMe hosts. | +| **Stateless Proxy** | `proxy` | Would embed `MetaCache`, compile the 20 SQL templates, and coordinate cross-shard 2PC. | + +`metadb-ctl cell register` calls `RegisterCell` and exits non-zero. It does not register a cell. Do not use it as a federation step. diff --git a/docs/guides/fr/deployment.md b/docs/guides/fr/deployment.md index 2aaaa2e..c1ea16d 100644 --- a/docs/guides/fr/deployment.md +++ b/docs/guides/fr/deployment.md @@ -2,7 +2,7 @@ * **Retour à l'index**: [Présentation Français](./README.md) | [Portail](../../README.md) -MetaDB exécute **exactement le même moteur LSM sans WAL et la même machine à états OpenRaft** du nœud unique jusqu'au cluster multi-cellules de plus de 1 000 serveurs, sans migration hors ligne. +The current binary runs a persistent deployment only as `all-in-one`. A second `all-in-one` process can join the same cell. Role-split processes and the multi-cell topology are a design target, not a deployment this repository runs. The `100B`–`10T+` range is a design model, not a measurement of this repository. Trillion-scale figures in `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. --- @@ -48,22 +48,29 @@ Lorsqu'un shard dépasse `shard_split_threshold_bytes`, `PolicyShardSplitter` ch --- -## Étape 3 : Extension sans Interruption vers Multi-Raft `3-Voter` & Multi-Cell `[Implémenté]` +## Stage 3: Intended multi-cell topology (not deployable today) -### 3.1 Promotion Haute Disponibilité `1-Voter -> Learner -> 3-Voter` +Stage 3 is a design target. The current binary does not deploy it. -```bash -metadbd --role be --node-id 2 --listen 10.0.1.12:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb -metadbd --role be --node-id 3 --listen 10.0.1.13:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb +`metadbd` only runs `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` in `crates/metadb-server/src/lib.rs` rejects `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` in `crates/metadb-server/src/grpc_services.rs` returns an application error and does not store a second cell. This tree has no live multi-process multi-Cell deployment. -metadb-ctl raft scale-replicas --cell-id 1 --target-voters 3 -``` +A second `metadbd --role all-in-one` can join the **same** cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh. That path is covered by `crates/metadb-server/tests/join_existing_group.rs`. The joiner is still an all-in-one process. It is not a role-trimmed backend, and the join does not create another cell. See [Operations](../../fr/operations.md). + +### Step 3.1: Voters inside one cell + +Do not start `metadbd --role be`. That role exits in `open_and_serve`, so those commands are not a runbook. `metadb-ctl raft scale-replicas` calls `ScaleShardReplicas` and requires the requested voter count to already be registered in the cell. A fresh all-in-one cell has one node, so `--target-voters 3` fails until those nodes exist. The constraints are in [Operations](../../fr/operations.md). + +### Step 3.2: Design model for a disaggregated topology (`100B – 10T+` records) + +`100B – 10T+` is a design-model range: arithmetic for how a future multi-cell topology might be sized. It is not a record count this repository has stored. It is also not a Baidu production figure claimed as a result of `rustfs/MetaDB`. Baidu's published sizes, including the BOS2 figure of 1.848 trillion records in `arXiv:2610.32247v1`, are Baidu production metrics, not results of this repository. -Les nouveaux nœuds rejoignent le groupe en tant que `Learner`, reçoivent un instantané SSTable par liens physiques (`InstallSnapshot`) suivi des segments `.raftlog`, puis passent `Voter` par consensus conjoint sans arrêt des écritures. +The table is the intended role split. This binary does not run those roles. Jumbo isolation in this tree is a route flag. It does not move peer shards onto a dedicated host. -### 3.2 Architecture Multi-Cell à Deux Niveaux (`100 Md – 10 000 Md+` d'entrées) +| Role | Design `--role` | Intended responsibility | +| :--- | :--- | :--- | +| **Global Manager** | `global-manager` | Would map coarse `[start_key, end_key)` intervals to `CellId`, allocate `65,536`-ID blocks, and coordinate cross-Cell directory rename leases. | +| **Cell Local Manager** | `cell-manager` | Would process BE heartbeats (`20K–50K` shards/Cell) and orchestrate `PID` splits and membership changes. | +| **Backend Storage (`BE`)** | `be` | Would host Multi-Raft shard groups and the LSM engine on NVMe hosts. | +| **Stateless Proxy** | `proxy` | Would embed `MetaCache`, compile the 20 SQL templates, and coordinate cross-shard 2PC. | -* **`global-manager`** : Table grossière `[start_key, end_key) -> CellId` (`<1 000` entrées) et allocation de blocs de `65 536` identifiants. -* **`cell-manager`** : Battements de cœur par shard (`20K–50K` shards/Cell), découpage `PID` et isolation dédiée des Jumbo Shards. -* **`be`** : Groupes Multi-Raft, `MemMvccStore`, `LsmStorageBackend` et exécution `1-RTT`. -* **`proxy`** : Routage `MetaCache` en un saut, compilation des 20 modèles SQL et coordination 2PC. +`metadb-ctl cell register` calls `RegisterCell` and exits non-zero. It does not register a cell. Do not use it as a federation step. diff --git a/docs/guides/fr/operations-and-tuning.md b/docs/guides/fr/operations-and-tuning.md index 1ff7edf..2f1e66b 100644 --- a/docs/guides/fr/operations-and-tuning.md +++ b/docs/guides/fr/operations-and-tuning.md @@ -31,7 +31,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 bench --workload hotspot-create --concurren ## 2. Gestion des Répertoires Géants (Jumbo Shards & Dual-Mode) -1. **Isolation automatique sur nœud dédié (`JumboIsolated`)** : Lorsqu'un unique `PID` représente `>80 %` d'un shard dépassant le seuil de découpage, `CellLocalManager` évacue les autres shards du serveur BE afin de lui réserver 100 % des IOPS NVMe et du CPU. +1. **`JumboIsolated` route flag**: When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent, `JumboIsolationPlanner` writes `dedicated_node` from nodes already registered in this cell. It does not migrate co-hosted peer shards onto another host. With one node, the flag names this process. 2. **Découpage fin `DualModeFineGrained` `(PID, name)`** : Si ce répertoire dépasse la capacité d'un serveur dédié, l'activation du mode `DualModeFineGrained` découpe la plage `(PID, name)` tout en maintenant un compteur local `[0x04] DirShardDelta` sur chaque sous-shard : `create_file` et `unlink` restent en `1 RTT` sans verrouillage inter-shards, tandis que `dirstat` effectue une collecte parallèle en `1` saut réseau. --- diff --git a/docs/guides/ja/deployment.md b/docs/guides/ja/deployment.md index 0f8827d..58bff2a 100644 --- a/docs/guides/ja/deployment.md +++ b/docs/guides/ja/deployment.md @@ -2,7 +2,7 @@ * **ガイド目次へ戻る**: [日本語概要](./README.md) | [ハブ](../../README.md) -MetaDB はシングルノード構成から 1,000 台超の分散クラスターまで **完全に同一の WAL レス LSM エンジンと OpenRaft ステートマシン** を実行し、データ移行なしで段階的にスケールアウトできます。 +The current binary runs a persistent deployment only as `all-in-one`. A second `all-in-one` process can join the same cell. Role-split processes and the multi-cell topology are a design target, not a deployment this repository runs. The `100B`–`10T+` range is a design model, not a measurement of this repository. Trillion-scale figures in `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. --- @@ -48,22 +48,29 @@ metadbd --config /etc/metadb/standalone.toml --- -## Stage 3:`3-Voter` Multi-Raft および Multi-Cell 分散クラスターへの無停止拡張 `[実装済]` +## Stage 3: Intended multi-cell topology (not deployable today) -### 3.1 `1-Voter` から `3-Voter` への無停止レプリカ昇格 +Stage 3 is a design target. The current binary does not deploy it. -```bash -# 新規 BE ノード 2 台を起動 -metadbd --role be --node-id 2 --listen 10.0.1.12:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb -metadbd --role be --node-id 3 --listen 10.0.1.13:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb +`metadbd` only runs `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` in `crates/metadb-server/src/lib.rs` rejects `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` in `crates/metadb-server/src/grpc_services.rs` returns an application error and does not store a second cell. This tree has no live multi-process multi-Cell deployment. -# Learner 追加 -> SSTable スナップショット転送 -> Joint Consensus による Voter 昇格 -metadb-ctl raft scale-replicas --cell-id 1 --target-voters 3 -``` +A second `metadbd --role all-in-one` can join the **same** cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh. That path is covered by `crates/metadb-server/tests/join_existing_group.rs`. The joiner is still an all-in-one process. It is not a role-trimmed backend, and the join does not create another cell. See [Operations](../../ja/operations.md). + +### Step 3.1: Voters inside one cell + +Do not start `metadbd --role be`. That role exits in `open_and_serve`, so those commands are not a runbook. `metadb-ctl raft scale-replicas` calls `ScaleShardReplicas` and requires the requested voter count to already be registered in the cell. A fresh all-in-one cell has one node, so `--target-voters 3` fails until those nodes exist. The constraints are in [Operations](../../ja/operations.md). + +### Step 3.2: Design model for a disaggregated topology (`100B – 10T+` records) + +`100B – 10T+` is a design-model range: arithmetic for how a future multi-cell topology might be sized. It is not a record count this repository has stored. It is also not a Baidu production figure claimed as a result of `rustfs/MetaDB`. Baidu's published sizes, including the BOS2 figure of 1.848 trillion records in `arXiv:2610.32247v1`, are Baidu production metrics, not results of this repository. + +The table is the intended role split. This binary does not run those roles. Jumbo isolation in this tree is a route flag. It does not move peer shards onto a dedicated host. -### 3.2 Multi-Cell 2 階層コントロールプレーン構成(1,000 億〜10 兆+ レコード) +| Role | Design `--role` | Intended responsibility | +| :--- | :--- | :--- | +| **Global Manager** | `global-manager` | Would map coarse `[start_key, end_key)` intervals to `CellId`, allocate `65,536`-ID blocks, and coordinate cross-Cell directory rename leases. | +| **Cell Local Manager** | `cell-manager` | Would process BE heartbeats (`20K–50K` shards/Cell) and orchestrate `PID` splits and membership changes. | +| **Backend Storage (`BE`)** | `be` | Would host Multi-Raft shard groups and the LSM engine on NVMe hosts. | +| **Stateless Proxy** | `proxy` | Would embed `MetaCache`, compile the 20 SQL templates, and coordinate cross-shard 2PC. | -* **`global-manager`**:キー範囲と `CellId` の対応表(`<1,000` エントリ)および `65,536` 単位のグローバル ID ブロック割当てを管理。 -* **`cell-manager`**:各 Cell 内のシャードハートビート(Cell あたり `20K–50K` シャード)、`PID` 分割、Jumbo 専用ノード分離を制御。 -* **`be`**:Multi-Raft グループ、`MemMvccStore`、`LsmStorageBackend`、`PushdownExecutor` を実行。 -* **`proxy`**:`MetaCache` による 1 ホップルーティング、20 種類の SQL テンプレートコンパイル、クロスシャード 2PC を担当。 +`metadb-ctl cell register` calls `RegisterCell` and exits non-zero. It does not register a cell. Do not use it as a federation step. diff --git a/docs/guides/ja/operations-and-tuning.md b/docs/guides/ja/operations-and-tuning.md index c2efa6b..f79dfb7 100644 --- a/docs/guides/ja/operations-and-tuning.md +++ b/docs/guides/ja/operations-and-tuning.md @@ -31,7 +31,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 bench --workload hotspot-create --concurren ## 2. Jumbo Shard(巨大単一ディレクトリ)の運用設計 -1. **専用ノード自動分離 (`JumboIsolated`)**:単一 `PID` がシャード容量の `80%` 超を占める場合、`CellLocalManager` が他シャードを退避させ、1 台の NVMe ノードを該当ディレクトリ専用に割り当てます。 +1. **`JumboIsolated` route flag**: When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent, `JumboIsolationPlanner` writes `dedicated_node` from nodes already registered in this cell. It does not migrate co-hosted peer shards onto another host. With one node, the flag names this process. 2. **デュアルモード細粒度分割 (`DualModeFineGrained`)**:1 台の物理容量を超える場合のみ `(PID, name)` 境界での分割を有効化します。各サブシャードが `[0x04] DirShardDelta` を保持するため、`create_file` / `unlink` は `1-RTT` ロックフリーのまま動作し、`dirstat` は `1-hop` 並列集約で正確な値を返します。 --- diff --git a/docs/guides/zh/deployment.md b/docs/guides/zh/deployment.md index f09f7ec..9a6e782 100644 --- a/docs/guides/zh/deployment.md +++ b/docs/guides/zh/deployment.md @@ -2,9 +2,9 @@ * **返回指南首页**: [简体中文概览](./README.md) | [文档中心](../../README.md) -MetaDB 在单机模式与千节点分布式集群中使用**完全相同的无 WAL LSM 存储引擎与 OpenRaft 状态机**,支持从单机平滑在线演进至百亿—十万亿级元数据集群,无需停机迁移数据格式。 +The current binary runs a persistent deployment only as `all-in-one`. A second `all-in-one` process can join the same cell. Role-split processes and the multi-cell topology are a design target, not a deployment this repository runs. The `100B`–`10T+` range is a design model, not a measurement of this repository. Trillion-scale figures in `arXiv:2610.32247v1` are Baidu production metrics, not results of this repository. -> **实现状态说明**:无 WAL SSTable 持久化 LSM 引擎、`openraft` Multi-Raft(`1-Voter -> 3-Voter` 在线扩容)、带 `ShardEpoch` 围栏的 `PID` 边界与 `DualModeFineGrained` 分片分裂、Jumbo 分片隔离、守护进程 `metadbd` 以及运维工具 `metadb-ctl` 均已在当前 8-Crate 工作区中完整实现并通过测试验证。 +> **What this tree runs**: persistent LSM, Raft replication, same-process shard splits, and all-in-one gRPC/CLI have tests in this workspace. Only `all-in-one` starts a daemon. `be`, `proxy`, `cell-manager`, `global-manager`, and remote `RegisterCell` are rejected. Jumbo isolation is a route flag and does not move peer shards. See [correctness notes](../../designs/correctness_hardening.md). --- @@ -58,31 +58,29 @@ metadbd --config /etc/metadb/standalone.toml --- -## 阶段三:在线扩展至 `3-Voter` Multi-Raft 与多单元集群 `[已实现]` - -### 3.1 零停机高可用升级(`1-Voter -> Learner -> 3-Voter`) - -1. 启动两台新的存储后端节点(`--role be`)接入当前控制面: - ```bash - metadbd --role be --node-id 2 --listen 10.0.1.12:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb - metadbd --role be --node-id 3 --listen 10.0.1.13:7800 --cell-manager 10.0.1.11:7800 --data-dir /var/lib/metadb - ``` -2. 通过 `metadb-ctl` 在线提升副本数: - ```bash - metadb-ctl raft scale-replicas --cell-id 1 --target-voters 3 - ``` - **内部演进流程**: - * `ConfChangeOrchestrator` 先将节点 `2`、`3` 添加为无投票权的 `Learner`。 - * Leader 触发协同刷盘屏障,创建硬链接 SSTable 快照并通过 `InstallSnapshot` 与增量日志追平进度。 - * 当复制延迟低于 `64` 条日志后,通过 OpenRaft 联合共识(Joint Consensus)将其平滑提升为 `Voter`,全程**零写入中断**。 - -### 3.2 多单元(Multi-Cell)存算与控制面分离拓扑(百亿—十万亿级规模) - -当单集群规模超过 `~50,000` 个分片时,可将各角色独立部署并划分为多个自治 **Cell**: - -| 组件角色 | `--role` 参数 | 推荐部署方式 | 核心职责 | -| :--- | :--- | :--- | :--- | -| **全局管理器 (`GlobalManager`)** | `global-manager` | 3 副本 Raft 组 | 维护粗粒度 `[start_key, end_key) -> CellId` 映射、分配 `65,536` 步长全局 ID 号段、管理跨目录移动租约。 | -| **单元管理器 (`CellLocalManager`)** | `cell-manager` | 每 Cell 独立 3 副本组 | 承载本 Cell 内 BE 节点心跳(每 Cell `20K–50K` 分片)、`PID` 分裂调度、Jumbo 独占隔离与副本变更。 | -| **存储后端 (`BE`)** | `be` | 每 Cell `12 – 60+` 台 NVMe 节点 | 承载 Multi-Raft 分片、`MemMvccStore`、`LsmStorageBackend`、`1-RTT` 下推执行与异步发件箱。 | -| **无状态代理 (`Proxy`)** | `proxy` | 弹性扩缩容 / 与 RustFS 同机部署 | 内嵌 `MetaCache`(`>99.9%` 单跳命中率)、编译 20 条 SQL 模板并协调跨分片 2PC 事务。 | +## Stage 3: Intended multi-cell topology (not deployable today) + +Stage 3 is a design target. The current binary does not deploy it. + +`metadbd` only runs `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` in `crates/metadb-server/src/lib.rs` rejects `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` in `crates/metadb-server/src/grpc_services.rs` returns an application error and does not store a second cell. This tree has no live multi-process multi-Cell deployment. + +A second `metadbd --role all-in-one` can join the **same** cell when `--join` or `--cell-manager` names the current leader and the data directory is fresh. That path is covered by `crates/metadb-server/tests/join_existing_group.rs`. The joiner is still an all-in-one process. It is not a role-trimmed backend, and the join does not create another cell. See [Operations](../../zh/operations.md). + +### Step 3.1: Voters inside one cell + +Do not start `metadbd --role be`. That role exits in `open_and_serve`, so those commands are not a runbook. `metadb-ctl raft scale-replicas` calls `ScaleShardReplicas` and requires the requested voter count to already be registered in the cell. A fresh all-in-one cell has one node, so `--target-voters 3` fails until those nodes exist. The constraints are in [Operations](../../zh/operations.md). + +### Step 3.2: Design model for a disaggregated topology (`100B – 10T+` records) + +`100B – 10T+` is a design-model range: arithmetic for how a future multi-cell topology might be sized. It is not a record count this repository has stored. It is also not a Baidu production figure claimed as a result of `rustfs/MetaDB`. Baidu's published sizes, including the BOS2 figure of 1.848 trillion records in `arXiv:2610.32247v1`, are Baidu production metrics, not results of this repository. + +The table is the intended role split. This binary does not run those roles. Jumbo isolation in this tree is a route flag. It does not move peer shards onto a dedicated host. + +| Role | Design `--role` | Intended responsibility | +| :--- | :--- | :--- | +| **Global Manager** | `global-manager` | Would map coarse `[start_key, end_key)` intervals to `CellId`, allocate `65,536`-ID blocks, and coordinate cross-Cell directory rename leases. | +| **Cell Local Manager** | `cell-manager` | Would process BE heartbeats (`20K–50K` shards/Cell) and orchestrate `PID` splits and membership changes. | +| **Backend Storage (`BE`)** | `be` | Would host Multi-Raft shard groups and the LSM engine on NVMe hosts. | +| **Stateless Proxy** | `proxy` | Would embed `MetaCache`, compile the 20 SQL templates, and coordinate cross-shard 2PC. | + +`metadb-ctl cell register` calls `RegisterCell` and exits non-zero. It does not register a cell. Do not use it as a federation step. diff --git a/docs/guides/zh/operations-and-tuning.md b/docs/guides/zh/operations-and-tuning.md index 3a0dec0..ed261ea 100644 --- a/docs/guides/zh/operations-and-tuning.md +++ b/docs/guides/zh/operations-and-tuning.md @@ -34,7 +34,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 bench --workload hotspot-create --concurren ## 2. 超大目录(Jumbo Shard)治理策略 1. **第一级防护:自动节点独占隔离 (`JumboIsolated`)**: - * 当单个目录 (`PID`) 占比超过超限分片容量的 `80%` 无法按 `PID` 边界切分时,`CellLocalManager` 自动将其标记为 `JumboIsolated`,并将同机其他普通分片的 Leader/副本迁移至其他节点,使该大目录独占整台 NVMe 服务器的 I/O 与 CPU。 + * `JumboIsolated` is a route flag. When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent, `JumboIsolationPlanner` writes `dedicated_node` from nodes already registered in this cell. It does not migrate co-hosted peer shards onto another host. With one node, the flag names this process. 2. **第二级防护:双模细粒度分裂 (`DualModeFineGrained`)**: * 当单个目录规模突破单机物理上限(如数亿文件)时,通过 `metadb-ctl shard enable-dual-mode` 开启按 `(PID, name)` 子区间分裂。 * 各非锚点子分片通过本地 `[0x04] DirShardDelta` 记录分片内局部统计信息:`create_file` / `unlink` 依然保持 **单分片 `1-RTT` 无锁写入**,而 `dirstat` 自动切换为 **`1-hop` 并行扇出聚合**。 From c3388a8ce49cbbb98bbc738b31ad29f1bf73c52a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Nov 2026 19:30:18 +0000 Subject: [PATCH 2/5] Qualify MVCC, scale, and locale auth claims Stop stating zero future-read anomalies and a measured 60 percent write reduction. Mark multi-cell evolution and the embedded simulator as they actually run, and describe empty-secret loopback auth in the locale guides as an explicit opt-in. Co-authored-by: RustFS --- Architecture.md | 12 ++++++------ README.md | 6 +++--- docs/de/architecture.md | 4 ++-- docs/de/build-and-run.md | 2 +- docs/de/configuration.md | 7 ++++--- docs/de/operations.md | 4 ++-- docs/fr/architecture.md | 4 ++-- docs/fr/build-and-run.md | 2 +- docs/fr/configuration.md | 7 ++++--- docs/fr/operations.md | 4 ++-- docs/guides/de/deployment.md | 2 +- docs/guides/fr/deployment.md | 2 +- docs/guides/ja/deployment.md | 2 +- docs/guides/zh/deployment.md | 2 +- docs/ja/architecture.md | 4 ++-- docs/ja/build-and-run.md | 2 +- docs/ja/configuration.md | 7 ++++--- docs/ja/operations.md | 4 ++-- docs/zh/architecture.md | 4 ++-- docs/zh/build-and-run.md | 2 +- docs/zh/configuration.md | 7 ++++--- docs/zh/operations.md | 4 ++-- 22 files changed, 49 insertions(+), 45 deletions(-) diff --git a/Architecture.md b/Architecture.md index 918ff53..181b2fb 100644 --- a/Architecture.md +++ b/Architecture.md @@ -14,7 +14,7 @@ Modern exabyte-scale storage systems—including flat object storage (S3/BOS), hierarchical object namespaces (HDFS-compatible Mantle), and POSIX distributed file systems (CFS)—increasingly delegate metadata management to distributed transactional databases. However, Baidu's five-year production experience reported in `arXiv:2610.32247v1` (operating clusters across **1,000+ metadata machines**, **tens of trillions of metadata records**, and **exabytes of storage**) demonstrates a fundamental architectural lesson: **treating a general-purpose distributed database (such as TiDB or CockroachDB) as a "black box" for file-system metadata leaves 2.2x–4.1x throughput untapped and wastes ~50% of cluster hardware.** -**MetaDB** (`rustfs/MetaDB`) is a 100% pure-Rust, file-system structure-aware, semantic-aware, and lifecycle-aware transactional metadata database engine built for [RustFS](https://github.com/rustfs). It is engineered across an 8-crate workspace to support **seamless online evolution from an embedded or standalone single-node deployment (`1-Voter` OpenRaft) to a multi-cell distributed cluster (`3-Voter` Multi-Raft) designed to scale from single-host workloads to 100 billion – 10+ trillion metadata records.** +**MetaDB** (`rustfs/MetaDB`) is a 100% pure-Rust, file-system structure-aware, semantic-aware, and lifecycle-aware transactional metadata database engine built for [RustFS](https://github.com/rustfs). It is an 8-crate workspace. What this binary runs is an embedded persistent engine or a standalone all-in-one process (`1-Voter` OpenRaft), plus a second all-in-one process that can join that same cell. Online evolution to a multi-cell cluster (`3-Voter` Multi-Raft, sized in the design for 100 billion – 10+ trillion metadata records) is a future topology, not a deployment this tree performs. > **Distinguishing Reference Benchmarks from Repository Status**: > Production scale figures cited from `arXiv:2610.32247v1` (for example, Baidu's 575-node BOS2 cluster managing 1.848 trillion records) are Baidu production metrics, not results of this repository. `rustfs/MetaDB` is an independent clean-room Rust implementation. This document is not a first-launch acceptance record and not a scale-gate record. Status wording is in [Section 12](#12-implementation-status-matrix-paper-vs-repository). Operator behavior on current `main` is in [`docs/en`](./docs/en/README.md). @@ -45,8 +45,8 @@ Following the empirical findings of the Baidu MetaDB paper (`arXiv:2610.32247v1` ### 3.1 Goals 1. **Topology-Aligned Single-Shard Execution**: Keep `>96%` of directory modifications strictly within a single shard via `group_key = PID` colocation and execute single-directory Read-Modify-Write (RMW) sequences in a single shard-leader hop (`1 RTT`). 2. **Conflict-Free High-Concurrency Directory Writes**: Eliminate lock contention on hotspot parent directory attributes via lock-free/per-PID in-memory delta aggregation paired with race-free **Read-Path Reconciliation** and a **Coordinated Flush Barrier**. -3. **Zero Double-Tombstone Pure-Rust LSM Storage**: Retain multi-version states strictly in memory (`MemMvccStore` with `SnapshotGuard` registration) for the `5s` transaction window—flushing only collapsed unversioned keys or single physical LSM tombstones (`~60%` KV write reduction)—paired with bottommost-safe **Locality-Aware Compaction**. -4. **Seamless Single-Node to Multi-Cell Evolution**: Run the exact same `StorageBackend` and `openraft` state machine from a single-binary `1-Voter` node to a `3-Voter` Multi-Raft cluster orchestrated by `GlobalManager`, `CellLocalManager`, `MetaCache`, and decentralized `HybridLogicalClock` (`HLC`). +3. **In-memory MVCC, collapsed flush**: Retain multi-version states in memory (`MemMvccStore` with `SnapshotGuard` registration) for the `5s` transaction window and flush collapsed unversioned keys or a single physical LSM tombstone, paired with bottommost-safe **Locality-Aware Compaction**. The `~60%` KV write reduction is a paper/model figure from `arXiv:2610.32247v1`, not a measurement of this repository. The collapse does not prevent every later range read; see Pillar ③. +4. **Runnable single node, future multi-cell topology**: The process that runs is a single-binary `all-in-one` `1-Voter` node, or a second `all-in-one` that joins that cell. A `3-Voter` multi-cell layout with separate `GlobalManager`, `CellLocalManager`, and `MetaCache` processes is a design target, not a topology this binary deploys. The design keeps one `StorageBackend`, one `openraft` state machine, and a decentralized `HybridLogicalClock` (`HLC`). 5. **Lightweight 20-Template SQL & Typed gRPC Interfaces**: Compile the 20 canonical metadata SQL patterns directly into typed storage plans alongside high-throughput `tonic` gRPC services and an embedded Rust SDK. ### 3.2 Non-Goals @@ -119,7 +119,7 @@ flowchart TB * When shard size crosses `shard_split_threshold_bytes` (`4 GiB` production default), `PolicyShardSplitter` scans SSTable block-index midpoints (without reading values) to select a clean `PID` boundary `split_pid`, executing a deterministic `RaftCmd::ExecuteSplit` across replicas. 2. **Two-Level Jumbo Shard Defense (`JumboIsolated` + `DualModeFineGrained`)**: * *Level 1 — Route flag, not a host move*: When one parent owns more than 85% of the shard's `MetaTable` bytes, or the shard has a single parent (`crates/metadb-cluster/src/split_worker.rs`), `maybe_split_or_isolate_shard` stores `ShardHealthState::JumboIsolated { dedicated_node, dominant_pid }` on the route. `JumboIsolationPlanner::select_dedicated_node` picks a node id already registered in this cell. It does not move shard directories and does not migrate co-hosted peer shards off a host. With only the bootstrap node registered, the flag names this process. - * *Level 2 — Dual-Mode `(PID, name)` Split Fallback*: If a single directory outgrows a dedicated node, policy or `metadb-ctl` switches that `PID` to `DualModeFineGrained`, splitting along `(PID, split_name)` boundaries. Non-anchor sub-shards maintain shard-local `DirShardDelta` (`[0x04][pid: 8B BE]`) records initialized at split time: + * *Level 2 — Mode flag, then a later split*: `enable_dual_mode_split` and `metadb-ctl`'s `EnableDualModeSplit` persist `split_mode = DualModeFineGrained` and `dual_mode_pid` on the route. That call does not copy or migrate keys. `split_name` on the request is ignored. A later `ExecuteSplit`, after the route is already in that mode, may cut on a `(pid, name)` midpoint. Non-anchor sub-shards then keep shard-local `DirShardDelta` (`[0x04][pid: 8B BE]`) records initialized at that split: * `create_file` and `unlink` remain **lock-free `1-RTT` single-shard operations** on `route_composite(pid, name)`. * `dirstat(pid)` performs a `1-hop` parallel scatter-gather across the `K` sub-shards covering `[pid, pid+1)`, summing reconciled `num_children` and `size_bytes` and taking `max(modify_time)`. * `listdir(pid, after_name, limit)` streams cursor-paginated entries across sub-shards in lexicographical order. @@ -148,7 +148,7 @@ flowchart TB where `state_flushed_index` advances atomically only when both `MemMvccStore` and folded `AsyncAttrAggregator` updates up to `M` are durable in L0 SSTables + `MANIFEST`, and `aux_outbox_durable_index` advances strictly along contiguous `origin_raft_index` coverage frontiers. 2. **`SnapshotGuard` & `ReadCut` In-Memory MVCC (`MemMvccStore`)**: * Readers register an RAII `SnapshotGuard` pinning an immutable `ReadCut { max_raft_index, max_hlc }` + `Arc` + `Vec>` with bounded per-page step leases (`<= 5,000ms` timeout) in `ActiveSnapshotRegistry`. - * Sealed `ImmMemTable`s wait until `min_active_snapshot_hlc >= imm.max_hlc`, then write **only** the collapsed latest value (`Put`) or a single unversioned physical LSM `Delete` tombstone to a generation-ordered (`flush_generation`) L0 SSTable—mathematically preventing phantom/future-read anomalies while eliminating persisted MVCC tombstones (`~60%` fewer KV writes). + * Sealed `ImmMemTable`s wait until `min_active_snapshot_hlc >= imm.max_hlc`, then write **only** the collapsed latest value (`Put`) or a single unversioned physical LSM `Delete` tombstone to a generation-ordered (`flush_generation`) L0 SSTable. That collapse may keep only the latest value of a key. It does not pin every historical version on the shard, and it does not stop an unversioned SSTable from dropping older versions of other keys. A range read at `start_hlc` can therefore include later values of keys an open 2PC lease does not cover. Point reads of the keys that lease records stay at the pre-image until commit. This is the same limit stated in [`docs/en/architecture.md`](./docs/en/architecture.md). The `~60%` fewer KV writes figure is a paper/model claim from `arXiv:2610.32247v1`, not a measurement of this repository. 3. **Bottommost-Safe Locality-Aware Compaction (`LocalityCompactor`)**: * Tracks physical tombstone counts and tombstone-to-live ratios per 9-byte `[table_prefix][group_key: 8B]` spatial bucket. * When a bucket crosses `tombstone_density_threshold` (e.g., consecutive TTL expirations), `LocalityCompactor` triggers a targeted range compaction over `[bucket, bucket + 1)` spanning all overlapping SSTables down to the bottommost level for that range—legally dropping physical tombstones without rewriting cold neighboring directories. A flat `listdir` P99 under `<4ms` is a design target in `arXiv:2610.32247v1`, not a measured result of this repository. Latency numbers from the earlier single-node comparison on commit `f325f6a` are not results for this tree and are not repeated here. @@ -200,7 +200,7 @@ The stages below are the design path. [Section 12](#12-implementation-status-mat > **Current binary:** `metadbd` only starts with `--role all-in-one`. `PersistentMetaDbCluster::open_and_serve` (`crates/metadb-server/src/lib.rs`) returns an error for `be`, `proxy`, `cell-manager`, and `global-manager` before it listens. `RegisterCell` (`crates/metadb-server/src/grpc_services.rs`) returns an application error whose text says the RPC is not implemented, and it stores nothing. There is no live multi-process multi-Cell deployment in this tree. 1. **Stage 1 — Single-Node All-in-One (`1-Voter` OpenRaft)**: - * A single `metadbd --role all-in-one` binary (or embedded `MetaDbEngine` library) runs `GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy`, and a `1-Voter` OpenRaft group in-process (`0` network hops for `ReadIndex` and consensus commit; sequential disk `fdatasync` only on Raft log segments). + * A single `metadbd --role all-in-one` process runs `GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy`, and a `1-Voter` OpenRaft group in-process (`0` network hops for `ReadIndex` and consensus commit; sequential disk `fdatasync` only on Raft log segments). `MetaDbEngine::open` and `PersistentMetaDbCluster::open_and_serve` are that persistent engine: a data directory, a WAL-less LSM, and OpenRaft. `MetaDbEngine::new_single_node` is not that engine. It is an in-memory simulator with no data directory, no OpenRaft group, and no WAL-less LSM. 2. **Stage 2 — Dynamic Multi-Shard Split on Single Host**: * Starts with root shard `[0, u64::MAX)` and executes `RaftCmd::ExecuteSplit` along `group_key = PID` boundaries as directories grow, so several local Multi-Raft groups share one process. 3. **Stage 3 — Design target only: multi-node and multi-cell (`1 -> 3 -> N` nodes)**: diff --git a/README.md b/README.md index d12dfda..dadbe53 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ General-purpose distributed databases (such as TiDB, CockroachDB, and Foundation ### 1. Tree-Topology-Induced Sharding and Execution (`metadb-cluster` & `metadb-tx`) * **Colocated Schema (`(PID, "_attr_")`)**: `MetaTable` is keyed by `(PID, name)` with `group_key = PID`. A directory's own attributes are stored in a reserved child entry `(PID, "_attr_")` physically adjacent to its direct children `(PID, child_name)`. * **Epoch-Fenced `PID`-Boundary Sharding & Jumbo Defense**: Shards split strictly along `group_key = PID` boundaries under `ShardEpoch` fencing. In this tree, jumbo isolation is a `JumboIsolated` route flag. It does not migrate peer shards to a dedicated host. **`DualModeFineGrained` `(PID, name)` splitting** uses shard-local `DirShardDelta` records for `1-RTT` writes and `1-hop` scatter-gather `dirstat`. -* **Single-Shard Pushdown + Crash-Recoverable 2PC**: Executes single-directory Read-Modify-Write (`create`, `unlink`, `setattr`, `lookup`, `dirstat`, `listdir`, and colocated `mkdir`/`rmdir`) in `1 RTT` on the shard leader, reserving Primary-Anchored 2PC (`WriteIntent` + `TxnRecord`) for cross-shard `rename` (`<3%` of workload) and cross-shard `mkdir`/`rmdir`. +* **Single-Shard Pushdown + Crash-Recoverable 2PC**: Executes single-directory Read-Modify-Write (`create`, `unlink`, `setattr`, `lookup`, `dirstat`, `listdir`, and colocated `mkdir`/`rmdir`) in `1 RTT` on the shard leader, reserving Primary-Anchored 2PC (`WriteIntent` + `TxnRecord`) for cross-shard `rename` and cross-shard `mkdir`/`rmdir`. The `<3%` share of cross-directory `rename` is a Baidu paper workload figure (`arXiv:2610.32247v1`, Table 2), not a benchmark of this repository. ### 2. Semantic-Aware Off-Critical-Path Processing (`metadb-tx`) * **Conflict-Free Asynchronous Attribute Aggregation**: Removes parent directory attribute locks from the foreground write path. Child mutations append deterministic deltas to `AsyncAttrAggregator`, folded into `(PID, "_attr_")` at the L0 SSTable **Coordinated Flush Barrier** while **Read-Path Reconciliation** guarantees linearizable `dirstat` reads. @@ -39,7 +39,7 @@ General-purpose distributed databases (such as TiDB, CockroachDB, and Foundation ### 3. Lifecycle-Aware Pure-Rust Storage Engine (`metadb-storage` & `metadb-raft`) * **WAL-less LSM + 3-Watermark OpenRaft**: Disables local KV WAL files in favor of segmented CRC32C Raft logs (`openraft`), clamping log purge to `min(state_flushed_index, aux_outbox_durable_index, last_snapshot_index)`. -* **`SnapshotGuard` In-Memory MVCC**: Retains multi-version chains in memory for the `5s` transaction window, gating unversioned L0 SSTable collapse-flushes on `ActiveSnapshotRegistry` (`min_active_snapshot_hlc >= imm.max_hlc`) to eliminate persisted MVCC tombstones (`~60%` fewer KV writes) with zero future-read anomalies. +* **`SnapshotGuard` In-Memory MVCC**: Retains multi-version chains in memory for the `5s` transaction window and gates an unversioned L0 collapse-flush on `ActiveSnapshotRegistry` (`min_active_snapshot_hlc >= imm.max_hlc`). That flush may keep only the latest value of a key. It does not pin every historical version, and it does not stop an unversioned SSTable from dropping older versions of other keys. A range read at `start_hlc` can therefore include later values of keys an open 2PC lease does not cover. Point reads of the keys that lease records stay at the pre-image until commit. The `~60%` fewer KV writes figure is a paper/model claim from `arXiv:2610.32247v1`, not a measurement of this repository. The same range-read limit is in [docs/en/architecture.md](./docs/en/architecture.md). * **Bottommost-Safe Locality-Aware Compaction**: Tracks tombstone density per 9-byte prefix bucket and compacts hot deletion ranges down to the deepest overlapping SSTable level. A flat `listdir` P99 under `<4ms` is a design target in `arXiv:2610.32247v1`, not a measurement of this repository. --- @@ -48,7 +48,7 @@ General-purpose distributed databases (such as TiDB, CockroachDB, and Foundation The design keeps one `StorageBackend` and one `openraft` state machine from an embedded single-binary node toward a multi-Cell cluster. Stage 3 is a design target. This binary does not deploy it. -* **Stage 1 — Single-Node All-in-One (`1-Voter` OpenRaft)**: Zero network coordination; sequential Raft log persistence + embedded Rust SDK or `metadbd --role all-in-one`. +* **Stage 1 — Single-Node All-in-One (`1-Voter` OpenRaft)**: Zero network coordination; sequential Raft log persistence with `metadbd --role all-in-one` or the persistent API `MetaDbEngine::open` / `PersistentMetaDbCluster`. `MetaDbEngine::new_single_node` is a separate in-memory simulator: no data directory, no OpenRaft group, and no WAL-less LSM. * **Stage 2 — Dynamic Multi-Shard Split**: Splits shards along `group_key = PID` boundaries on a single host. * **Stage 3 — Multi-Cell Distributed Cluster (design only)**: The design describes `AddLearner`, SSTable snapshot catch-up, joint-consensus voter promotion, decentralized `HLC` clocks, stateless `MetaCache`, and a two-tier control plane. Role-trimmed `be`, `proxy`, `cell-manager`, and `global-manager` processes are not a deployment this tree runs. diff --git a/docs/de/architecture.md b/docs/de/architecture.md index b3ddc96..fae567c 100644 --- a/docs/de/architecture.md +++ b/docs/de/architecture.md @@ -9,13 +9,13 @@ Diese Seite folgt dem Code in `crates/`. Sie beschreibt keinen Mehrprozess-Zelle `PersistentMetaDbCluster::open_and_serve` (`crates/metadb-server/src/lib.rs`): 1. Weist jedes `node.role` außer `all-in-one` zurück. -2. Weist eine Wildcard oder eine andere Nicht-Loopback-Adresse in `grpc_listen_addr` oder `metrics_listen_addr` zurück, wenn `shared_secret` leer ist. Bindet danach `node.grpc_listen_addr` (Vorgabe `127.0.0.1:7800`; `127.0.0.1:0` lässt das Betriebssystem einen Port wählen). +2. An empty `shared_secret` does not start the process unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret plus the flag is rejected. A wildcard or other non-loopback address cannot use the opt-in. It then binds `node.grpc_listen_addr` (default `127.0.0.1:7800`; `127.0.0.1:0` asks the OS for a port). 3. Öffnet `DurableIdAllocator` unter `/global_allocator`. 4. Öffnet `ShardGroupHost` unter `/be`. 5. Öffnet oder bootstrapt `DurableCellManager` unter `/cell_`. 6. Registriert diese eine Zelle bei `DurableGlobalManager` für den Schlüsselbereich `[0x01, 0x04)`. 7. Stellt sicher, dass Wurzel-Inode `1` (`ROOT_INODE_ID`) einen Attributsatz hat. -8. Bedient vier gRPC-Dienste auf demselben Listener. Alle vier nehmen denselben Bearer-Interceptor. Wenn `metrics_listen_addr` gesetzt ist, verlangt `GET /metrics` auf dieser Adresse dasselbe Geheimnis. Ein nicht leeres Geheimnis weist einen fehlenden oder falschen Bearer zurück. Ein leeres Geheimnis wird nur für Loopback-Binds akzeptiert. Dieser Prozess beendet TLS nicht. +8. Serves four gRPC services on one listener. All four use the same bearer interceptor. When `metrics_listen_addr` is set, `GET /metrics` on that address requires the same secret. A non-empty secret rejects a missing or wrong bearer. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This process does not terminate TLS. 9. Startet eine Wartungsaufgabe im Abstand von 250 ms. `metadbd` ist eine dünne Hülle: Es lädt TOML, wendet CLI-Überschreibungen an, ruft `open_and_serve` auf, ruft optional `RegisterNode` an `--cell-manager` auf und ruft bei Strg-C `shutdown` auf. Metriken werden, wenn konfiguriert, in `open_and_serve` bedient. diff --git a/docs/de/build-and-run.md b/docs/de/build-and-run.md index d3bc38c..039aaed 100644 --- a/docs/de/build-and-run.md +++ b/docs/de/build-and-run.md @@ -64,7 +64,7 @@ cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml Logs verwenden den `EnvFilter` von `tracing-subscriber`. Der Standardfilter ist `info`. Überschreiben mit der üblichen Variable `RUST_LOG`, zum Beispiel `RUST_LOG=debug`. -Beim Start mit leerem `security.shared_secret` schreibt der Prozess eine Warnung, dass Loopback-gRPC keine Authentifizierung hat. Die Standardbindung ist `127.0.0.1`. Eine Wildcard oder eine andere Nicht-Loopback-Adresse mit leerem, fehlendem oder falsch geschriebenem Geheimnis verweigert das Binden. Ein nicht leeres `[security].shared_secret` verlangt denselben Bearer für Metadaten-, Transaktions-, Control-Plane- und Raft-Transport-RPCs sowie für `GET /metrics`. Der Prozess beendet TLS nicht. Ein TLS- oder Zertifikatsschlüssel in der Konfiguration lässt den Start fehlschlagen, statt Klartext zu dienen. Den Listener in einem vertrauenswürdigen Netz lassen, oder jeden Dienst hinter einen Proxy setzen, der Clients authentifiziert, und den direkten Zugriff auf diesen Prozess sperren. +An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Strg-C schreibt den Shard-Zustand und stoppt die OpenRaft-Gruppen (`cluster.shutdown()`). diff --git a/docs/de/configuration.md b/docs/de/configuration.md index 4160e9d..2da3a15 100644 --- a/docs/de/configuration.md +++ b/docs/de/configuration.md @@ -13,7 +13,7 @@ | `node.role` | `all-in-one` | Ja. Jeder andere Wert liefert einen Fehler | | `node.data_dir` | `./metadb-data` | Ja | | `node.grpc_listen_addr` | `127.0.0.1:7800` | Ja. Bind-Adresse | -| `node.metrics_listen_addr` | nicht gesetzt | Ja, nur wenn gesetzt. Eigener TCP-Listener. Eine Nicht-Loopback-Adresse verlangt ein nicht leeres Geheimnis | +| `node.metrics_listen_addr` | nicht gesetzt | Applied only when set. Separate TCP listener. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only | | `clock.max_clock_drift_ms` | `500` | Ja. `HybridLogicalClock::with_max_drift_ms` | | `storage.memtable_size_bytes` | `33554432` (32 MiB) | Ja. Versiegelt und schreibt die aktive Memtable aus, sobald ihre angerechneten Bytes diese Größe erreichen. Werte unter 1 gelten als 1 | | `storage.max_imm_memtables` | `4` | Ja. Schreiber warten, statt mehr unveränderliche Memtables als diese Obergrenze einzureihen | @@ -24,7 +24,8 @@ | `storage.locality_tombstone_ratio` | `0.50` | Ja. Mal 1000, auf 1..=1000 begrenzt, gespeichert als `tombstone_min_ratio_permille` | | `sharding.bootstrap_table_shards` | `true` | Ja. `true` erzeugt die Shards 1, 2 und 3. `false` erzeugt Shard 1 über `[0x01, 0x04)` | | `sharding.shard_split_threshold_bytes` | `4294967296` (4 GiB) | Ja. Die Split-Prüfung nutzt die ungefähre Shard-Größe | -| `security.shared_secret` | `""` | Ja. Leer ist nur zulässig, wenn jeder Listener Loopback ist. Nicht leer verlangt denselben Bearer für gRPC und Metriken | +| `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | Es gibt keine Tabelle `[raft]`. `ServerTomlConfig.raft_options` wird von serde übersprungen und bleibt bei `RaftNodeOptions::default()` (Heartbeat 150 ms, Wahl 450–900 ms, Snapshot-Log-Behalten 0, Segment 64 MiB). @@ -73,7 +74,7 @@ Dieser Prozess beendet TLS nicht. Es gibt keine Zertifikatskonfiguration, die na Wenn `shared_secret` nicht leer ist, verlangen `MetadataService`, `TransactionService`, `ControlPlaneService` und `RaftTransportService`, dass `authorization` genau `Bearer ` ist. `GET /metrics` auf `metrics_listen_addr` verlangt denselben `Authorization`-Header. Ein fehlender Header, ein leerer Bearer, ein Präfix oder ein längerer Token wird abgelehnt. Der Fehlerkörper der Metriken ist kein Prometheus-Text. Raft-Peers senden denselben Bearer. `metadb-ctl --auth-token` (Umgebungsvariable `METADB_AUTH_TOKEN`) und `metadbd --join` / `--cell-manager` senden ihn. `metadb-ctl cluster status` ruft `GetRoutes` auf und liegt unter demselben Interceptor. -Ein leeres oder nur aus Leerzeichen bestehendes Geheimnis ist nur zulässig, wenn `grpc_listen_addr` und, falls gesetzt, `metrics_listen_addr` Loopback sind (`127.0.0.0/8`, `::1` oder der Name `localhost`). Eine Wildcard (`0.0.0.0`, `::`) oder jede andere Adresse verweigert das Binden. Ein leeres Loopback-Geheimnis wird beim Start gewarnt. Die Listener bleiben Klartext. Sie in einem vertrauenswürdigen Netz lassen, oder jeden Dienst hinter einen Proxy setzen, der den Client authentifiziert, und den direkten Zugriff auf diesen Prozess sperren. +An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## Was sich nicht konfigurieren lässt diff --git a/docs/de/operations.md b/docs/de/operations.md index 91f4875..dde24c6 100644 --- a/docs/de/operations.md +++ b/docs/de/operations.md @@ -71,7 +71,7 @@ Siehe [Tests und Benches](./testing.md#metadb-ctl-bench). Das ist ein Client geg ## Metriken -`node.metrics_listen_addr` setzen (zum Beispiel `127.0.0.1:9100`). `open_and_serve` nimmt auf dieser Adresse TCP-Verbindungen an. `GET /metrics` liefert Prometheus-Text. Jeder andere Pfad liefert 404, jede andere Methode 405. Wenn `[security].shared_secret` nicht leer ist, muss jede Anfrage auf diesem Listener `Authorization: Bearer ` senden. Ein fehlender, leerer oder falscher Bearer liefert HTTP 401 und einen Rumpf, der nicht der Metriktext ist, auch für `/status`. Eine Nicht-Loopback-Metrikadresse mit leerem Geheimnis verweigert den Start. Dieser Listener beendet TLS nicht. +`node.metrics_listen_addr` setzen (zum Beispiel `127.0.0.1:9100`). `open_and_serve` nimmt auf dieser Adresse TCP-Verbindungen an. `GET /metrics` liefert Prometheus-Text. Jeder andere Pfad liefert 404, jede andere Methode 405. Wenn `[security].shared_secret` nicht leer ist, muss jede Anfrage auf diesem Listener `Authorization: Bearer ` senden. Ein fehlender, leerer oder falscher Bearer liefert HTTP 401 und einen Rumpf, der nicht der Metriktext ist, auch für `/status`. An empty secret does not start the process on any address, including loopback, unless `allow_unauthenticated = true`. That flag is loopback-only and still refuses a wildcard or other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This listener does not terminate TLS. Gauges und Counter aus `render_prometheus_metrics`: @@ -136,7 +136,7 @@ Die Varianten sind in `crates/metadb-core/src/error.rs` definiert. gRPC-Methoden - `GetRoutes` scheitert geschlossen bei einer unbekannten `cell_id` ungleich null. `StoreHeartbeat` ersetzt zwischengespeicherte Routen nicht. - Jumbo-Isolation ist ein Routenflag plus eine Knotenkennung aus der lokalen Knotentabelle. Sie verdrängt andere Shards nicht von einer Platte. - Heartbeats sind ein RPC ohne Sender in `metadbd`. `StoreHeartbeat` speichert nicht dauerhaft. -- Ein nicht leeres gemeinsames Geheimnis authentifiziert Raft, die drei anderen gRPC-Dienste und den Metrik-Listener mit demselben Bearer. Ein leeres Geheimnis wird nur für Loopback-Binds akzeptiert und lässt diese Listener unauthentifiziert. Ein Wildcard-Bind mit leerem Geheimnis verweigert den Start. Der Prozess beendet TLS nicht. +- A non-empty shared secret authenticates Raft, the other three gRPC services, and the metrics listener with the same bearer. An empty secret does not start the process, including on loopback. `allow_unauthenticated = true` is the explicit opt-in for empty-secret loopback development and still refuses a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with that opt-in. A usable secret combined with the opt-in is rejected. The process does not terminate TLS. - `memtable_size_bytes` versiegelt die aktive Memtable und schreibt sie aus. `max_imm_memtables` begrenzt die eingereihten unveränderlichen Tabellen. Raft-Zeitgeberfelder ändern das Laufzeitverhalten über TOML nicht. - `metadb-ctl bench` für `hotspot-create` und `bulk-ttl-delete` druckt JSON-Zeilen: einen Kopf mit `bench_pid`, dann Phasenberichte mit attempted, succeeded, failed und Latenzperzentilen. Der Prozess endet mit einem Fehler, wenn nicht jede angeforderte Operation gelingt. `--workload mixed` oder `--embedded` startet den prozessinternen Stress-Harness. `sql` druckt die Antwort als JSON und endet bei einem Anwendungsfehler mit einem Fehlerstatus. diff --git a/docs/fr/architecture.md b/docs/fr/architecture.md index c5da223..987826d 100644 --- a/docs/fr/architecture.md +++ b/docs/fr/architecture.md @@ -9,13 +9,13 @@ Cette page suit le code de `crates/`. Elle ne décrit pas un déploiement de cel `PersistentMetaDbCluster::open_and_serve` (`crates/metadb-server/src/lib.rs`) : 1. Rejette tout `node.role` autre que `all-in-one`. -2. Refuse un joker ou une autre adresse non locale dans `grpc_listen_addr` ou `metrics_listen_addr` lorsque `shared_secret` est vide. Lie ensuite `node.grpc_listen_addr` (défaut `127.0.0.1:7800` ; `127.0.0.1:0` demande un port au système). +2. An empty `shared_secret` does not start the process unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret plus the flag is rejected. A wildcard or other non-loopback address cannot use the opt-in. It then binds `node.grpc_listen_addr` (default `127.0.0.1:7800`; `127.0.0.1:0` asks the OS for a port). 3. Ouvre `DurableIdAllocator` dans `/global_allocator`. 4. Ouvre `ShardGroupHost` dans `/be`. 5. Ouvre ou amorce `DurableCellManager` dans `/cell_`. 6. Enregistre cette unique cellule sur `DurableGlobalManager` pour l'intervalle de clés `[0x01, 0x04)`. 7. Garantit que l'inode racine `1` (`ROOT_INODE_ID`) possède un enregistrement d'attributs. -8. Sert quatre services gRPC sur le même écouteur. Les quatre prennent le même intercepteur bearer. Lorsque `metrics_listen_addr` est défini, `GET /metrics` sur cette adresse exige le même secret. Un secret non vide rejette un bearer absent ou incorrect. Un secret vide n'est accepté que pour les liaisons en boucle locale. Ce processus ne termine pas TLS. +8. Serves four gRPC services on one listener. All four use the same bearer interceptor. When `metrics_listen_addr` is set, `GET /metrics` on that address requires the same secret. A non-empty secret rejects a missing or wrong bearer. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This process does not terminate TLS. 9. Lance une tâche de maintenance toutes les 250 ms. `metadbd` est une fine enveloppe : il charge le TOML, applique les remplacements CLI, appelle `open_and_serve`, appelle éventuellement `RegisterNode` sur `--cell-manager`, et sur Ctrl-C appelle `shutdown`. Les métriques, lorsqu'elles sont configurées, sont servies dans `open_and_serve`. diff --git a/docs/fr/build-and-run.md b/docs/fr/build-and-run.md index b14c73a..6b321ba 100644 --- a/docs/fr/build-and-run.md +++ b/docs/fr/build-and-run.md @@ -64,7 +64,7 @@ cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml Les journaux utilisent l'`EnvFilter` de `tracing-subscriber`. Le filtre par défaut est `info`. On le remplace avec la variable standard `RUST_LOG`, par exemple `RUST_LOG=debug`. -Au démarrage, si `security.shared_secret` est vide, le processus journalise un avertissement : le gRPC en boucle locale n'a pas d'authentification. La liaison par défaut est `127.0.0.1`. Un joker ou une autre adresse non locale avec un secret vide, absent ou mal orthographié refuse d'écouter. Un `[security].shared_secret` non vide exige le même bearer pour les RPC de métadonnées, de transaction, de plan de contrôle, de transport Raft, et pour `GET /metrics`. Le processus ne termine pas TLS. Une clé TLS ou de certificat dans la configuration fait échouer le démarrage au lieu de servir en clair. Garder l'écouteur sur un réseau de confiance, ou placer chaque service derrière un proxy qui authentifie les clients, et bloquer l'accès direct à ce processus. +An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C vide l'état des shards et arrête les groupes OpenRaft (`cluster.shutdown()`). diff --git a/docs/fr/configuration.md b/docs/fr/configuration.md index c234fe6..94e914f 100644 --- a/docs/fr/configuration.md +++ b/docs/fr/configuration.md @@ -13,7 +13,7 @@ | `node.role` | `all-in-one` | Oui. Toute autre valeur renvoie une erreur | | `node.data_dir` | `./metadb-data` | Oui | | `node.grpc_listen_addr` | `127.0.0.1:7800` | Oui. Adresse de liaison | -| `node.metrics_listen_addr` | non défini | Oui, seulement s'il est défini. Écouteur TCP séparé. Une adresse non locale exige un secret non vide | +| `node.metrics_listen_addr` | non défini | Applied only when set. Separate TCP listener. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only | | `clock.max_clock_drift_ms` | `500` | Oui. `HybridLogicalClock::with_max_drift_ms` | | `storage.memtable_size_bytes` | `33554432` (32 Mio) | Oui. Scelle et vide le memtable actif dès que ses octets comptabilisés atteignent cette taille. Les valeurs inférieures à 1 sont traitées comme 1 | | `storage.max_imm_memtables` | `4` | Oui. Les écritures attendent au lieu de mettre en file plus de memtables immuables que ce plafond | @@ -24,7 +24,8 @@ | `storage.locality_tombstone_ratio` | `0.50` | Oui. Multiplié par 1000, borné à 1..=1000, stocké dans `tombstone_min_ratio_permille` | | `sharding.bootstrap_table_shards` | `true` | Oui. `true` crée les shards 1, 2 et 3. `false` crée le shard 1 sur `[0x01, 0x04)` | | `sharding.shard_split_threshold_bytes` | `4294967296` (4 Gio) | Oui. Le contrôle de découpage utilise la taille approximative du shard | -| `security.shared_secret` | `""` | Oui. Vide n'est accepté que si chaque écouteur est en boucle locale. Non vide exige le même bearer pour le gRPC et les métriques | +| `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | Il n'y a pas de table `[raft]`. `ServerTomlConfig.raft_options` est ignoré par serde et reste à `RaftNodeOptions::default()` (battement 150 ms, élection 450–900 ms, conservation du journal d'instantané 0, segment 64 Mio). @@ -73,7 +74,7 @@ Ce processus ne termine pas TLS. Aucune configuration de certificat n'active un Lorsque `shared_secret` n'est pas vide, `MetadataService`, `TransactionService`, `ControlPlaneService` et `RaftTransportService` exigent que `authorization` soit exactement `Bearer `. `GET /metrics` sur `metrics_listen_addr` exige le même en-tête `Authorization`. Un en-tête absent, un bearer vide, un préfixe ou un jeton plus long est rejeté. Le corps d'échec des métriques n'est pas du texte Prometheus. Les pairs Raft envoient le même bearer. `metadb-ctl --auth-token` (variable d'environnement `METADB_AUTH_TOKEN`) et `metadbd --join` / `--cell-manager` l'envoient. `metadb-ctl cluster status` appelle `GetRoutes` et passe par le même intercepteur. -Un secret vide ou composé seulement d'espaces n'est accepté que si `grpc_listen_addr` et `metrics_listen_addr` (s'il est défini) sont en boucle locale (`127.0.0.0/8`, `::1`, ou le nom `localhost`). Un joker (`0.0.0.0`, `::`) ou toute autre adresse refuse d'écouter. Un secret vide en boucle locale produit un avertissement au démarrage. Les écouteurs restent en clair. Les garder sur un réseau de confiance, ou placer chaque service derrière un proxy qui authentifie le client, et bloquer l'accès direct à ce processus. +An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## Ce que l'on ne peut pas configurer diff --git a/docs/fr/operations.md b/docs/fr/operations.md index 3243ba1..e8adc18 100644 --- a/docs/fr/operations.md +++ b/docs/fr/operations.md @@ -71,7 +71,7 @@ Voir [Tests et bancs](./testing.md#metadb-ctl-bench). C'est un client contre un ## Métriques -Définir `node.metrics_listen_addr` (par exemple `127.0.0.1:9100`). `open_and_serve` accepte les connexions TCP sur cette adresse. `GET /metrics` renvoie du texte Prometheus. Tout autre chemin renvoie 404, et toute autre méthode renvoie 405. Lorsque `[security].shared_secret` n'est pas vide, chaque requête sur cet écouteur doit envoyer `Authorization: Bearer `. Un bearer absent, vide ou incorrect renvoie HTTP 401 et un corps qui n'est pas le texte des métriques, y compris une requête vers `/status`. Une adresse de métriques non locale avec un secret vide refuse de démarrer. Cet écouteur ne termine pas TLS. +Définir `node.metrics_listen_addr` (par exemple `127.0.0.1:9100`). `open_and_serve` accepte les connexions TCP sur cette adresse. `GET /metrics` renvoie du texte Prometheus. Tout autre chemin renvoie 404, et toute autre méthode renvoie 405. Lorsque `[security].shared_secret` n'est pas vide, chaque requête sur cet écouteur doit envoyer `Authorization: Bearer `. Un bearer absent, vide ou incorrect renvoie HTTP 401 et un corps qui n'est pas le texte des métriques, y compris une requête vers `/status`. An empty secret does not start the process on any address, including loopback, unless `allow_unauthenticated = true`. That flag is loopback-only and still refuses a wildcard or other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This listener does not terminate TLS. Jauges et compteurs de `render_prometheus_metrics` : @@ -136,7 +136,7 @@ Les variantes sont définies dans `crates/metadb-core/src/error.rs`. Les méthod - `GetRoutes` échoue fermé pour un `cell_id` non nul inconnu. `StoreHeartbeat` ne remplace pas les routes en cache. - L'isolation jumbo est un indicateur de route plus un identifiant de nœud choisi dans la table locale. Elle n'évince pas d'autres shards d'un disque. - Les battements de cœur sont un RPC sans émetteur dans `metadbd`. `StoreHeartbeat` ne persiste pas. -- Un secret partagé non vide authentifie Raft, les trois autres services gRPC et l'écouteur de métriques avec le même bearer. Un secret vide n'est accepté que pour les liaisons en boucle locale et laisse ces écouteurs non authentifiés. Une liaison joker avec un secret vide refuse de démarrer. Le processus ne termine pas TLS. +- A non-empty shared secret authenticates Raft, the other three gRPC services, and the metrics listener with the same bearer. An empty secret does not start the process, including on loopback. `allow_unauthenticated = true` is the explicit opt-in for empty-secret loopback development and still refuses a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with that opt-in. A usable secret combined with the opt-in is rejected. The process does not terminate TLS. - `memtable_size_bytes` scelle et vide le memtable actif. `max_imm_memtables` limite les tables immuables en file. Les champs de temporisation Raft ne changent pas le comportement d'exécution via le TOML. - `metadb-ctl bench` pour `hotspot-create` et `bulk-ttl-delete` imprime des lignes JSON : un en-tête avec `bench_pid`, puis des rapports de phase avec attempted, succeeded, failed et des percentiles de latence. Le processus se termine en erreur si une opération demandée échoue. `--workload mixed` ou `--embedded` lance le harnais de stress dans le processus. `sql` imprime la réponse en JSON et se termine en erreur sur une erreur d'application. diff --git a/docs/guides/de/deployment.md b/docs/guides/de/deployment.md index 0a8167c..eb7590f 100644 --- a/docs/guides/de/deployment.md +++ b/docs/guides/de/deployment.md @@ -34,7 +34,7 @@ bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 GiB ``` -Rust 1.100.0 (`rust-toolchain.toml`). Nur die Rolle `all-in-one` startet. Dieser Prozess beendet TLS nicht. Ohne `[security].shared_secret` gibt es keine Authentifizierung, und nur Loopback-Binds werden akzeptiert. Der Default ist `127.0.0.1`. Eine Wildcard oder eine andere Adresse mit leerem Geheimnis verweigert den Start. Ein nicht leeres `shared_secret` verlangt `authorization: Bearer ` für Metadaten, Transaktionen, die Control Plane, Raft auf demselben Port und `GET /metrics`. +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. ```bash metadbd --config /etc/metadb/standalone.toml diff --git a/docs/guides/fr/deployment.md b/docs/guides/fr/deployment.md index c1ea16d..2d15d77 100644 --- a/docs/guides/fr/deployment.md +++ b/docs/guides/fr/deployment.md @@ -34,7 +34,7 @@ bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 Gio ``` -Rust 1.100.0 (`rust-toolchain.toml`). Seul le rôle `all-in-one` démarre. Ce processus ne termine pas TLS. Sans `[security].shared_secret`, il n'y a pas d'authentification, et seules les liaisons en boucle locale sont acceptées. Le défaut est `127.0.0.1`. Un joker ou une autre adresse avec un secret vide refuse de démarrer. Un `shared_secret` non vide exige `authorization: Bearer ` pour les métadonnées, les transactions, le plan de contrôle, Raft sur le même port, et `GET /metrics`. +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. ```bash metadbd --config /etc/metadb/standalone.toml diff --git a/docs/guides/ja/deployment.md b/docs/guides/ja/deployment.md index 58bff2a..1001e5a 100644 --- a/docs/guides/ja/deployment.md +++ b/docs/guides/ja/deployment.md @@ -34,7 +34,7 @@ bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 GiB ``` -Rust 1.100.0(`rust-toolchain.toml`)。実装されているロールは `all-in-one` のみ。このプロセスは TLS を終端しない。空の `[security].shared_secret` では認証もなく、待受はループバックだけを受け付ける。既定は `127.0.0.1`。ワイルドカードやそれ以外のアドレスに空のシークレットがあると起動を拒否する。空でない `shared_secret` は metadata、transaction、control-plane、同じポートの Raft 転送、および `GET /metrics` に `authorization: Bearer ` を要求する。 +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. ```bash metadbd --config /etc/metadb/standalone.toml diff --git a/docs/guides/zh/deployment.md b/docs/guides/zh/deployment.md index 9a6e782..599063d5 100644 --- a/docs/guides/zh/deployment.md +++ b/docs/guides/zh/deployment.md @@ -42,7 +42,7 @@ shard_split_threshold_bytes = 4294967296 # 4 GiB 分片分裂阈值 工具链固定为 Rust **1.100.0**(`rust-toolchain.toml`)。当前只有 `all-in-one` 会真正启动;`be` / `proxy` / `cell-manager` / `global-manager` 会被拒绝,而不是静默变成全功能进程。 -gRPC 的 metadata、transaction、control-plane、Raft 传输以及指标监听器**都不终结 TLS**。`[security].shared_secret` 为空时也没有应用层认证,并且只接受环回绑定。通配或其他非环回地址如果没有非空密钥,会拒绝启动。默认 `grpc_listen_addr` 是 `127.0.0.1:7800`。文件里的 TLS 或证书键会被拒绝,而不是当作明文服务。非空 `shared_secret` 要求 metadata、transaction、control-plane、同一端口上的 Raft 传输以及 `GET /metrics` 都携带 `authorization: Bearer `。对等 Raft 客户端发送同一个令牌。 +Metadata, transaction, control-plane, and Raft gRPC, and the metrics listener, do not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1:7800` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. Peer Raft clients send the same token. A TLS or certificate key in the file is rejected rather than served as plaintext. ```bash metadbd --config /etc/metadb/standalone.toml diff --git a/docs/ja/architecture.md b/docs/ja/architecture.md index 3521509..e29aa2d 100644 --- a/docs/ja/architecture.md +++ b/docs/ja/architecture.md @@ -9,13 +9,13 @@ `PersistentMetaDbCluster::open_and_serve`(`crates/metadb-server/src/lib.rs`)は次を行います。 1. `all-in-one` 以外の `node.role` を拒否する。 -2. `shared_secret` が空のとき、ワイルドカードまたはループバック以外の `grpc_listen_addr` と `metrics_listen_addr` を拒否する。その後 `node.grpc_listen_addr` をバインドする(既定は `127.0.0.1:7800`。`127.0.0.1:0` は OS にポートを選ばせる)。 +2. An empty `shared_secret` does not start the process unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret plus the flag is rejected. A wildcard or other non-loopback address cannot use the opt-in. It then binds `node.grpc_listen_addr` (default `127.0.0.1:7800`; `127.0.0.1:0` asks the OS for a port). 3. `/global_allocator` で `DurableIdAllocator` を開く。 4. `/be` で `ShardGroupHost` を開く。 5. `/cell_` で `DurableCellManager` を開くかブートストラップする。 6. その 1 つのセルを、キー範囲 `[0x01, 0x04)` で `DurableGlobalManager` に登録する。 7. ルートの inode `1`(`ROOT_INODE_ID`)に属性レコードがあることを保証する。 -8. 同じリスナーで 4 つの gRPC サービスを提供する。4 つとも同じベアラインターセプタを取る。`metrics_listen_addr` が設定されているとき、そのアドレスの `GET /metrics` は同じシークレットを要求する。シークレットが空でなければ、欠落または誤ったベアラは拒否される。空のシークレットはループバックのバインドだけを受け付ける。このプロセスは TLS を終端しない。 +8. Serves four gRPC services on one listener. All four use the same bearer interceptor. When `metrics_listen_addr` is set, `GET /metrics` on that address requires the same secret. A non-empty secret rejects a missing or wrong bearer. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This process does not terminate TLS. 9. 250 ms 間隔のメンテナンスタスクを起動する。 `metadbd` は薄いラッパです。TOML を読み、CLI の上書きを適用し、`open_and_serve` を呼び、任意で `--cell-manager` へ `RegisterNode` を呼び、Ctrl-C で `shutdown` を呼びます。メトリクスは設定されているとき `open_and_serve` の中で提供されます。 diff --git a/docs/ja/build-and-run.md b/docs/ja/build-and-run.md index 7522b2a..c165ca5 100644 --- a/docs/ja/build-and-run.md +++ b/docs/ja/build-and-run.md @@ -64,7 +64,7 @@ cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml ログは `tracing-subscriber` の `EnvFilter` を使います。既定のフィルタは `info` です。標準の環境変数 `RUST_LOG` で上書きします。例: `RUST_LOG=debug`。 -`security.shared_secret` が空のとき、起動時にループバックの gRPC には認証が無いという警告が出ます。既定のバインドは `127.0.0.1` です。ワイルドカードまたはループバック以外のアドレスで、シークレットが空、欠落、または綴り違いなら待受を拒否します。空でない `[security].shared_secret` は、メタデータ、トランザクション、コントロールプレーン、Raft 転送、および `GET /metrics` に同じベアラを要求します。プロセスは TLS を終端しません。設定中の TLS または証明書キーは、平文で提供する代わりに起動を失敗させます。リスナーを信頼できるネットワークに留めるか、すべてのサービスを、クライアントを認証するプロキシの後ろに置き、このプロセスへの直接アクセスを塞いでください。 +An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C はシャード状態をフラッシュし、OpenRaft グループを止めます(`cluster.shutdown()`)。 diff --git a/docs/ja/configuration.md b/docs/ja/configuration.md index d379043..30fd3fa 100644 --- a/docs/ja/configuration.md +++ b/docs/ja/configuration.md @@ -13,7 +13,7 @@ | `node.role` | `all-in-one` | する。それ以外の値はエラー | | `node.data_dir` | `./metadb-data` | する | | `node.grpc_listen_addr` | `127.0.0.1:7800` | する。バインドアドレス | -| `node.metrics_listen_addr` | 未設定 | 設定されたときだけする。別の TCP リスナー。ループバック以外は空でないシークレットが必要 | +| `node.metrics_listen_addr` | 未設定 | Applied only when set. Separate TCP listener. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only | | `clock.max_clock_drift_ms` | `500` | する。`HybridLogicalClock::with_max_drift_ms` | | `storage.memtable_size_bytes` | `33554432`(32 MiB) | する。計上バイトがこの大きさに達したとき、アクティブな memtable を封印してフラッシュする。1 未満は 1 として扱う | | `storage.max_imm_memtables` | `4` | する。書き手はこの上限を超える不変 memtable をキューに積まず、待つ | @@ -24,7 +24,8 @@ | `storage.locality_tombstone_ratio` | `0.50` | する。1000 倍し、1..=1000 にクランプし、`tombstone_min_ratio_permille` として保存する | | `sharding.bootstrap_table_shards` | `true` | する。`true` はシャード 1、2、3 を作る。`false` は `[0x01, 0x04)` を覆うシャード 1 を作る | | `sharding.shard_split_threshold_bytes` | `4294967296`(4 GiB) | する。分割判定はシャードの概算サイズを使う | -| `security.shared_secret` | `""` | する。空は全リスナーがループバックのときだけ受け付ける。空でない値は gRPC とメトリクスに同じベアラを要求する | +| `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | `[raft]` テーブルはありません。`ServerTomlConfig.raft_options` は serde がスキップし、`RaftNodeOptions::default()` のままです(ハートビート 150 ms、選挙 450–900 ms、スナップショットログ保持 0、セグメント 64 MiB)。 @@ -73,7 +74,7 @@ CLI フラグはファイルを解析したあとで上書きします。`--node `shared_secret` が空でないとき、`MetadataService`、`TransactionService`、`ControlPlaneService`、`RaftTransportService` は `authorization` が `Bearer ` と完全に一致することを要求します。`metrics_listen_addr` の `GET /metrics` も同じ `Authorization` ヘッダを要求します。ヘッダの欠落、空のベアラ、接頭辞、より長いトークンは拒否されます。失敗したメトリクス応答の本体は Prometheus テキストではありません。Raft ピアは同じベアラを送ります。`metadb-ctl --auth-token`(環境変数 `METADB_AUTH_TOKEN`)と `metadbd --join` / `--cell-manager` も送ります。`metadb-ctl cluster status` は `GetRoutes` を呼び、同じインターセプタの対象です。 -空、または空白だけのシークレットは、`grpc_listen_addr` と設定済みの `metrics_listen_addr` がどちらもループバック(`127.0.0.0/8`、`::1`、または名前 `localhost`)のときだけ受け付けます。ワイルドカード(`0.0.0.0`、`::`)やそれ以外のアドレスは待受を拒否します。空のループバックシークレットは起動時に警告されます。リスナーは引き続き平文です。信頼できるネットワークに留めるか、すべてのサービスをクライアントを認証するプロキシの後ろに置き、このプロセスへの直接アクセスを塞いでください。 +An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## 設定できないもの diff --git a/docs/ja/operations.md b/docs/ja/operations.md index cd14977..108cec8 100644 --- a/docs/ja/operations.md +++ b/docs/ja/operations.md @@ -71,7 +71,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 sql \ ## メトリクス -`node.metrics_listen_addr` を設定します(例: `127.0.0.1:9100`)。`open_and_serve` がそのアドレスで TCP 接続を受けます。`GET /metrics` は Prometheus テキストを返します。他のパスは 404、他のメソッドは 405 です。`[security].shared_secret` が空でないとき、このリスナーのすべての要求は `Authorization: Bearer ` を送らなければなりません。欠落、空、または誤ったベアラは HTTP 401 を返し、本体はメトリクス本文ではありません。`/status` への要求も同じです。空のシークレットでループバック以外のメトリクスアドレスは起動を拒否します。このリスナーは TLS を終端しません。 +`node.metrics_listen_addr` を設定します(例: `127.0.0.1:9100`)。`open_and_serve` がそのアドレスで TCP 接続を受けます。`GET /metrics` は Prometheus テキストを返します。他のパスは 404、他のメソッドは 405 です。`[security].shared_secret` が空でないとき、このリスナーのすべての要求は `Authorization: Bearer ` を送らなければなりません。欠落、空、または誤ったベアラは HTTP 401 を返し、本体はメトリクス本文ではありません。`/status` への要求も同じです。An empty secret does not start the process on any address, including loopback, unless `allow_unauthenticated = true`. That flag is loopback-only and still refuses a wildcard or other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This listener does not terminate TLS. `render_prometheus_metrics` のゲージとカウンタ: @@ -136,7 +136,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 sql \ - 未知で非ゼロの `cell_id` に対する `GetRoutes` は失敗して閉じる。`StoreHeartbeat` はキャッシュ済みルートを置き換えない。 - ジャンボ隔離はルートフラグと、ローカルノード表から選んだノード ID である。他のシャードをディスクから追い出すことはしない。 - ハートビートは RPC であり、`metadbd` に送信側はない。`StoreHeartbeat` は永続化しない。 -- 空でない共有シークレットは、Raft、他の 3 つの gRPC サービス、およびメトリクスリスナーを同じベアラで認証する。空のシークレットはループバックのバインドだけを受け付け、それらのリスナーは無認証のままである。空のシークレットでのワイルドカードバインドは起動を拒否する。プロセスは TLS を終端しない。 +- A non-empty shared secret authenticates Raft, the other three gRPC services, and the metrics listener with the same bearer. An empty secret does not start the process, including on loopback. `allow_unauthenticated = true` is the explicit opt-in for empty-secret loopback development and still refuses a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with that opt-in. A usable secret combined with the opt-in is rejected. The process does not terminate TLS. - `memtable_size_bytes` はアクティブな memtable を封印してフラッシュする。`max_imm_memtables` はキューに積まれた不変テーブルの数を抑える。Raft のタイマ項目は、TOML 経由で実行時の挙動を変えない。 - `hotspot-create` と `bulk-ttl-delete` の `metadb-ctl bench` は JSON 行を印字する。`bench_pid` を含むヘッダのあと、attempted、succeeded、failed とレイテンシのパーセンタイルを持つフェーズ報告が続く。要求した操作がすべて成功しない限り、プロセスは非ゼロで終了する。`--workload mixed` または `--embedded` はプロセス内のストレステストを実行する。`sql` は応答を JSON で印字し、アプリケーションエラーでは非ゼロで終了する。 diff --git a/docs/zh/architecture.md b/docs/zh/architecture.md index dfe5354..8d1cfad 100644 --- a/docs/zh/architecture.md +++ b/docs/zh/architecture.md @@ -9,13 +9,13 @@ `PersistentMetaDbCluster::open_and_serve`(`crates/metadb-server/src/lib.rs`): 1. 拒绝除 `all-in-one` 以外的任何 `node.role`。 -2. `shared_secret` 为空时,拒绝通配或其他非环回的 `grpc_listen_addr` 与 `metrics_listen_addr`。然后绑定 `node.grpc_listen_addr`(默认 `127.0.0.1:7800`;`127.0.0.1:0` 让操作系统分配端口)。 +2. An empty `shared_secret` does not start the process unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret plus the flag is rejected. A wildcard or other non-loopback address cannot use the opt-in. It then binds `node.grpc_listen_addr` (default `127.0.0.1:7800`; `127.0.0.1:0` asks the OS for a port). 3. 在 `/global_allocator` 打开 `DurableIdAllocator`。 4. 在 `/be` 打开 `ShardGroupHost`。 5. 在 `/cell_` 打开或引导 `DurableCellManager`。 6. 把这一个单元以键范围 `[0x01, 0x04)` 注册到 `DurableGlobalManager`。 7. 保证根 inode `1`(`ROOT_INODE_ID`)有属性记录。 -8. 在同一监听器上提供四个 gRPC 服务。四个服务使用同一个持有者拦截器。设置了 `metrics_listen_addr` 时,该地址上的 `GET /metrics` 要求同一个密钥。密钥非空时,缺失或错误的令牌会被拒绝。空密钥只接受环回绑定。本进程不终结 TLS。 +8. Serves four gRPC services on one listener. All four use the same bearer interceptor. When `metrics_listen_addr` is set, `GET /metrics` on that address requires the same secret. A non-empty secret rejects a missing or wrong bearer. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This process does not terminate TLS. 9. 启动间隔 250 ms 的维护任务。 `metadbd` 是薄封装:加载 TOML,应用命令行覆盖,调用 `open_and_serve`,可选地对 `--cell-manager` 调用 `RegisterNode`,并在 Ctrl-C 时调用 `shutdown`。配置了指标时,由 `open_and_serve` 提供。 diff --git a/docs/zh/build-and-run.md b/docs/zh/build-and-run.md index e7e2924..1e72fa7 100644 --- a/docs/zh/build-and-run.md +++ b/docs/zh/build-and-run.md @@ -64,7 +64,7 @@ cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml 日志使用 `tracing-subscriber` 的 `EnvFilter`。默认过滤器是 `info`。用标准环境变量 `RUST_LOG` 覆盖,例如 `RUST_LOG=debug`。 -`security.shared_secret` 为空时,进程在启动时记录一条警告:环回 gRPC 没有认证。默认绑定是 `127.0.0.1`。通配或其他非环回地址如果密钥为空、缺失或拼错,会拒绝监听。非空的 `[security].shared_secret` 对元数据、事务、控制面、Raft 传输和 `GET /metrics` 要求同一个持有者令牌。进程不终结 TLS。配置里的 TLS 或证书键会使启动失败,而不是以明文提供服务。把监听器留在可信网络上,或把每个服务放到会认证客户端的代理后面,并阻断对本进程的直接访问。 +An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C 会刷出分片状态并停止 OpenRaft 组(`cluster.shutdown()`)。 diff --git a/docs/zh/configuration.md b/docs/zh/configuration.md index f096463..293ca12 100644 --- a/docs/zh/configuration.md +++ b/docs/zh/configuration.md @@ -13,7 +13,7 @@ | `node.role` | `all-in-one` | 是。任何其他值都返回错误 | | `node.data_dir` | `./metadb-data` | 是 | | `node.grpc_listen_addr` | `127.0.0.1:7800` | 是。绑定地址 | -| `node.metrics_listen_addr` | 未设置 | 仅在设置时应用。单独的 TCP 监听器。非环回地址要求非空密钥 | +| `node.metrics_listen_addr` | 未设置 | Applied only when set. Separate TCP listener. An empty secret does not listen unless `allow_unauthenticated = true`, and that flag is loopback-only | | `clock.max_clock_drift_ms` | `500` | 是。`HybridLogicalClock::with_max_drift_ms` | | `storage.memtable_size_bytes` | `33554432`(32 MiB) | 是。计入的字节达到该大小时,封印并刷出活动 memtable。小于 1 的值按 1 处理 | | `storage.max_imm_memtables` | `4` | 是。写入方会等待,而不是把超过该上限的不可变 memtable 继续排队 | @@ -24,7 +24,8 @@ | `storage.locality_tombstone_ratio` | `0.50` | 是。乘以 1000,钳制到 1..=1000,存为 `tombstone_min_ratio_permille` | | `sharding.bootstrap_table_shards` | `true` | 是。`true` 创建分片 1、2、3。`false` 创建覆盖 `[0x01, 0x04)` 的分片 1 | | `sharding.shard_split_threshold_bytes` | `4294967296`(4 GiB) | 是。分裂检查使用分片的近似大小 | -| `security.shared_secret` | `""` | 是。空密钥只在全部监听器都是环回地址时接受。非空时 gRPC 和指标要求同一个持有者令牌 | +| `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | 没有 `[raft]` 表。`ServerTomlConfig.raft_options` 被 serde 跳过,保持 `RaftNodeOptions::default()`(心跳 150 ms,选举 450–900 ms,快照日志保留 0,段大小 64 MiB)。 @@ -73,7 +74,7 @@ shared_secret = "replace-with-a-long-random-string" `shared_secret` 非空时,`MetadataService`、`TransactionService`、`ControlPlaneService` 和 `RaftTransportService` 要求 `authorization` 精确等于 `Bearer `。`metrics_listen_addr` 上的 `GET /metrics` 要求同一个 `Authorization` 头。缺失的头、空令牌、前缀或更长的令牌都会被拒绝。指标失败响应的正文不是 Prometheus 文本。Raft 对等体发送同一个令牌。`metadb-ctl --auth-token`(环境变量 `METADB_AUTH_TOKEN`)以及 `metadbd --join` / `--cell-manager` 也会发送它。`metadb-ctl cluster status` 调用 `GetRoutes`,走同一个拦截器。 -空密钥或只含空白的密钥,仅当 `grpc_listen_addr` 和已设置的 `metrics_listen_addr` 都是环回地址(`127.0.0.0/8`、`::1` 或名字 `localhost`)时才接受。通配地址(`0.0.0.0`、`::`)或其他地址会拒绝监听。空的环回密钥会在启动时记一条警告。监听器仍然是明文。把它们留在可信网络上,或把每个服务放到会认证客户端的代理后面,并阻断对本进程的直接访问。 +An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## 不能配置的内容 diff --git a/docs/zh/operations.md b/docs/zh/operations.md index 97352a7..ecd60a4 100644 --- a/docs/zh/operations.md +++ b/docs/zh/operations.md @@ -71,7 +71,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 sql \ ## 指标 -设置 `node.metrics_listen_addr`(例如 `127.0.0.1:9100`)。`open_and_serve` 在该地址接受 TCP 连接。`GET /metrics` 返回 Prometheus 文本。其他路径返回 404,其他方法返回 405。`[security].shared_secret` 非空时,该监听器上的每个请求都必须发送 `Authorization: Bearer `。缺失、空或错误的令牌返回 HTTP 401,正文不是指标文本,包括对 `/status` 的请求。空密钥配合非环回的指标地址会拒绝启动。该监听器不终结 TLS。 +设置 `node.metrics_listen_addr`(例如 `127.0.0.1:9100`)。`open_and_serve` 在该地址接受 TCP 连接。`GET /metrics` 返回 Prometheus 文本。其他路径返回 404,其他方法返回 405。`[security].shared_secret` 非空时,该监听器上的每个请求都必须发送 `Authorization: Bearer `。缺失、空或错误的令牌返回 HTTP 401,正文不是指标文本,包括对 `/status` 的请求。An empty secret does not start the process on any address, including loopback, unless `allow_unauthenticated = true`. That flag is loopback-only and still refuses a wildcard or other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. This listener does not terminate TLS. `render_prometheus_metrics` 的计量与计数: @@ -136,7 +136,7 @@ metadb-ctl --endpoint 127.0.0.1:7800 sql \ - 未知且非零的 `cell_id` 上,`GetRoutes` 失败关闭。`StoreHeartbeat` 不会替换缓存路由。 - 巨型隔离是路由标志加上从本地节点表选出的节点标识。它不会把其他分片从磁盘上赶走。 - 心跳是一个 RPC,`metadbd` 里没有发送方。`StoreHeartbeat` 不持久化。 -- 非空共享密钥用同一个持有者令牌认证 Raft、另外三个 gRPC 服务和指标监听器。空密钥只接受环回绑定,这些监听器不认证。通配绑定加上空密钥会拒绝启动。进程不终结 TLS。 +- A non-empty shared secret authenticates Raft, the other three gRPC services, and the metrics listener with the same bearer. An empty secret does not start the process, including on loopback. `allow_unauthenticated = true` is the explicit opt-in for empty-secret loopback development and still refuses a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with that opt-in. A usable secret combined with the opt-in is rejected. The process does not terminate TLS. - `memtable_size_bytes` 会封印并刷出活动 memtable。`max_imm_memtables` 限制已排队的不可变表数量。Raft 计时字段不会通过 TOML 改变运行行为。 - `hotspot-create` 和 `bulk-ttl-delete` 的 `metadb-ctl bench` 打印 JSON 行:先是带 `bench_pid` 的头,然后是包含 attempted、succeeded、failed 和延迟分位数的阶段报告。只要有一次请求的操作失败,进程就以非零状态退出。`--workload mixed` 或 `--embedded` 运行进程内的压力工具。`sql` 把响应打印成 JSON,遇到应用错误时以非零状态退出。 From 75873832d16e0c21260e8bea0eca84f0e84bcbfd Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Nov 2026 19:34:23 +0000 Subject: [PATCH 3/5] Remove remaining false guarantees from design docs Attribute paper ratios and the 60 percent write figure, and describe jumbo isolation as a route flag. Mark Phase 0 as a design note, qualify Implemented headings that match runnable code, and record that locale auth text depends on unmerged pull request 35 while raft loading stays off main until pull request 38. Co-authored-by: RustFS --- Architecture.md | 2 +- README.md | 8 ++++---- _agents/skills/metadb_elephant/SKILL.md | 6 +++--- docs/DEVELOPMENT_PLAN.md | 12 ++++++------ docs/de/architecture.md | 2 ++ docs/de/configuration.md | 6 +++++- docs/designs/SITEMAP.md | 16 ++++++++-------- docs/designs/concepts_brief.md | 2 +- docs/designs/consensus_and_transactions.md | 2 +- docs/designs/metadb_architecture.md | 16 +++++++++------- docs/designs/review_report.md | 4 ++-- docs/designs/sharding_and_control_plane.md | 13 +++++-------- docs/designs/storage_lsm_mvcc.md | 6 +++--- docs/fr/architecture.md | 2 ++ docs/fr/configuration.md | 6 +++++- docs/guides/de/client-apis-and-sql.md | 2 +- docs/guides/de/deployment.md | 4 ++++ docs/guides/de/operations-and-tuning.md | 2 ++ docs/guides/en/client-apis-and-sql.md | 4 +++- docs/guides/en/operations-and-tuning.md | 2 ++ docs/guides/fr/client-apis-and-sql.md | 2 +- docs/guides/fr/deployment.md | 4 ++++ docs/guides/fr/operations-and-tuning.md | 2 ++ docs/guides/ja/client-apis-and-sql.md | 2 +- docs/guides/ja/deployment.md | 4 ++++ docs/guides/ja/operations-and-tuning.md | 2 ++ docs/guides/zh/client-apis-and-sql.md | 4 +++- docs/guides/zh/deployment.md | 4 ++++ docs/guides/zh/operations-and-tuning.md | 2 ++ docs/ja/architecture.md | 2 ++ docs/ja/configuration.md | 6 +++++- docs/zh/architecture.md | 2 ++ docs/zh/configuration.md | 6 +++++- 33 files changed, 106 insertions(+), 53 deletions(-) diff --git a/Architecture.md b/Architecture.md index 181b2fb..ad9bdf8 100644 --- a/Architecture.md +++ b/Architecture.md @@ -2,7 +2,7 @@ * **Project**: `rustfs/MetaDB` * **Language & Stack**: 100% Pure Rust (`tokio` + `tonic`/`prost` gRPC + `openraft` Multi-Raft + Custom WAL-less LSM Storage; zero C/C++ FFI) -* **Specification Status**: Phase 0 Approved Architecture & Subsystem Suite (see [Section 12](#12-implementation-status-matrix-paper-vs-repository) for current prototype vs. Phase 1–6 implementation status) +* **Specification Status**: Phase 0 is the design status of this architecture note. It is not a first-launch acceptance of the running tree. [Section 12](#12-implementation-status-matrix-paper-vs-repository) separates design claims, crate tests, and multi-process gaps. * **Design Methodology**: [Google Elephant-Goldfish Model (EGM)](https://github.com/google/elephant-goldfish-model) for Spec-Driven Development (SDD) * **Primary Theoretical Reference**: This architecture is directly inspired by and adapted from Baidu's trillion-scale production metadata database paper: > **Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou.** diff --git a/README.md b/README.md index dadbe53..2689e7f 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ ## Why MetaDB? -General-purpose distributed databases (such as TiDB, CockroachDB, and FoundationDB) treat file-system and object-storage metadata as generic flat key-value or relational rows. At exabyte scale, this "black-box" approach creates three severe bottlenecks: +General-purpose distributed databases (such as TiDB, CockroachDB, and FoundationDB) treat file-system and object-storage metadata as generic flat key-value or relational rows. The three bottlenecks below are Baidu production observations reported in `arXiv:2610.32247v1`. None of the ratios or latencies is a measurement of this repository. -1. **Data Model Mismatch**: Flat hash or byte-midpoint sharding fractures entries of the same directory across multiple shards, turning `>96%` of localized single-directory operations (`create`, `mkdir`, `unlink`, `listdir`) into multi-shard Two-Phase Commit (2PC) transactions and incurring extra network round-trips. -2. **Transaction Model Mismatch**: Synchronously locking the shared parent-directory attribute record (`num_children`, `size_bytes`, `modify_time`) collapses concurrent single-directory write throughput by `10x–36x`, while synchronous updates to `QuotaTable` and `SecondaryIndexTable` force unnecessary cross-shard 2PC on every write. -3. **Storage Implementation Mismatch**: Persisting multi-version concurrency control (MVCC) tombstones to disk for transient (`<10ms`) metadata transactions creates a **double-tombstone penalty** (MVCC tombstones + LSM-tree tombstones). Under consecutive bulk TTL deletions, accumulated tombstones degrade `listdir` range-scan latency from `<100ms` to `~6 seconds`. +1. **Data Model Mismatch**: The paper reports that flat hash or byte-midpoint sharding turns `>96%` of localized single-directory operations (`create`, `mkdir`, `unlink`, `listdir`) into multi-shard Two-Phase Commit (2PC). That percentage is Baidu's workload figure, not a ratio counted in this tree. +2. **Transaction Model Mismatch**: The paper reports that synchronously locking the shared parent-directory attribute record collapses concurrent single-directory write throughput by `10x–36x` (including a `36.2x` gap versus TiDB in that study). Synchronous `QuotaTable` and `SecondaryIndexTable` updates are the paper's description of extra cross-shard 2PC, not a benchmark of this repository. +3. **Storage Implementation Mismatch**: The paper reports a double-tombstone penalty for short-lived (`<10ms`) metadata transactions, and `listdir` latency moving from `<100ms` to `~6 seconds` under bulk TTL deletion (`arXiv:2610.32247v1`, §2.3.3 and §7.4). Those latencies are not measurements of this repository. --- diff --git a/_agents/skills/metadb_elephant/SKILL.md b/_agents/skills/metadb_elephant/SKILL.md index 696a433..927a834 100644 --- a/_agents/skills/metadb_elephant/SKILL.md +++ b/_agents/skills/metadb_elephant/SKILL.md @@ -29,13 +29,13 @@ This skill loads the architectural history, foundational literature, subsystem c * `metadb-storage`: `StorageBackend` trait, pure-Rust WAL-less SSTable LSM (4 KiB CRC32C blocks, Bloom filters including physical tombstones, 16-shard LRU `BlockCache`, atomic `MANIFEST`), `SnapshotGuard`-gated `MemMvccStore`, and bottommost-safe `LocalityCompactor`. * `metadb-raft`: `openraft` Multi-Raft (`1-Voter` single-node to `3-Voter` distributed), segmented CRC32C log store, 3-watermark purge gate, `ReadIndex` batcher, and online `ConfChange`. * `metadb-tx`: Deterministic `RaftStateMachine`, `1-RTT` `PushdownExecutor`, `AsyncAttrAggregator` (Coordinated Flush Barrier + Read-Path Reconciliation), FIFO `AuxOutbox` + `[0x07]` local spill, and Primary-Anchored crash-recoverable 2PC (`Rename`, cross-shard `Mkdir`/`Rmdir`). -* `metadb-cluster`: Unified `[0x01, 0x04)` sharding, `ShardEpoch` fencing, `PID`-boundary & `DualModeFineGrained` (`[0x04] DirShardDelta`) splitting, Jumbo dedicated-node isolation, `GlobalManager`, `CellLocalManager`, `MetaCache`, and `IdRangeAllocator`. +* `metadb-cluster`: Unified `[0x01, 0x04)` sharding, `ShardEpoch` fencing, `PID`-boundary splits, a `DualModeFineGrained` mode flag (a later split may use `[0x04] DirShardDelta`; the flag write does not copy keys), a `JumboIsolated` route flag (not dedicated-node placement), `GlobalManager`, `CellLocalManager`, `MetaCache`, and `IdRangeAllocator`. * `metadb-proxy`: Tokenizing compiler for all 20 parameterized metadata SQL templates + Epoch-aware stateless router. -* `metadb-server`: Embedded `MetaDbEngine` SDK + `metadbd` multi-role daemon + `metadb-ctl` operator CLI. +* `metadb-server`: Persistent `MetaDbEngine::open` / `PersistentMetaDbCluster`, in-memory `new_single_node` simulator, `metadbd` (`all-in-one` only), and `metadb-ctl`. ## Implementation Status Policy -* **Current Baseline**: Phases 0–6 Completed & Verified across all 8 pure-Rust crates (`cargo fmt`, `cargo clippy -D warnings`, and `cargo test --workspace` passing). +* **Current baseline**: The 8 crates are in this repository. Phase labels are not a completed verification and not a first-launch pass. Crate tests exist. This file does not assert that `cargo test --workspace` is currently green. Multi-cell topology, role-split processes, and dedicated-host jumbo moves are not deployed. Jumbo isolation is a route flag. * **Ongoing Maintenance**: Keep `Architecture.md`, `README.md`, `docs/designs/*.md`, and `docs/guides/{en,ja,fr,zh,de}/` synchronized with any future architectural extensions. ## Non-Negotiable Architectural Invariants diff --git a/docs/DEVELOPMENT_PLAN.md b/docs/DEVELOPMENT_PLAN.md index 95126df..85a4eb1 100644 --- a/docs/DEVELOPMENT_PLAN.md +++ b/docs/DEVELOPMENT_PLAN.md @@ -69,7 +69,7 @@ flowchart TD ## 2. Phase-by-Phase Implementation Plan -### Phase 0: Architecture, EGM Specifications, Goldfish Review & Multilingual Guides (Current Gate) +### Phase 0: Architecture, EGM Specifications, Goldfish Review & Multilingual Guides (design documents, not a first-launch pass) * **Objective**: Establish Zero-Decision architectural specifications, subsystem blueprints, phased engineering plan, adversarial zero-context Goldfish review resolutions, and 5-language user documentation (`en`, `ja`, `fr`, `zh`, `de`) before modifying Rust crate source code. * **Deliverables**: * `Architecture.md` @@ -116,13 +116,13 @@ flowchart TD * **Key Invariants**: * **WAL-less Persistence**: `LsmStorageBackend` writes zero KV WAL files; durability before flush is owned by the Raft log, and `lsm_flushed_index` advances strictly after `L0` SSTable `fdatasync` + `MANIFEST` `fdatasync` + parent directory `fsync`. * **SSTable Integrity**: 4 KiB prefix-compressed data blocks with 16-entry restart intervals, per-block CRC32C trailers, Kirsch-Mitzenmacher Bloom filter (`10 bits/key` indexing both live values and `PhysicalTombstone`s), sparse block index, length-framed `MetaBlock` with monotonic `flush_generation: u64`, and canonical **64-byte** magic/version/checksum footer. - * **Mathematical MVCC Visibility (`SnapshotGuard` & `ReadCut`)**: `SnapshotGuard` pins a total `ReadCut { max_raft_index, max_hlc }` + `Arc` + `Vec>` with bounded per-page step leases. An `ImmMemTable` covering writes up to `H_imm` flushes to an unversioned L0 SSTable **only when** `min_active_snapshot_hlc >= H_imm` (`<= 5,000ms` timeout), guaranteeing zero future-read/phantom-scan anomalies and zero persisted MVCC tombstones. + * **MVCC visibility (`SnapshotGuard` & `ReadCut`)**: `SnapshotGuard` pins a `ReadCut { max_raft_index, max_hlc }` plus the version and immutable memtables, with bounded per-page step leases. An `ImmMemTable` covering writes up to `H_imm` collapse-flushes to an unversioned L0 SSTable only when `min_active_snapshot_hlc >= H_imm` (retention `5,000ms`). That gate does not guarantee zero future-read or phantom-scan anomalies. Collapse may keep only the latest value. A range read at `start_hlc` can include later values of keys an open 2PC lease does not cover. Point reads of keys that lease records stay at the pre-image until commit. * **Bottommost-Safe Locality Compaction**: `LocalityCompactor` tracks tombstone density per 9-byte `[table_prefix][group_key: 8B]` bucket and compacts `[start_key, end_key)` across all overlapping levels (`L0..L_max`), dropping `PhysicalTombstone` entries **only** when no deeper overlapping SSTable can contain the key. * **Verification Commands**: * `cargo test -p metadb-storage` * `cargo clippy -p metadb-storage --all-targets -- -D warnings` * **Acceptance Criteria**: - * Crash/reopen tests verify `MANIFEST` recovery, orphan `.sst.tmp` cleanup, CRC32C corruption detection, Bloom filter zero false-negatives, `SnapshotGuard` isolation across concurrent `MemTable` seals and L0 flushes, `~60%` KV write reduction on rapid updates/deletes, and zero shadowed-key resurrection during multi-level `LocalityCompactor` runs. + * Crash/reopen tests cover `MANIFEST` recovery, orphan `.sst.tmp` cleanup, CRC32C corruption detection, one L0 tombstone shadowing an L1 value, `SnapshotGuard` isolation across concurrent memtable seals and L0 flushes, and a locality-compaction fixture that does not resurrect the shadowed key in that case. They do not measure a `~60%` KV write reduction. That percentage is a paper/model figure from `arXiv:2610.32247v1`, not a result of `mvcc_snapshot_tests.rs`. They also do not prove zero future-read anomalies for every range read. --- @@ -184,7 +184,7 @@ flowchart TD * `cargo test -p metadb-cluster -p metadb-proxy` * `cargo clippy -p metadb-cluster -p metadb-proxy --all-targets -- -D warnings` * **Acceptance Criteria**: - * Tests verify concurrent client writes during live `PID`-boundary shard splits (`EpochMismatch` auto-retry with zero lost/duplicate writes), Jumbo Shard dedicated-node isolation, `DualModeFineGrained` scatter-gather `dirstat` + paginated `listdir` + 2PC `rmdir`, `IdRangeAllocator` uniqueness across restarts, and all 20 SQL templates. + * In-process tests cover `PID`-boundary splits, a `JumboIsolated` route flag (not a move of peer shards onto a dedicated host), `DualModeFineGrained` scatter-gather inside one process, `IdRangeAllocator` uniqueness across restarts, and the 20 SQL templates. Dedicated-host jumbo placement is not what those tests run. --- @@ -197,11 +197,11 @@ flowchart TD * `crates/metadb-server/tests/{integration_tests.rs, e2e_cluster_evolution_tests.rs}` * Documentation status updates across `Architecture.md`, `README.md`, and `docs/guides/{en,ja,fr,zh,de}/` * **Key Invariants**: - * **Single Codebase Across Deployment Topologies**: `metadbd --role all-in-one` runs `GlobalManager + CellLocalManager + MetaCache + Proxy + BE (1-Voter OpenRaft)` in one process; `--role global-manager | cell-manager | be | proxy` runs disaggregated multi-node / multi-Cell clusters over `tonic` gRPC. + * **Single runnable role**: `metadbd --role all-in-one` runs `GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy`, and a `1-Voter` OpenRaft group in one process. `open_and_serve` rejects `global-manager`, `cell-manager`, `be`, and `proxy`. Those names are not a disaggregated deployment. * **Clean Lifecycle**: Graceful SIGINT/SIGTERM drain flushes active MemTables, persists `MANIFEST` and Raft state, and closes network listeners cleanly. * **Verification Commands**: * `cargo fmt --all -- --check` * `cargo clippy --workspace --all-targets -- -D warnings` * `cargo test --workspace` * **Acceptance Criteria**: - * End-to-end integration suite boots a persistent `1-Voter` `metadbd` node on disk, restarts and verifies crash recovery, splits shards across `PID` boundaries, joins two additional `metadbd` BE nodes over real local TCP/gRPC sockets, promotes shards to `3-Voter` Multi-Raft under live load, adds a second `Cell`, executes cross-shard 2PC `rename` and bulk-delete `LocalityCompactor` scans via `metadb-ctl` and gRPC clients, and updates all documentation status tables to `Implemented`. + * `e2e_cluster_evolution_tests.rs` boots one persistent all-in-one `PersistentMetaDbCluster`, restarts it from the same directory, calls `TriggerShardSplit`, and runs a cross-shard `Rename` plus bulk deletion on that one process. It does not start `metadbd --role be`, does not join two extra BE processes, and does not register a second Cell. A second all-in-one join is `join_existing_group`, not that end-to-end test. In-process 1-voter to 3-voter coverage is `multi_raft_failover_tests`, not a three-VM rehearsal. diff --git a/docs/de/architecture.md b/docs/de/architecture.md index fae567c..873f0e7 100644 --- a/docs/de/architecture.md +++ b/docs/de/architecture.md @@ -88,6 +88,8 @@ MVCC-Versionen leben `storage.mvcc_retention_ms` (Vorgabe 5.000) lang im Speiche Jeder lokale Shard ist eine `openraft`-0.10-Gruppe. Das Log ist eine segmentierte CRC32C-Datei unter `.../shards//raft`. Vorgaben, die **nicht** aus TOML geladen werden (`raft_options` ist `#[serde(skip)]`): +That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. + | Feld | Vorgabe | | :--- | :--- | | Heartbeat | 150 ms | diff --git a/docs/de/configuration.md b/docs/de/configuration.md index 2da3a15..77dc135 100644 --- a/docs/de/configuration.md +++ b/docs/de/configuration.md @@ -2,7 +2,9 @@ [Überblick](./README.md) · [English](../en/configuration.md) · [Français](../fr/configuration.md) · [日本語](../ja/configuration.md) · [简体中文](../zh/configuration.md) -`metadbd --config` und `ServerTomlConfig::from_toml_file` / `from_toml_str` lesen TOML (`crates/metadb-server/src/config.rs`). Unbekannte Schlüssel, die kein Geheimnis und kein TLS benennen, werden ignoriert. Ein falsch geschriebenes `shared_secret`, ein Token- oder Passwortschlüssel oder ein TLS- oder Zertifikatsschlüssel wird abgelehnt, und der Prozess startet nicht. Jeder bekannte Abschnitt ist optional. Ausgelassene Felder nehmen die Vorgaben unten an. +`metadbd --config` und `ServerTomlConfig::from_toml_file` / `from_toml_str` lesen TOML (`crates/metadb-server/src/config.rs`). Jeder bekannte Abschnitt ist optional. Ausgelassene Felder nehmen die Vorgaben unten an. + +On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. ## Vorgaben @@ -29,6 +31,8 @@ Es gibt keine Tabelle `[raft]`. `ServerTomlConfig.raft_options` wird von serde übersprungen und bleibt bei `RaftNodeOptions::default()` (Heartbeat 150 ms, Wahl 450–900 ms, Snapshot-Log-Behalten 0, Segment 64 MiB). +That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. + `to_lsm_config` setzt immer `auto_locality_compaction: true`. ## Beispiel diff --git a/docs/designs/SITEMAP.md b/docs/designs/SITEMAP.md index ecc67a5..0986d0d 100644 --- a/docs/designs/SITEMAP.md +++ b/docs/designs/SITEMAP.md @@ -6,14 +6,14 @@ This directory contains the living design specifications and adversarial zero-co | Artifact | Role / EGM Stage | Scope | Status | | :--- | :--- | :--- | :--- | -| [`../../Architecture.md`](../../Architecture.md) | Master Architecture | End-to-end 8-crate Rust architecture, three mismatches from `arXiv:2610.32247v1`, capacity math (`100M–10T+`), and implementation status matrix. | Phase 0 Approved | -| [`../DEVELOPMENT_PLAN.md`](../DEVELOPMENT_PLAN.md) | Engineering Roadmap | Phased pure-Rust implementation plan (Phases 1–6), crate dependency DAG, file boundaries, verification commands, and acceptance gates. | Phase 0 Approved | -| [`concepts_brief.md`](./concepts_brief.md) | Upstream Ideation (`Brainstorm`) | Core hypothesis and 6-lens adversarial Goldfish shootdown summary. | Phase 0 Approved | -| [`metadb_architecture.md`](./metadb_architecture.md) | Umbrella EGM Spec (`Draft`) | System-level `FeatureRange` + `DetailedRange` specification tying together the 8 workspace crates. | Phase 0 Approved | -| [`storage_lsm_mvcc.md`](./storage_lsm_mvcc.md) | Subsystem Spec 1 (`Draft`) | `metadb-storage`: `StorageBackend` trait, 4 KiB CRC32C SSTables, Bloom filter, sharded LRU `BlockCache`, `MANIFEST` recovery, `SnapshotGuard` In-Memory MVCC, and bottommost-safe `LocalityCompactor`. | Phase 0 Approved | -| [`consensus_and_transactions.md`](./consensus_and_transactions.md) | Subsystem Spec 2 (`Draft`) | `metadb-raft` & `metadb-tx`: `openraft` Multi-Raft, segmented CRC32C log store, 3-watermark purge gate, `ReadIndex`, `1-RTT` `PushdownExecutor`, `AsyncAttrAggregator` Coordinated Flush Barrier, FIFO `AuxOutbox` + `[0x07]` spill, and crash-recoverable 2PC. | Phase 0 Approved | -| [`sharding_and_control_plane.md`](./sharding_and_control_plane.md) | Subsystem Spec 3 (`Draft`) | `metadb-proto`, `metadb-cluster` & `metadb-proxy`: Unified `[0x01, 0x04)` composite sharding, `ShardEpoch` fencing, Jumbo `DualModeFineGrained` scatter-gather, `GlobalManager`/`CellLocalManager`/`MetaCache`, `IdRangeAllocator`, 20 SQL templates, and Protobuf v1 contracts. | Phase 0 Approved | -| [`review_report.md`](./review_report.md) | Adversarial Audit (`Review & Resolve`) | Independent zero-context Goldfish subagent review findings and specification resolutions. | Phase 0 Approved & Goldfish-Verified | +| [`../../Architecture.md`](../../Architecture.md) | Master Architecture | End-to-end 8-crate Rust architecture, three mismatches from `arXiv:2610.32247v1`, capacity math (`100M–10T+`), and implementation status matrix. | Phase 0 design note, not a launch pass | +| [`../DEVELOPMENT_PLAN.md`](../DEVELOPMENT_PLAN.md) | Engineering Roadmap | Phased pure-Rust implementation plan (Phases 1–6), crate dependency DAG, file boundaries, verification commands, and acceptance gates. | Phase 0 design note, not a launch pass | +| [`concepts_brief.md`](./concepts_brief.md) | Upstream Ideation (`Brainstorm`) | Core hypothesis and 6-lens adversarial Goldfish shootdown summary. | Phase 0 design note, not a launch pass | +| [`metadb_architecture.md`](./metadb_architecture.md) | Umbrella EGM Spec (`Draft`) | System-level `FeatureRange` + `DetailedRange` specification tying together the 8 workspace crates. | Phase 0 design note, not a launch pass | +| [`storage_lsm_mvcc.md`](./storage_lsm_mvcc.md) | Subsystem Spec 1 (`Draft`) | `metadb-storage`: `StorageBackend` trait, 4 KiB CRC32C SSTables, Bloom filter, sharded LRU `BlockCache`, `MANIFEST` recovery, `SnapshotGuard` In-Memory MVCC, and bottommost-safe `LocalityCompactor`. | Phase 0 design note, not a launch pass | +| [`consensus_and_transactions.md`](./consensus_and_transactions.md) | Subsystem Spec 2 (`Draft`) | `metadb-raft` & `metadb-tx`: `openraft` Multi-Raft, segmented CRC32C log store, 3-watermark purge gate, `ReadIndex`, `1-RTT` `PushdownExecutor`, `AsyncAttrAggregator` Coordinated Flush Barrier, FIFO `AuxOutbox` + `[0x07]` spill, and crash-recoverable 2PC. | Phase 0 design note, not a launch pass | +| [`sharding_and_control_plane.md`](./sharding_and_control_plane.md) | Subsystem Spec 3 (`Draft`) | `metadb-proto`, `metadb-cluster` & `metadb-proxy`: Unified `[0x01, 0x04)` composite sharding, `ShardEpoch` fencing, Jumbo `DualModeFineGrained` scatter-gather, `GlobalManager`/`CellLocalManager`/`MetaCache`, `IdRangeAllocator`, 20 SQL templates, and Protobuf v1 contracts. | Phase 0 design note, not a launch pass | +| [`review_report.md`](./review_report.md) | Adversarial Audit (`Review & Resolve`) | Independent zero-context Goldfish subagent review findings and specification resolutions. | Phase 0 design review, not a launch pass | | [`../README.md`](../README.md) | Multilingual Usage Hub | User and operator documentation index across English (`en`), Japanese (`ja`), French (`fr`), Simplified Chinese (`zh`), and German (`de`). | Phase 0 Active | The [codec dependency analysis](codec_dependencies.md) records CRC and serialization dependency selection, storage-format compatibility, and review coverage. diff --git a/docs/designs/concepts_brief.md b/docs/designs/concepts_brief.md index f5a576b..084d1a3 100644 --- a/docs/designs/concepts_brief.md +++ b/docs/designs/concepts_brief.md @@ -24,7 +24,7 @@ During Phase 1 ideation, the concept was challenged across six adversarial lense | Lens | Challenge Raised | Architectural Resolution | | :--- | :--- | :--- | -| **1. Scale & Bottleneck Critic** | Anchoring a directory (`group_key = PID`) to a single shard creates unsplittable "Jumbo Shards" when a single directory holds hundreds of millions of files. | Implement **Jumbo-Shard Isolation Scheduling** (dedicated node placement by `CellLocalManager`) plus a **Dual-Mode Sharding Fallback** that allows operator/policy-triggered sub-directory hash/range splitting when a single `PID` exceeds node limits. | +| **1. Scale & Bottleneck Critic** | Anchoring a directory (`group_key = PID`) to a single shard creates unsplittable "Jumbo Shards" when a single directory holds hundreds of millions of files. | This tree writes a `JumboIsolated` route flag. It does not place the shard on a dedicated node or evict peer shards. `DualModeFineGrained` is a mode flag; a later split may cut on `(pid, name)`. The flag write does not copy keys. | | **2. Durability & Crash Recovery Critic** | Disabling the underlying KV WAL while holding MVCC versions and async attribute/quota queues in memory risks data loss or duplicate quota accounting on crash. | Persist all primary writes, attribute deltas, and auxiliary update intents in the **Raft Log** before enqueuing in memory. Hold Raft log truncation to `min(storage_flush_lsn, attr_agg_lsn, aux_sink_lsn)` and deduplicate auxiliary updates using monotonic **Hybrid Logical Clock (HLC)** timestamps. | | **3. Consistency & Read-Your-Writes Critic** | If parent directory attributes (`num_children`, `modify_time`) are updated asynchronously, `dirstat` immediately after `create` will return stale counts. | Introduce **Read-Path Reconciliation**: `dirstat` merges the persisted `(PID, "_attr_")` record with un-flushed in-memory delta accumulators on the shard leader in `<1µs`, guaranteeing linearizable read-your-writes for directory attributes. | | **4. Single-Node to Distributed Evolution Critic** | Maintaining separate code paths for standalone single-node WAL vs. distributed Raft causes state-machine divergence during online scale-out. | Unify single-node and distributed modes via **Single-Voter Raft (`ReplicationFactor = 1`)** in Phase 1. Scale-out to 3 nodes uses standard Raft `ConfChange` (`AddLearner` $\rightarrow$ `PromoteVoter`) with zero code-path switching. | diff --git a/docs/designs/consensus_and_transactions.md b/docs/designs/consensus_and_transactions.md index e812050..ff0f8d0 100644 --- a/docs/designs/consensus_and_transactions.md +++ b/docs/designs/consensus_and_transactions.md @@ -1,6 +1,6 @@ # EGM Subsystem Specification 2: OpenRaft Multi-Raft Consensus, Off-Critical-Path Queues & Crash-Recoverable 2PC (`metadb-raft` & `metadb-tx`) -* **Status**: Phase 0 Approved Specification +* **Status**: Phase 0 design note. Not a first-launch acceptance of the running tree. * **Target Crates**: `crates/metadb-raft` and `crates/metadb-tx` * **Primary Reference**: Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou, *"MetaDB: Putting File-System Structure Back into Distributed Databases"*, [arXiv:2610.32247v1](https://arxiv.org/html/2610.32247v1) (Vrije Universiteit Amsterdam, Baidu & Peking University, 2026), §3.2, §4.2, §5.1, §5.2 * **Semantic Boundaries**: diff --git a/docs/designs/metadb_architecture.md b/docs/designs/metadb_architecture.md index b22d5c3..14ef917 100644 --- a/docs/designs/metadb_architecture.md +++ b/docs/designs/metadb_architecture.md @@ -1,6 +1,6 @@ # EGM Specification: MetaDB Distributed Metadata Engine -* **Status**: Phase 0 Approved Umbrella Specification +* **Status**: Phase 0 is the design status of this umbrella note. It is not a first-launch acceptance of the running tree. * **Methodology**: [Google Elephant-Goldfish Model (EGM)](https://github.com/google/elephant-goldfish-model) * **Primary Reference**: Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou, *"MetaDB: Putting File-System Structure Back into Distributed Databases"*, [arXiv:2610.32247v1](https://arxiv.org/html/2610.32247v1) (Vrije Universiteit Amsterdam, Baidu & Peking University, 2026) * **Modular Subsystem Contracts**: @@ -72,7 +72,7 @@ Furthermore, adopters need an engine that can run in **Single-Node All-in-One Mo * **Exact-Once FIFO `AuxOutbox`**: Dispatches `QuotaTable` and `SecondaryIndexTable` batches in strict ascending `origin_raft_index` order per `(origin_shard_id, target_shard_id)`, spilling overdue tasks to `[0x07]` on L0 flush. ### 3.5 Topology Sharding, Two-Tier Control Plane & Wire Contracts (`metadb-proto`, `metadb-cluster`, `metadb-proxy`, `metadb-server`) -* **Unified `[0x01, 0x04)` Sharding**: `PolicyShardSplitter` splits `MetaTable` shards on `group_key = PID` boundaries via `RaftCmd::ExecuteSplit`, isolates single-`PID` Jumbo Shards (`JumboIsolated`), and supports `DualModeFineGrained` `(PID, name)` splits (`1-RTT` writes + `1-hop` parallel scatter-gather `dirstat`). +* **Unified `[0x01, 0x04)` Sharding**: `PolicyShardSplitter` splits `MetaTable` shards on `group_key = PID` boundaries via `RaftCmd::ExecuteSplit`. `JumboIsolated` is a route flag, not a move of peer shards onto a dedicated host. `DualModeFineGrained` is a mode flag; a later split may cut on `(pid, name)`. The flag write does not copy keys. * **Two-Tier Control Plane**: `GlobalManager` + per-Cell `CellLocalManager` + `MetaCache` + bitspace-partitioned `IdRangeAllocator` (File bit-63 = `1`, Directory bit-63 = `0` with shard-locality leases). * **Interfaces**: 20 parameterized/escaped SQL templates in `metadb-proxy`, `tonic` gRPC services in `metadb-proto`, embedded `MetaDbEngine` SDK, `metadbd` daemon, and `metadb-ctl` CLI in `metadb-server`. @@ -89,13 +89,15 @@ Furthermore, adopters need an engine that can run in **Single-Node All-in-One Mo ## 5. Risks & Mitigations (`FeatureRange`) -1. **Single-Directory Skew (Jumbo Shard)**: Mitigated by (a) `CellLocalManager` `JumboIsolated` dedicated-node placement, and (b) `DualModeFineGrained` `(PID, name)` splitting using shard-local `[0x04] DirShardDelta` records so `create`/`unlink` remain `1-RTT` lock-free while `dirstat` uses `1-hop` scatter-gather. +1. **Single-Directory Skew (Jumbo Shard)**: This tree writes `JumboIsolated { dedicated_node, dominant_pid }` on the route and does not place the shard on a dedicated host or evict peer shards. `DualModeFineGrained` is a route flag; a later split may use shard-local `[0x04] DirShardDelta` records. That later split is not performed by the flag write itself. 2. **Unbounded Raft Log Growth During Remote Sink Partitions**: Mitigated by spilling overdue `AuxOutbox` entries into `[0x07] SpilledAuxOutbox` inside the local L0 SSTable flush, advancing `aux_outbox_durable_index` immediately. -3. **Future-Read Anomaly & Stale Parent Attributes**: Mitigated by `ActiveSnapshotRegistry` gating unversioned L0 flushes until `min_active_snapshot_hlc >= imm.max_hlc` and `AsyncAttrAggregator` folding deltas via the Coordinated Flush Barrier + Read-Path Reconciliation. +3. **Future-read limit and stale parent attributes**: `ActiveSnapshotRegistry` gates an unversioned L0 flush until `min_active_snapshot_hlc >= imm.max_hlc`. That gate does not remove the collapse-flush range-read limit: a range read at `start_hlc` can include later values of keys an open 2PC lease does not cover. Parent-attribute reconciliation is the coordinated flush barrier plus the read path, not a proof of zero future reads. --- -## 6. Capacity & Scale Verification (`FeatureRange`) +## 6. Capacity model (`FeatureRange`) + +The rows below are design arithmetic, not a scale measurement of this repository. Trillion-record figures in `arXiv:2610.32247v1` are Baidu production data. Role-trimmed BE fleets and extra cells are not deployed by this binary. * **Single-Node Starter (`10^8` records)**: `~18 GB` (`1-Voter`), `5–16` shards, `< 2 GiB` RAM on 1 `metadbd` node. * **100B Records (`10^11`)**: `~18 TB` logical (`~54 TB` 3-replica), `~4,500` shards (`4 GiB` each), served by 1 Cell (`~20` BE nodes). @@ -125,7 +127,7 @@ Full step-by-step execution rules, invariants, and verification commands are spe 3. **Phase 3 (`metadb-raft`)**: `openraft` Multi-Raft, segmented CRC32C `.raftlog` store, 3-watermark purge gate, batched `ReadIndex`, and online `1-Voter -> 3-Voter` `ConfChange`. 4. **Phase 4 (`metadb-tx`)**: Deterministic `RaftStateMachine`, `PushdownExecutor`, Coordinated Flush Barrier `AsyncAttrAggregator`, FIFO `AuxOutbox` + `[0x07]` spill, and Primary-Anchored 2PC + `TxnRecoveryWorker`. 5. **Phase 5 (`metadb-cluster` & `metadb-proxy`)**: Epoch-fenced `ExecuteSplit`, Jumbo isolation & `DualModeFineGrained` scatter-gather, Two-Tier Control Plane, `IdRangeAllocator`, and 20 parameterized SQL templates. -6. **Phase 6 (`metadb-server`)**: Unified `MetaDbEngine` SDK, `metadbd` multi-role server, `metadb-ctl` CLI, and end-to-end Stage 1 -> Stage 2 -> Stage 3 evolution suite. +6. **Phase 6 (`metadb-server`)**: `MetaDbEngine::open` / `PersistentMetaDbCluster` is the persistent engine. `new_single_node` is an in-memory simulator with no disk and no Raft. `metadbd` runs `all-in-one` only. `metadb-ctl` is the CLI. The end-to-end test is one all-in-one process, not a Stage 3 multi-cell suite. --- @@ -134,7 +136,7 @@ Full step-by-step execution rules, invariants, and verification commands are spe Subsystem fault-injection tests (`T-LSM-*`, `T-MVCC-*`, `T-COMP-*`, `T-RAFT-*`, `T-TX-*`, `T-2PC-*`, `T-SHARD-*`, `T-ID-*`, `T-SQL-*`) are defined in the three modular specifications and culminate in the end-to-end cluster evolution suite (`e2e_cluster_evolution_tests.rs`) verifying: 1. Persistent `1-Voter` crash recovery across torn `.raftlog` and `MANIFEST` tails. 2. Live `group_key = PID` shard splitting under concurrent load with zero mid-directory splits and transparent `EpochMismatch` retry. -3. Jumbo Shard dedicated-node isolation and `DualModeFineGrained` `(PID, name)` scatter-gather `dirstat` + paginated `listdir` + 2PC `rmdir`. +3. A `JumboIsolated` route flag, not dedicated-node isolation, and in-process `DualModeFineGrained` behavior. The flag write does not copy keys or evict peer shards. 4. Hotspot single-directory concurrent writes with linearizable Read-Path Reconciliation across L0 Coordinated Flush Barriers. 5. Exact-once `QuotaTable` and `SecondaryIndexTable` convergence across network partitions (`[0x07]` local spill) and leader failovers. 6. Crash-recoverable cross-shard 2PC `rename` (exclusive + overwrite + cycle rejection) and online `1-Voter -> Learner -> 3-Voter` Multi-Cell expansion. diff --git a/docs/designs/review_report.md b/docs/designs/review_report.md index 822eaf2..19fcd20 100644 --- a/docs/designs/review_report.md +++ b/docs/designs/review_report.md @@ -8,7 +8,7 @@ * [`docs/designs/consensus_and_transactions.md`](./consensus_and_transactions.md) * [`docs/designs/sharding_and_control_plane.md`](./sharding_and_control_plane.md) * **Review Methodology**: Adversarial Zero-Context Goldfish Audit inspired by Google's [Elephant-Goldfish Model (EGM)](https://github.com/google/elephant-goldfish-model). Conducted by spawning an isolated zero-context review subagent (`rubber-duck`, reading strictly the markdown specification files above with zero access to `crates/**` or prior review notes) alongside independent cross-session Goldfish design critique—without invoking external EGM CLI plugins. -* **Gate Status**: **Phase 0 Approved & Goldfish-Verified** — All 18 Blocking Findings (`B1`–`B18`) and 5 Non-Blocking Clarifications (`N1`–`N5`) are resolved directly in the specifications. +* **Gate Status**: Phase 0 is a specification review. The Goldfish notes resolved findings `B1`–`B18` and `N1`–`N5` in the design text. That review is not a first-launch acceptance of the running tree. --- @@ -44,7 +44,7 @@ | **N1** | Watermark Naming | Unified `lsm_flushed_index` + `attr_flushed_index` (which advance atomically together at `on_flush_durable`) into `state_flushed_index`, making `safe_purge_index = min(state_flushed_index, aux_outbox_durable_index, last_snapshot_index)` cleanly match "3-watermark purge gate" across all documents. | | **N2** | Paginated `ListDir` Contract | Defined explicit POSIX/S3 **Keyset Continuation Semantics** (`name > after_name` per bounded linearizable page) and unconditional filtering of internal `"_attr_"` rows across SQL Templates #9–#11 (`sharding_and_control_plane.md` §5.4, §7). | | **N3** | `QuotaRecord` Map Growth | Specified pruning of retired `ShardId` keys from `QuotaRecord.applied_by_shard` once `GlobalManager` marks a retired shard's outbox fully acknowledged (`consensus_and_transactions.md` §7.3). | -| **N4** | Phase-0 Status Vocabulary | Standardized status across `SITEMAP.md`, `Architecture.md`, `DEVELOPMENT_PLAN.md`, and `review_report.md` to `Phase 0 Approved & Goldfish-Verified`. | +| **N4** | Phase-0 Status Vocabulary | The old shared label was `Phase 0 Approved & Goldfish-Verified`. That names a specification review, not a first-launch pass of the running tree. | | **N5** | 16-Bit HLC Logical Overflow | Specified advancing the 48-bit `physical_ms` field by `+1ms` (yielding briefly if approaching `max_clock_drift_ms = 500ms`) and strictly forbade `u16` wrap-around (`DEVELOPMENT_PLAN.md` Phase 1; `metadb_architecture.md` §3.2). | --- diff --git a/docs/designs/sharding_and_control_plane.md b/docs/designs/sharding_and_control_plane.md index c2cc66f..72d3816 100644 --- a/docs/designs/sharding_and_control_plane.md +++ b/docs/designs/sharding_and_control_plane.md @@ -1,6 +1,6 @@ # EGM Subsystem Specification 3: Epoch-Fenced Topology Sharding, Jumbo Dual-Mode, Two-Tier Control Plane & Wire Protocols (`metadb-proto`, `metadb-cluster` & `metadb-proxy`) -* **Status**: Phase 0 Approved Specification +* **Status**: Phase 0 design note. Not a first-launch acceptance of the running tree. * **Target Crates**: `crates/metadb-proto`, `crates/metadb-cluster`, and `crates/metadb-proxy` * **Primary Reference**: Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou, *"MetaDB: Putting File-System Structure Back into Distributed Databases"*, [arXiv:2610.32247v1](https://arxiv.org/html/2610.32247v1) (Vrije Universiteit Amsterdam, Baidu & Peking University, 2026), §3.1, §3.2, §4.1, §8 * **Semantic Boundaries**: @@ -23,7 +23,7 @@ Scaling a file-system metadata engine from a single embedded node (`10^6` entrie ### Goals * **G1 (Unified `[0x01, 0x04)` User Keyspace & `ShardEpoch` Fencing)**: Partition `MetaTable` (`0x01`), `QuotaTable` (`0x02`), and `SecondaryIndexTable` (`0x03`) across contiguous byte intervals `[start_key, end_key)` protected by `ShardEpoch { conf_ver, version }`. -* **G2 (Raft-Replicated `PID`-Boundary Splits & Two-Level Jumbo Defense)**: Split `MetaTable` shards cleanly on `[0x01][pid: 8B BE]` boundaries via deterministic `RaftCmd::ExecuteSplit`; isolate single-`PID` Jumbo Shards onto dedicated BE nodes (`JumboIsolated`); and provide `DualModeFineGrained` `(PID, name)` splitting with shard-local `DirShardDelta` (`[0x04]`) so writes stay `1-RTT` lock-free and `dirstat` uses `1-hop` parallel scatter-gather. +* **G2 (Raft-Replicated `PID`-Boundary Splits & Two-Level Jumbo Defense)**: Split `MetaTable` shards on `[0x01][pid: 8B BE]` boundaries via `RaftCmd::ExecuteSplit`. In this tree, jumbo isolation writes `JumboIsolated { dedicated_node, dominant_pid }` on the route. `JumboIsolationPlanner` picks a node id already registered in the cell. It does not migrate peer shards onto a dedicated BE node. `EnableDualModeSplit` persists a mode flag and does not copy keys. A later split may cut on `(pid, name)` and use shard-local `DirShardDelta` (`[0x04]`). * **G3 (Two-Tier Control Plane + `MetaCache` + Hierarchical `IdRangeAllocator`)**: Partition cluster management into `GlobalManager` (coarse `[start_key, end_key) -> CellId` table + global ID block allocation) and per-Cell `CellLocalManager`s (`20K–50K` shards/Cell), fronted by `MetaCache`. * **G4 (Complete 20-Template SQL Compiler & Protobuf v1 Contracts)**: Compile all 20 parameterized/escaped metadata SQL templates in `<5µs` and expose typed `tonic` gRPC services (`MetadataService`, `TransactionService`, `RaftTransportService`, `ControlPlaneService`). @@ -106,7 +106,7 @@ pub struct ShardEpoch { * Triggered when shard live + SSTable bytes `>= shard_split_threshold_bytes`. * Reads SSTable `IndexBlock` entries (no `DataBlock` disk reads) to build a cumulative byte histogram: * For `0x02` (`QuotaTable`) / `0x03` (`SecondaryIndexTable`): picks midpoint 9-byte key `[prefix][id: 8B BE]`. - * For `0x01` (`MetaTable`) in `ShardSplitMode::DirectoryColocated`: groups index keys by 9-byte prefix `[0x01][pid: 8B BE]`. If a valid `split_pid` exists with `>= 10%` bytes on both sides, selects `split_key = [0x01][split_pid: 8B BE]`; otherwise emits `UnsplittableJumboShard { shard_id, dominant_pid }`. + * For `0x01` (`MetaTable`) in `DirectoryColocated`: the durable splitter groups bytes by parent. If one parent owns more than 85% of those bytes, or the shard has a single parent, it returns `SplitCandidate::Jumbo` and the caller stores a route flag. It does not emit a dedicated-host move. The in-memory simulator in `control_plane.rs` returns `UnsplittableJumboShard` and also does not move files. The `>= 10%` both-sides rule is design text, not the 85% check in `split_worker.rs`. * For `0x01` (`MetaTable`) when `dominant_pid` has `DualModeFineGrained` enabled: selects midpoint full `MetaKey` `split_key = [0x01][dominant_pid: 8B BE][split_name_utf8]` (ensuring `split_name != "_attr_"`). 2. **Stage A — Durable Control-Plane Registration & Intent Drain (`Planned`)**: * Parent leader calls `CellLocalManager::AllocSplitPlanRpc { request_uuid, parent_shard_id, split_key, target_version: old_version + 1 }`—which durably allocates `new_shard_id` (from `CellLocalManager`'s `GlobalManager`-leased `ShardId` pool) and persists `SplitPlanRecord::Planned` in `CellLocalManager`'s Raft log before replying. @@ -141,10 +141,7 @@ pub struct ShardEpoch { ### 6.1 `CellLocalManager` (`crates/metadb-cluster/src/cell_manager.rs`) * Receives `StoreHeartbeat` every `3s` from each BE node in its Cell containing `(node_capacity, disk_free, cpu_load, Vec)`. -* **Jumbo Isolation Scheduler**: When a shard reports `UnsplittableJumboShard { dominant_pid }`: - 1. Transitions shard state to `JumboIsolated { dedicated_node, dominant_pid }`. - 2. Selects the lowest-loaded BE node (or a newly joined spare node), migrates leadership/voter replica of the Jumbo Shard there if needed, and issues `TransferLeader` + `ChangeMembership` commands to drain non-jumbo shards off `dedicated_node`. - 3. If `approx_bytes > auto_dual_mode_threshold_bytes` (optional policy knob, disabled by default unless operator-approved or configured), automatically triggers `DualModeFineGrained` split. +* **Jumbo route flag, not a placement move**: When `discover_split_key` returns `SplitCandidate::Jumbo`, `maybe_split_or_isolate_shard` stores `JumboIsolated { dedicated_node, dominant_pid }` from `JumboIsolationPlanner::select_dedicated_node`. The chosen id is a node already in this cell. With one node, the flag names this process. The call does not issue `TransferLeader` or `ChangeMembership`, and it does not drain other shards off a host. `enable_dual_mode_split` is a separate call. It writes `DualModeFineGrained` and `dual_mode_pid` and does not copy keys. A design that would migrate leadership and evict co-hosted shards is not what this function does. ### 6.2 `GlobalManager` & Durable `IdRangeAllocator` (`crates/metadb-cluster/src/global_manager.rs`) * Maintains: @@ -222,6 +219,6 @@ Defined under `crates/metadb-proto/proto/metadb/v1/`: ## 10. Verification & Scale-Out Test Plan (`DetailedRange`) 1. **T-SHARD-1 (`ShardEpoch` Live Split Under Concurrent Load)**: Run 8 concurrent client threads executing `CreateFile`, `Unlink`, and `ListDir` while forcing repeated `PID`-boundary `ExecuteSplit`s; verify `EpochMismatch` triggers `MetaCache` refresh + retry with zero client-visible errors and zero split mid-directory. -2. **T-SHARD-2 (Jumbo Isolation & `DualModeFineGrained` Scatter-Gather)**: Insert 5,000 files into one `PID` exceeding threshold; verify `JumboIsolated` placement onto dedicated node, enable `DualModeFineGrained`, split `PID` across 3 sub-shards, verify `CreateFile`/`Unlink` execute `1-RTT` per sub-shard, `DirStat` reconciles exact sum across all 3 sub-shards, cursor `ListDir` returns exact sorted union, and 2PC `Rmdir` succeeds only once all 3 sub-shards are empty. +2. **T-SHARD-2 (Jumbo flag & `DualModeFineGrained` scatter-gather)**: In-process tests cover a `JumboIsolated` route flag and later `(pid, name)` split behavior. They do not verify placement onto a dedicated host or eviction of peer shards. `EnableDualModeSplit` does not itself copy keys. 3. **T-ID-1 (Locality-Aware `IdRangeAllocator` Collision-Free Test)**: Concurrently allocate 100,000 File and Directory IDs across multiple simulated restarts and Cells; verify zero duplicates, bit-63 File/Directory separation, and `>90%` single-shard `mkdir` colocation. 4. **T-SQL-1 (All 20 SQL Templates & Escaping Fuzz Test)**: Verify all 20 templates with both inline escaped literals (`'it''s_a_file.txt'`, rejected `'_attr_'`) and `?` positional parameters, plus cursor pagination. diff --git a/docs/designs/storage_lsm_mvcc.md b/docs/designs/storage_lsm_mvcc.md index be17622..2b7780c 100644 --- a/docs/designs/storage_lsm_mvcc.md +++ b/docs/designs/storage_lsm_mvcc.md @@ -1,6 +1,6 @@ # EGM Subsystem Specification 1: Pure-Rust WAL-less LSM, `SnapshotGuard` MVCC & Locality-Aware Compaction (`metadb-storage`) -* **Status**: Phase 0 Approved Specification +* **Status**: Phase 0 design note. Not a first-launch acceptance of the running tree. * **Target Crate**: `crates/metadb-storage` (depends solely on `metadb-core` + pure-Rust utilities; zero C/C++ FFI) * **Primary Reference**: Zebin Ren ([@ZebinRen](https://github.com/ZebinRen)), Biao Cao, Kang Chen ([@kangchenPKU](https://github.com/kangchenPKU)), Zhihui Yin, Qiushi Chen, Jielong Jian, Jiwei Xiong, Xinxing Wang, Yan Xing, Liguo Duan, Ran Zheng, Xianjun Meng, and Zhenyu Hou, *"MetaDB: Putting File-System Structure Back into Distributed Databases"*, [arXiv:2610.32247v1](https://arxiv.org/html/2610.32247v1) (Vrije Universiteit Amsterdam, Baidu & Peking University, 2026), §3.2 & §6 * **Semantic Boundaries**: @@ -25,7 +25,7 @@ At the same time, omitting version metadata inside SSTables introduces two letha ### Goals * **G1 (Pluggable Pure-Rust WAL-less LSM)**: Provide a trait-abstracted `StorageBackend` backed by a disk-persistent sorted SSTable engine (`LsmStorageBackend`) with zero local KV WAL files (relying on `metadb-raft` for pre-flush durability). -* **G2 (Mathematically Sound Unversioned SSTable Flush)**: Guarantee Snapshot Isolation within the `5,000ms` transaction window via `ActiveSnapshotRegistry` (`SnapshotGuard`) while writing **only** unversioned collapsed values or single physical tombstones to disk (`~60%` KV write reduction, zero double-tombstones). +* **G2 (Unversioned SSTable flush)**: `ActiveSnapshotRegistry` holds an `ImmMemTable` until `min_active_snapshot_hlc >= imm.max_hlc`, then writes a collapsed unversioned value or one physical tombstone. That is not a guarantee of zero future-read or phantom anomalies. Collapse may keep only the latest value. A range read at `start_hlc` can include later values of keys an open 2PC lease does not cover. Point reads of keys that lease records stay at the pre-image until commit. The `~60%` KV write reduction is a paper/model figure from `arXiv:2610.32247v1`, not a ratio asserted by `mvcc_snapshot_tests.rs`. * **G3 (Coordinated Flush Barrier)**: Allow upper-layer `AsyncAttrAggregator` (`_attr_` folded deltas) and `AuxOutbox` (`[0x07]` overflow spills) to inject deterministic key-value entries atomically into the sealing `ImmMemTable` flush batch before `lsm_flushed_index` advances. * **G4 (Bottommost-Safe Locality-Aware Compaction)**: Track physical tombstone density per 9-byte spatial prefix bucket (`[table_prefix][group_key: 8B]`) and compact dense buckets down to the deepest overlapping SSTable level so physical tombstones are legally purged in milliseconds. * **G5 (Zero-Copy Checkpoint for Raft Snapshots)**: Materialize consistent point-in-time shard snapshots via hard-linked immutable `.sst` files and a standalone `MANIFEST`. @@ -93,7 +93,7 @@ When `imm` flushes to L0 SSTable, $H_{\text{disk}}$ advances to $\max(H_{\text{d * Every mutation with $hlc > H_{\text{disk}}$ still resides in younger `ImmMemTable`s or the active `MemTable` with full `(hlc, MvccValue)` chains. * During `get(K, &g)` or `scan([start, end), &g)`: 1. Inspect `ActiveMemTable` then `ImmMemTable`s from newest to oldest for the latest version of `K` with $v.\text{hlc} \le g.\text{read\_hlc}$. If found, return `Some(v)` or `None` (if `MvccValue::Tombstone`) immediately without consulting older `ImmMemTable`s or SSTables. - 2. If no version with $v.\text{hlc} \le g.\text{read\_hlc}$ exists in memory, `K` experienced zero mutations in $(H_{\text{disk}}, g.\text{read\_hlc}]$. Therefore, `K`'s exact value at $g.\text{read\_hlc}$ equals its collapsed state at $H_{\text{disk}}$ in `L0..L3` SSTables. + 2. If no version with $v.\text{hlc} \le g.\text{read\_hlc}$ exists in memory, the flush-gate argument treats `K` as unchanged in $(H_{\text{disk}}, g.\text{read\_hlc}]$. That argument does not cover an open 2PC lease. Collapse may retain only the latest value of a prepared key, which is still the pre-image until commit, and it does not pin every older version of other keys. A range read at `start_hlc` can include later values of keys the lease does not cover. ### 6.3 Coordinated Flush Barrier API When sealing `ActiveMemTable` at `max_raft_index = M`: diff --git a/docs/fr/architecture.md b/docs/fr/architecture.md index 987826d..f7ff636 100644 --- a/docs/fr/architecture.md +++ b/docs/fr/architecture.md @@ -88,6 +88,8 @@ Les versions MVCC vivent en mémoire pendant `storage.mvcc_retention_ms` (défau Chaque shard local est un groupe `openraft` 0.10. Le journal est un fichier segmenté CRC32C sous `.../shards//raft`. Options par défaut, qui ne sont **pas** chargées depuis le TOML (`raft_options` est `#[serde(skip)]`) : +That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. + | Champ | Défaut | | :--- | :--- | | battement | 150 ms | diff --git a/docs/fr/configuration.md b/docs/fr/configuration.md index 94e914f..6e90c0b 100644 --- a/docs/fr/configuration.md +++ b/docs/fr/configuration.md @@ -2,7 +2,9 @@ [Présentation](./README.md) · [English](../en/configuration.md) · [Deutsch](../de/configuration.md) · [日本語](../ja/configuration.md) · [简体中文](../zh/configuration.md) -`metadbd --config` et `ServerTomlConfig::from_toml_file` / `from_toml_str` lisent le TOML (`crates/metadb-server/src/config.rs`). Les clés inconnues qui ne nomment ni un secret ni TLS sont ignorées. Un `shared_secret` mal orthographié, une clé de jeton ou de mot de passe, ou une clé TLS ou de certificat sont refusés, et le processus ne démarre pas. Chaque section connue est facultative. Les champs omis prennent les valeurs par défaut ci-dessous. +`metadbd --config` et `ServerTomlConfig::from_toml_file` / `from_toml_str` lisent le TOML (`crates/metadb-server/src/config.rs`). Chaque section connue est facultative. Les champs omis prennent les valeurs par défaut ci-dessous. + +On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. ## Valeurs par défaut @@ -29,6 +31,8 @@ Il n'y a pas de table `[raft]`. `ServerTomlConfig.raft_options` est ignoré par serde et reste à `RaftNodeOptions::default()` (battement 150 ms, élection 450–900 ms, conservation du journal d'instantané 0, segment 64 Mio). +That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. + `to_lsm_config` fixe toujours `auto_locality_compaction: true`. ## Exemple diff --git a/docs/guides/de/client-apis-and-sql.md b/docs/guides/de/client-apis-and-sql.md index 0ca5c4c..46a347f 100644 --- a/docs/guides/de/client-apis-and-sql.md +++ b/docs/guides/de/client-apis-and-sql.md @@ -11,7 +11,7 @@ * `MetadataService`: `CreateFile`, `Mkdir`, `Unlink`, `Rmdir`, `SetAttr`, `Lookup`, `DirStat`, `ListDir`, `ExecuteSql`, `GetQuota`, `SetQuotaLimit`, `ListQuotas`, `GetSecondaryIndex`, `ScanSecondaryIndex`. * `TransactionService`: `Rename` (automatisch `1-RTT` lokal oder primärverankertes `2PC` über Shards hinweg) sowie `Prepare2pc`, `CommitPrimary2pc`, `CommitSecondary2pc`, `Abort2pc`, `CheckTxnStatus`, `ApplyAuxBatch`. * `ControlPlaneService`: `GetRoutes`, `AllocateIdBlock`, `StoreHeartbeat`, `TriggerShardSplit`, `EnableDualModeSplit`, `ScaleShardReplicas`, `RegisterCell`. -3. **20 Leichtgewichtige SQL-Vorlagen (`metadb-proxy`)**: Direkte Kompilierung in `<5 µs` ohne allgemeinen SQL-Optimizer (alle 20 literalen, `?`-parametrisierten und escapteten SQL-Vorlagen sind implementiert und getestet). +3. **20 Leichtgewichtige SQL-Vorlagen (`metadb-proxy`)**: `sql_templates_tests` covers all 20 templates. A compile time under `5µs` is not a measurement of this repository. > **Reservierter Eintragsname**: Der Name `'_attr_'` (sowie Namen mit `'\0'`) ist für reguläre Dateien/Verzeichnisse gesperrt (`MetaDbError::ReservedEntryName`) und ausschließlich für Vorlage #7 (`DirStat`) reserviert. diff --git a/docs/guides/de/deployment.md b/docs/guides/de/deployment.md index eb7590f..c0f5ab4 100644 --- a/docs/guides/de/deployment.md +++ b/docs/guides/de/deployment.md @@ -8,6 +8,8 @@ The current binary runs a persistent deployment only as `all-in-one`. A second ` ## Stufe 1: Eigenständiger Einzelknoten (`metadbd --role all-in-one`) `[Implementiert]` +`[Implementiert]` means one `metadbd --role all-in-one` process in current source. It is not a multi-cell deployment. `MetaDbEngine::new_single_node` is an in-memory simulator with no disk and no Raft, not this process. + Im Einzelknotenmodus laufen `GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy` und das **`1-Voter`-OpenRaft**-Speicher-Backend in einem einzigen Prozess. Auf ein separates KV-WAL wird verzichtet, da das CRC32C-gesicherte `.raftlog` bereits sequenzielle Absturzsicherheit garantiert. ```toml @@ -44,6 +46,8 @@ metadbd --config /etc/metadb/standalone.toml ## Stufe 2: Dynamisches Shard-Splitting an `PID`-Grenzen `[Implementiert]` +`[Implementiert]` means in-process PID-boundary splits inside that same all-in-one process. It is not a multi-host topology. Jumbo isolation is a route flag and does not move peer shards. + Überschreitet ein Shard `shard_split_threshold_bytes`, teilt `PolicyShardSplitter` ihn strikt entlang einer `group_key = PID`-Grenze (`[0x01][pid: 8B BE]`), sodass `(PID, "_attr_")` und sämtliche Kind-Einträge gemeinsam auf demselben Shard verbleiben. --- diff --git a/docs/guides/de/operations-and-tuning.md b/docs/guides/de/operations-and-tuning.md index 19aad65..16a48cc 100644 --- a/docs/guides/de/operations-and-tuning.md +++ b/docs/guides/de/operations-and-tuning.md @@ -6,6 +6,8 @@ ## 1. Administrations-CLI `metadb-ctl` `[Implementiert]` +`[Implementiert]` means the `metadb-ctl` binary exists and talks to an all-in-one process. `cell register` does not create a cell. `metadbd --role be` is not a supported deployment. Output from a bench command is for the machine that ran it, not a checked-in result. + ```bash # Cluster-, Cell-, BE-Knoten- und Raft-Watermark-Status prüfen metadb-ctl --endpoint 127.0.0.1:7800 cluster status diff --git a/docs/guides/en/client-apis-and-sql.md b/docs/guides/en/client-apis-and-sql.md index d68b0ea..6ff80c2 100644 --- a/docs/guides/en/client-apis-and-sql.md +++ b/docs/guides/en/client-apis-and-sql.md @@ -5,12 +5,14 @@ MetaDB exposes three client access surfaces tailored to different integration needs: 1. **Embedded Rust SDK (`metadb-server`)** — Zero-serialization direct calls for co-located Rust services (`PersistentMetaDbCluster` async persistent API and `MetaDbEngine` synchronous API). 2. **Typed `tonic` gRPC APIs (`metadb-proto` & `metadb-server`)** — High-throughput multiplexed RPCs for networked RustFS data nodes and proxies (`MetadataService`, `TransactionService`, `ControlPlaneService`, `RaftTransportService`). -3. **20 Lightweight SQL Templates (`metadb-proxy`)** — Sub-5µs pattern compilation without general-purpose SQL optimizer overhead (all 20 literal, `?`-parameterized, and single-quote-escaped templates implemented and verified). +3. **20 Lightweight SQL Templates (`metadb-proxy`)** — `sql_templates_tests` covers all 20 literal, `?`-parameterized, and escaped templates. A compile time under `5µs` is not a measurement of this repository. --- ## 1. gRPC Service Surface (`metadb.v1`) `[Implemented]` +`[Implemented]` means one all-in-one process serves these RPCs. `RegisterCell` returns an error and stores nothing. Roles other than `all-in-one` are rejected before listen. + ### `MetadataService` (`proto/metadb/v1/metadata.proto`) * **Namespace Mutations (`1-RTT` Pushdown)**: `CreateFile`, `Mkdir`, `Unlink`, `Rmdir`, `SetAttr` (`chmod`, `chown`, `truncate`, `utimes`). * **Linearizable Namespace Reads (`ReadIndex`)**: `Lookup`, `DirStat` (with Read-Path Reconciliation), `ListDir` (cursor-paginated via `after_name` + `limit`), `ExecuteSql`. diff --git a/docs/guides/en/operations-and-tuning.md b/docs/guides/en/operations-and-tuning.md index 9278239..f09d597 100644 --- a/docs/guides/en/operations-and-tuning.md +++ b/docs/guides/en/operations-and-tuning.md @@ -6,6 +6,8 @@ ## 1. `metadb-ctl` Administration CLI `[Implemented]` +`[Implemented]` means the `metadb-ctl` binary exists and talks to an all-in-one process. `cell register` does not create a cell. `metadbd --role be` is not a supported deployment. Output from a bench command is for the machine that ran it, not a checked-in result. + `metadb-ctl` connects to gRPC services to inspect local cluster state, manage shards, execute SQL templates, and run synthetic benchmarks. SQL results are complete JSON responses; command failures exit nonzero. Benchmark JSONL reports an allocated `bench_pid`, exact attempts, successes, failures, and latency statistics. See [upgrade and compatibility notes](../../designs/correctness_hardening.md). ```bash diff --git a/docs/guides/fr/client-apis-and-sql.md b/docs/guides/fr/client-apis-and-sql.md index 2a546fa..35ef3a0 100644 --- a/docs/guides/fr/client-apis-and-sql.md +++ b/docs/guides/fr/client-apis-and-sql.md @@ -11,7 +11,7 @@ * `MetadataService` : `CreateFile`, `Mkdir`, `Unlink`, `Rmdir`, `SetAttr`, `Lookup`, `DirStat`, `ListDir`, `ExecuteSql`, `GetQuota`, `SetQuotaLimit`, `ListQuotas`, `GetSecondaryIndex`, `ScanSecondaryIndex`. * `TransactionService` : `Rename` (`1-RTT` local ou `2PC` inter-shards automatique) ainsi que `Prepare2pc`, `CommitPrimary2pc`, `CommitSecondary2pc`, `Abort2pc`, `CheckTxnStatus`, `ApplyAuxBatch`. * `ControlPlaneService` : `GetRoutes`, `AllocateIdBlock`, `StoreHeartbeat`, `TriggerShardSplit`, `EnableDualModeSplit`, `ScaleShardReplicas`, `RegisterCell`. -3. **20 Modèles SQL Légers (`metadb-proxy`)** : Compilation directe en `<5 µs` sans optimiseur SQL généraliste (les 20 modèles littéraux, paramétrés `?` et échappés sont implémentés et vérifiés). +3. **20 Modèles SQL Légers (`metadb-proxy`)** : `sql_templates_tests` covers all 20 templates. A compile time under `5µs` is not a measurement of this repository. > **Nom réservé** : Le nom `'_attr_'` (ainsi que tout nom contenant `'\0'`) est interdit pour les fichiers/répertoires utilisateurs (`MetaDbError::ReservedEntryName`) et réservé au modèle #7 (`DirStat`). diff --git a/docs/guides/fr/deployment.md b/docs/guides/fr/deployment.md index 2d15d77..49eb0ef 100644 --- a/docs/guides/fr/deployment.md +++ b/docs/guides/fr/deployment.md @@ -8,6 +8,8 @@ The current binary runs a persistent deployment only as `all-in-one`. A second ` ## Étape 1 : Déploiement Mononœud Autonome (`metadbd --role all-in-one`) `[Implémenté]` +`[Implémenté]` means one `metadbd --role all-in-one` process in current source. It is not a multi-cell deployment. `MetaDbEngine::new_single_node` is an in-memory simulator with no disk and no Raft, not this process. + Tous les rôles (`GlobalManager`, `CellLocalManager`, `MetaCache`, `Proxy` et stockage `BE` en **OpenRaft `1-Voter`**) tournent dans un seul binaire. Le WAL local du moteur KV est désactivé : seul le journal segmenté `.raftlog` (protégé par CRC32C) assure la durabilité séquentielle. ```toml @@ -44,6 +46,8 @@ metadbd --config /etc/metadb/standalone.toml ## Étape 2 : Découpage Dynamique sur Frontière `PID` `[Implémenté]` +`[Implémenté]` means in-process PID-boundary splits inside that same all-in-one process. It is not a multi-host topology. Jumbo isolation is a route flag and does not move peer shards. + Lorsqu'un shard dépasse `shard_split_threshold_bytes`, `PolicyShardSplitter` choisit une frontière stricte `group_key = PID` (`[0x01][pid: 8B BE]`) afin que `(PID, "_attr_")` et tous ses enfants restent sur le même shard. --- diff --git a/docs/guides/fr/operations-and-tuning.md b/docs/guides/fr/operations-and-tuning.md index 2f1e66b..aea94a5 100644 --- a/docs/guides/fr/operations-and-tuning.md +++ b/docs/guides/fr/operations-and-tuning.md @@ -6,6 +6,8 @@ ## 1. Utilitaire d'Administration `metadb-ctl` `[Implémenté]` +`[Implémenté]` means the `metadb-ctl` binary exists and talks to an all-in-one process. `cell register` does not create a cell. `metadbd --role be` is not a supported deployment. Output from a bench command is for the machine that ran it, not a checked-in result. + ```bash # État global des cellules, nœuds BE et filigranes Raft metadb-ctl --endpoint 127.0.0.1:7800 cluster status diff --git a/docs/guides/ja/client-apis-and-sql.md b/docs/guides/ja/client-apis-and-sql.md index fc657e6..cc40c5d 100644 --- a/docs/guides/ja/client-apis-and-sql.md +++ b/docs/guides/ja/client-apis-and-sql.md @@ -11,7 +11,7 @@ * `MetadataService`:`CreateFile`, `Mkdir`, `Unlink`, `Rmdir`, `SetAttr`, `Lookup`, `DirStat`, `ListDir`, `ExecuteSql`, `GetQuota`, `SetQuotaLimit`, `ListQuotas`, `GetSecondaryIndex`, `ScanSecondaryIndex`。 * `TransactionService`:`Rename`(単一シャード `1-RTT` / クロスシャード `2PC` 自動切替)および内部 2PC / `ApplyAuxBatch` RPC。 * `ControlPlaneService`:`GetRoutes`, `AllocateIdBlock`, `StoreHeartbeat`, `TriggerShardSplit`, `EnableDualModeSplit`, `ScaleShardReplicas`, `RegisterCell`。 -3. **20 種類の軽量 SQL テンプレート (`metadb-proxy`)**:汎用 SQL オプティマイザを経由せず `<5µs` でストレージ実行プランへ直接変換します(全 20 パターンおよび `?` プレースホルダ・エスケープ実装済)。 +3. **20 種類の軽量 SQL テンプレート (`metadb-proxy`)**:`sql_templates_tests` covers all 20 templates. A compile time under `5µs` is not a measurement of this repository. > **予約名ルール**:ユーザーファイル/ディレクトリ名として `'_attr_'` または NULL 文字 `'\0'` を含む名前は使用できません(`MetaDbError::ReservedEntryName`)。`name = '_attr_'` はテンプレート #7 の `DirStat` 専用です。 diff --git a/docs/guides/ja/deployment.md b/docs/guides/ja/deployment.md index 1001e5a..8f03713 100644 --- a/docs/guides/ja/deployment.md +++ b/docs/guides/ja/deployment.md @@ -8,6 +8,8 @@ The current binary runs a persistent deployment only as `all-in-one`. A second ` ## Stage 1:スタンドアロン・シングルノード構成 (`metadbd --role all-in-one`) `[実装済]` +`[実装済]` means one `metadbd --role all-in-one` process in current source. It is not a multi-cell deployment. `MetaDbEngine::new_single_node` is an in-memory simulator with no disk and no Raft, not this process. + 単一プロセス内で `GlobalManager`、`CellLocalManager`、`MetaCache`、`Proxy`、および **`1-Voter` OpenRaft** バックエンドを実行します。ローカル KV の WAL は無効化され、CRC32C チェックサム付き `.raftlog` セグメントへの順次追記のみで耐久性を保証します。 ```toml @@ -44,6 +46,8 @@ metadbd --config /etc/metadb/standalone.toml ## Stage 2:単一ホスト上の自動 `PID` 境界シャード分割 `[実装済]` +`[実装済]` means in-process PID-boundary splits inside that same all-in-one process. It is not a multi-host topology. Jumbo isolation is a route flag and does not move peer shards. + シャードサイズが `shard_split_threshold_bytes` を超えると、`PolicyShardSplitter` が `group_key = PID`(`[0x01][pid: 8B BE]`)境界でシャードを分割し、親ディレクトリ属性 `(PID, "_attr_")` と全子エントリを同一シャードに維持します。 --- diff --git a/docs/guides/ja/operations-and-tuning.md b/docs/guides/ja/operations-and-tuning.md index f79dfb7..d40509c 100644 --- a/docs/guides/ja/operations-and-tuning.md +++ b/docs/guides/ja/operations-and-tuning.md @@ -6,6 +6,8 @@ ## 1. `metadb-ctl` 管理 CLI `[実装済]` +`[実装済]` means the `metadb-ctl` binary exists and talks to an all-in-one process. `cell register` does not create a cell. `metadbd --role be` is not a supported deployment. Output from a bench command is for the machine that ran it, not a checked-in result. + ```bash # クラスター全体の Cell・BE ノード状態・3 ウォーターマーク遅延を確認 metadb-ctl --endpoint 127.0.0.1:7800 cluster status diff --git a/docs/guides/zh/client-apis-and-sql.md b/docs/guides/zh/client-apis-and-sql.md index 06bfdc8..2e08dcb 100644 --- a/docs/guides/zh/client-apis-and-sql.md +++ b/docs/guides/zh/client-apis-and-sql.md @@ -5,12 +5,14 @@ MetaDB 提供三类客户端接入方式: 1. **嵌入式 Rust SDK (`metadb-server`)** — 同进程零序列化调用(提供 `PersistentMetaDbCluster` 异步持久化版与 `MetaDbEngine` 同步内存版)。 2. **强类型 `tonic` gRPC 接口 (`metadb-proto` & `metadb-server`)** — 面向分布式 RustFS 数据节点与代理的高吞吐多路复用 RPC。 -3. **20 条轻量级元数据 SQL 模板 (`metadb-proxy`)** — 省去通用 SQL 优化器开销,在 `<5µs` 内直接编译为存储执行计划(全部 20 条字面量、`?` 参数绑定与引号转义模式均已实现并验证)。 +3. **20 条轻量级元数据 SQL 模板 (`metadb-proxy`)** — `sql_templates_tests` covers all 20 templates. A compile time under `5µs` is not a measurement of this repository. --- ## 1. gRPC 服务契约概览 (`metadb.v1`) `[已实现]` +`[已实现]` means one all-in-one process serves these RPCs. `RegisterCell` returns an error and stores nothing. Roles other than `all-in-one` are rejected before listen. + * **`MetadataService` (`metadata.proto`)**: * 单分片 `1-RTT` 写操作:`CreateFile`、`Mkdir`、`Unlink`、`Rmdir`、`SetAttr`(`chmod`、`chown`、`truncate`、`utimes`)。 * 线性一致读操作(`ReadIndex`):`Lookup`、`DirStat`(含读取路径实时对账)、`ListDir`(支持 `after_name` + `limit` 游标分页)、`ExecuteSql`。 diff --git a/docs/guides/zh/deployment.md b/docs/guides/zh/deployment.md index 599063d5..72c7cc9 100644 --- a/docs/guides/zh/deployment.md +++ b/docs/guides/zh/deployment.md @@ -10,6 +10,8 @@ The current binary runs a persistent deployment only as `all-in-one`. A second ` ## 阶段一:独立单节点部署 (`metadbd --role all-in-one`) `[已实现]` +`[已实现]` means one `metadbd --role all-in-one` process in current source. It is not a multi-cell deployment. `MetaDbEngine::new_single_node` is an in-memory simulator with no disk and no Raft, not this process. + 在单机一体化模式下,`GlobalManager`、`CellLocalManager`、`MetaCache`、`Proxy` 与 `BE` 存储引擎运行于同一进程,底层采用 **`1-Voter` OpenRaft**。由于分段 CRC32C `.raftlog` 已经提供顺序写崩溃持久化保障,底层 LSM 引擎彻底关闭本地 KV WAL,避免双重写日志开销。 ### `standalone.toml` 配置示例 @@ -52,6 +54,8 @@ metadbd --config /etc/metadb/standalone.toml ## 阶段二:单节点动态 `PID` 边界分片分裂 `[已实现]` +`[已实现]` means in-process PID-boundary splits inside that same all-in-one process. It is not a multi-host topology. Jumbo isolation is a route flag and does not move peer shards. + 当分片容量超过 `shard_split_threshold_bytes` 时,`PolicyShardSplitter` 会扫描 SSTable 块索引中点并严格沿着 `group_key = PID`(`[0x01][pid: 8B BE]`)边界执行原子分裂: * 同一目录的属性记录 `(PID, "_attr_")` 与所有直接子项 `(PID, child_name)` 始终保持在同一分片内。 * 单机上的多个 OpenRaft 分片组可并行刷盘与压缩,充分压榨多核与 NVMe 多队列吞吐。 diff --git a/docs/guides/zh/operations-and-tuning.md b/docs/guides/zh/operations-and-tuning.md index ed261ea..f7d2292 100644 --- a/docs/guides/zh/operations-and-tuning.md +++ b/docs/guides/zh/operations-and-tuning.md @@ -6,6 +6,8 @@ ## 1. `metadb-ctl` 运维命令行工具 `[已实现]` +`[已实现]` means the `metadb-ctl` binary exists and talks to an all-in-one process. `cell register` does not create a cell. `metadbd --role be` is not a supported deployment. Output from a bench command is for the machine that ran it, not a checked-in result. + ```bash # 查看各 Cell、BE 节点健康状态、分片分布与 Raft 三水位延迟 metadb-ctl --endpoint 127.0.0.1:7800 cluster status diff --git a/docs/ja/architecture.md b/docs/ja/architecture.md index e29aa2d..481e6f5 100644 --- a/docs/ja/architecture.md +++ b/docs/ja/architecture.md @@ -88,6 +88,8 @@ MVCC の版は `storage.mvcc_retention_ms`(既定 5,000)のあいだメモ ローカルの各シャードは `openraft` 0.10 のグループです。ログは `.../shards//raft` 以下の分割された CRC32C ファイルです。既定値は TOML から **読み込まれません**(`raft_options` は `#[serde(skip)]`): +That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. + | 項目 | 既定 | | :--- | :--- | | ハートビート | 150 ms | diff --git a/docs/ja/configuration.md b/docs/ja/configuration.md index 30fd3fa..0b826b9 100644 --- a/docs/ja/configuration.md +++ b/docs/ja/configuration.md @@ -2,7 +2,9 @@ [概要](./README.md) · [English](../en/configuration.md) · [Français](../fr/configuration.md) · [Deutsch](../de/configuration.md) · [简体中文](../zh/configuration.md) -`metadbd --config` と `ServerTomlConfig::from_toml_file` / `from_toml_str` は TOML を読みます(`crates/metadb-server/src/config.rs`)。シークレットや TLS を示さない未知のキーは無視されます。綴りの違う `shared_secret`、トークンやパスワードのキー、TLS や証明書のキーは拒否され、プロセスは起動しません。既知のセクションは省略できます。省略した項目は次の既定値になります。 +`metadbd --config` と `ServerTomlConfig::from_toml_file` / `from_toml_str` は TOML を読みます(`crates/metadb-server/src/config.rs`)。既知のセクションは省略できます。省略した項目は次の既定値になります。 + +On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. ## 既定値 @@ -29,6 +31,8 @@ `[raft]` テーブルはありません。`ServerTomlConfig.raft_options` は serde がスキップし、`RaftNodeOptions::default()` のままです(ハートビート 150 ms、選挙 450–900 ms、スナップショットログ保持 0、セグメント 64 MiB)。 +That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. + `to_lsm_config` は常に `auto_locality_compaction: true` を設定します。 ## 例 diff --git a/docs/zh/architecture.md b/docs/zh/architecture.md index 8d1cfad..01ebc99 100644 --- a/docs/zh/architecture.md +++ b/docs/zh/architecture.md @@ -88,6 +88,8 @@ MVCC 版本在内存中保留 `storage.mvcc_retention_ms`(默认 5,000)。 每个本地分片是一个 `openraft` 0.10 组。日志是 `.../shards//raft` 下的分段 CRC32C 文件。下列默认值 **不** 从 TOML 加载(`raft_options` 为 `#[serde(skip)]`): +That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. + | 字段 | 默认 | | :--- | :--- | | 心跳 | 150 ms | diff --git a/docs/zh/configuration.md b/docs/zh/configuration.md index 293ca12..6764784 100644 --- a/docs/zh/configuration.md +++ b/docs/zh/configuration.md @@ -2,7 +2,9 @@ [概览](./README.md) · [English](../en/configuration.md) · [Français](../fr/configuration.md) · [Deutsch](../de/configuration.md) · [日本語](../ja/configuration.md) -`metadbd --config` 以及 `ServerTomlConfig::from_toml_file` / `from_toml_str` 读取 TOML(`crates/metadb-server/src/config.rs`)。不表示密钥或 TLS 的未知键仍会被忽略。拼错的 `shared_secret`、令牌或密码键,以及任何 TLS 或证书键都会被拒绝,进程不会启动。每个已知节都可以省略。省略的字段取下面的默认值。 +`metadbd --config` 以及 `ServerTomlConfig::from_toml_file` / `from_toml_str` 读取 TOML(`crates/metadb-server/src/config.rs`)。每个已知节都可以省略。省略的字段取下面的默认值。 + +On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. ## 默认值 @@ -29,6 +31,8 @@ 没有 `[raft]` 表。`ServerTomlConfig.raft_options` 被 serde 跳过,保持 `RaftNodeOptions::default()`(心跳 150 ms,选举 450–900 ms,快照日志保留 0,段大小 64 MiB)。 +That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. + `to_lsm_config` 总是把 `auto_locality_compaction` 设为 `true`。 ## 示例 From 188b2c90dbdc8f70f5138b17d809a9bd8694b63e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Nov 2026 19:43:16 +0000 Subject: [PATCH 4/5] Give locale launch samples an explicit loopback opt-in State the auth rules as the resulting tree, without saying what main does today or which pull request is still open. The eight runnable locale samples now pass --config and a literal 127.0.0.1 development flag, and show the security block to use instead when a secret is set. Co-authored-by: RustFS --- docs/de/architecture.md | 1 - docs/de/build-and-run.md | 34 ++++++++++++++++++++++++---------- docs/de/configuration.md | 7 +++---- docs/fr/architecture.md | 1 - docs/fr/build-and-run.md | 34 ++++++++++++++++++++++++---------- docs/fr/configuration.md | 7 +++---- docs/guides/de/deployment.md | 15 ++++++++++++++- docs/guides/fr/deployment.md | 15 ++++++++++++++- docs/guides/ja/deployment.md | 15 ++++++++++++++- docs/guides/zh/deployment.md | 13 ++++++++++++- docs/ja/architecture.md | 1 - docs/ja/build-and-run.md | 34 ++++++++++++++++++++++++---------- docs/ja/configuration.md | 7 +++---- docs/zh/architecture.md | 1 - docs/zh/build-and-run.md | 34 ++++++++++++++++++++++++---------- docs/zh/configuration.md | 7 +++---- 16 files changed, 162 insertions(+), 64 deletions(-) diff --git a/docs/de/architecture.md b/docs/de/architecture.md index 873f0e7..5b60db9 100644 --- a/docs/de/architecture.md +++ b/docs/de/architecture.md @@ -88,7 +88,6 @@ MVCC-Versionen leben `storage.mvcc_retention_ms` (Vorgabe 5.000) lang im Speiche Jeder lokale Shard ist eine `openraft`-0.10-Gruppe. Das Log ist eine segmentierte CRC32C-Datei unter `.../shards//raft`. Vorgaben, die **nicht** aus TOML geladen werden (`raft_options` ist `#[serde(skip)]`): -That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. | Feld | Vorgabe | | :--- | :--- | diff --git a/docs/de/build-and-run.md b/docs/de/build-and-run.md index 039aaed..6d75a02 100644 --- a/docs/de/build-and-run.md +++ b/docs/de/build-and-run.md @@ -44,27 +44,41 @@ Flags von `metadbd` (`crates/metadb-server/src/bin/metadbd.rs`): Jede Rolle außer `all-in-one` scheitert, bevor der Listener gebunden wird, mit `server role ... is not implemented; only all-in-one runs a process`. -Beispiel, nur Loopback: +`metadbd` with no config file uses an empty `shared_secret` and `allow_unauthenticated = false`, so that process does not start. The file below is the explicit loopback development opt-in. It is not a credential. Bind only a literal loopback IP (`127.0.0.1`). The hostname `localhost` is not accepted for this flag. Do not use it on a non-loopback address. ```bash mkdir -p /tmp/metadb-data -cargo run -p metadb-server --bin metadbd -- \ - --data-dir /tmp/metadb-data \ - --listen 127.0.0.1:7800 \ - --node-id 1 \ - --cell-id 1 \ - --role all-in-one +cat > /tmp/metadb-loopback.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +allow_unauthenticated = true +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-loopback.toml ``` -Mit einer Datei, siehe [Konfiguration](./configuration.md): +A usable secret is a different file. Replace the `[security]` block. Do not set `allow_unauthenticated` in that same file. Both together are rejected. A whitespace-only secret is rejected. ```bash -cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml +mkdir -p /tmp/metadb-data +cat > /tmp/metadb-auth.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +shared_secret = "replace-with-a-long-random-string" +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-auth.toml ``` +Pass that same secret to the client as `metadb-ctl --auth-token` or `METADB_AUTH_TOKEN`. + Logs verwenden den `EnvFilter` von `tracing-subscriber`. Der Standardfilter ist `info`. Überschreiben mit der üblichen Variable `RUST_LOG`, zum Beispiel `RUST_LOG=debug`. -An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty `security.shared_secret` does not start the process. Loopback is not an implicit exception. Development without credentials sets `allow_unauthenticated = true` and keeps every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that opt-in. A wildcard or other non-loopback address refuses to listen. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS, certificate, anonymous, or insecure key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Strg-C schreibt den Shard-Zustand und stoppt die OpenRaft-Gruppen (`cluster.shutdown()`). diff --git a/docs/de/configuration.md b/docs/de/configuration.md index 77dc135..299e35f 100644 --- a/docs/de/configuration.md +++ b/docs/de/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` und `ServerTomlConfig::from_toml_file` / `from_toml_str` lesen TOML (`crates/metadb-server/src/config.rs`). Jeder bekannte Abschnitt ist optional. Ausgelassene Felder nehmen die Vorgaben unten an. -On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. +A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## Vorgaben @@ -27,11 +27,10 @@ On current `main`, a key inside `[security]` other than `shared_secret` fails pa | `sharding.bootstrap_table_shards` | `true` | Ja. `true` erzeugt die Shards 1, 2 und 3. `false` erzeugt Shard 1 über `[0x01, 0x04)` | | `sharding.shard_split_threshold_bytes` | `4294967296` (4 GiB) | Ja. Die Split-Prüfung nutzt die ungefähre Shard-Größe | | `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | -| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on a literal loopback IP (`127.0.0.1` or `::1`) only. The hostname `localhost` is not accepted. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | Es gibt keine Tabelle `[raft]`. `ServerTomlConfig.raft_options` wird von serde übersprungen und bleibt bei `RaftNodeOptions::default()` (Heartbeat 150 ms, Wahl 450–900 ms, Snapshot-Log-Behalten 0, Segment 64 MiB). -That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. `to_lsm_config` setzt immer `auto_locality_compaction: true`. @@ -78,7 +77,7 @@ Dieser Prozess beendet TLS nicht. Es gibt keine Zertifikatskonfiguration, die na Wenn `shared_secret` nicht leer ist, verlangen `MetadataService`, `TransactionService`, `ControlPlaneService` und `RaftTransportService`, dass `authorization` genau `Bearer ` ist. `GET /metrics` auf `metrics_listen_addr` verlangt denselben `Authorization`-Header. Ein fehlender Header, ein leerer Bearer, ein Präfix oder ein längerer Token wird abgelehnt. Der Fehlerkörper der Metriken ist kein Prometheus-Text. Raft-Peers senden denselben Bearer. `metadb-ctl --auth-token` (Umgebungsvariable `METADB_AUTH_TOKEN`) und `metadbd --join` / `--cell-manager` senden ihn. `metadb-ctl cluster status` ruft `GetRoutes` auf und liegt unter demselben Interceptor. -An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty secret does not start the process. Loopback is not an implicit exception. Development without credentials requires `allow_unauthenticated = true` and every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard (`0.0.0.0`, `::`) or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## Was sich nicht konfigurieren lässt diff --git a/docs/fr/architecture.md b/docs/fr/architecture.md index f7ff636..3f591d1 100644 --- a/docs/fr/architecture.md +++ b/docs/fr/architecture.md @@ -88,7 +88,6 @@ Les versions MVCC vivent en mémoire pendant `storage.mvcc_retention_ms` (défau Chaque shard local est un groupe `openraft` 0.10. Le journal est un fichier segmenté CRC32C sous `.../shards//raft`. Options par défaut, qui ne sont **pas** chargées depuis le TOML (`raft_options` est `#[serde(skip)]`) : -That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. | Champ | Défaut | | :--- | :--- | diff --git a/docs/fr/build-and-run.md b/docs/fr/build-and-run.md index 6b321ba..275e039 100644 --- a/docs/fr/build-and-run.md +++ b/docs/fr/build-and-run.md @@ -44,27 +44,41 @@ Options de `metadbd` (`crates/metadb-server/src/bin/metadbd.rs`) : Tout rôle autre que `all-in-one` échoue avant la liaison de l'écouteur, avec `server role ... is not implemented; only all-in-one runs a process`. -Exemple, boucle locale seulement : +`metadbd` with no config file uses an empty `shared_secret` and `allow_unauthenticated = false`, so that process does not start. The file below is the explicit loopback development opt-in. It is not a credential. Bind only a literal loopback IP (`127.0.0.1`). The hostname `localhost` is not accepted for this flag. Do not use it on a non-loopback address. ```bash mkdir -p /tmp/metadb-data -cargo run -p metadb-server --bin metadbd -- \ - --data-dir /tmp/metadb-data \ - --listen 127.0.0.1:7800 \ - --node-id 1 \ - --cell-id 1 \ - --role all-in-one +cat > /tmp/metadb-loopback.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +allow_unauthenticated = true +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-loopback.toml ``` -Avec un fichier, voir [Configuration](./configuration.md) : +A usable secret is a different file. Replace the `[security]` block. Do not set `allow_unauthenticated` in that same file. Both together are rejected. A whitespace-only secret is rejected. ```bash -cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml +mkdir -p /tmp/metadb-data +cat > /tmp/metadb-auth.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +shared_secret = "replace-with-a-long-random-string" +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-auth.toml ``` +Pass that same secret to the client as `metadb-ctl --auth-token` or `METADB_AUTH_TOKEN`. + Les journaux utilisent l'`EnvFilter` de `tracing-subscriber`. Le filtre par défaut est `info`. On le remplace avec la variable standard `RUST_LOG`, par exemple `RUST_LOG=debug`. -An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty `security.shared_secret` does not start the process. Loopback is not an implicit exception. Development without credentials sets `allow_unauthenticated = true` and keeps every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that opt-in. A wildcard or other non-loopback address refuses to listen. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS, certificate, anonymous, or insecure key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C vide l'état des shards et arrête les groupes OpenRaft (`cluster.shutdown()`). diff --git a/docs/fr/configuration.md b/docs/fr/configuration.md index 6e90c0b..9682ac8 100644 --- a/docs/fr/configuration.md +++ b/docs/fr/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` et `ServerTomlConfig::from_toml_file` / `from_toml_str` lisent le TOML (`crates/metadb-server/src/config.rs`). Chaque section connue est facultative. Les champs omis prennent les valeurs par défaut ci-dessous. -On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. +A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## Valeurs par défaut @@ -27,11 +27,10 @@ On current `main`, a key inside `[security]` other than `shared_secret` fails pa | `sharding.bootstrap_table_shards` | `true` | Oui. `true` crée les shards 1, 2 et 3. `false` crée le shard 1 sur `[0x01, 0x04)` | | `sharding.shard_split_threshold_bytes` | `4294967296` (4 Gio) | Oui. Le contrôle de découpage utilise la taille approximative du shard | | `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | -| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on a literal loopback IP (`127.0.0.1` or `::1`) only. The hostname `localhost` is not accepted. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | Il n'y a pas de table `[raft]`. `ServerTomlConfig.raft_options` est ignoré par serde et reste à `RaftNodeOptions::default()` (battement 150 ms, élection 450–900 ms, conservation du journal d'instantané 0, segment 64 Mio). -That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. `to_lsm_config` fixe toujours `auto_locality_compaction: true`. @@ -78,7 +77,7 @@ Ce processus ne termine pas TLS. Aucune configuration de certificat n'active un Lorsque `shared_secret` n'est pas vide, `MetadataService`, `TransactionService`, `ControlPlaneService` et `RaftTransportService` exigent que `authorization` soit exactement `Bearer `. `GET /metrics` sur `metrics_listen_addr` exige le même en-tête `Authorization`. Un en-tête absent, un bearer vide, un préfixe ou un jeton plus long est rejeté. Le corps d'échec des métriques n'est pas du texte Prometheus. Les pairs Raft envoient le même bearer. `metadb-ctl --auth-token` (variable d'environnement `METADB_AUTH_TOKEN`) et `metadbd --join` / `--cell-manager` l'envoient. `metadb-ctl cluster status` appelle `GetRoutes` et passe par le même intercepteur. -An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty secret does not start the process. Loopback is not an implicit exception. Development without credentials requires `allow_unauthenticated = true` and every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard (`0.0.0.0`, `::`) or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## Ce que l'on ne peut pas configurer diff --git a/docs/guides/de/deployment.md b/docs/guides/de/deployment.md index c0f5ab4..e6bc3aa 100644 --- a/docs/guides/de/deployment.md +++ b/docs/guides/de/deployment.md @@ -34,14 +34,27 @@ locality_tombstone_ratio = 0.50 [sharding] bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 GiB + +[security] +# Loopback development only. Literal 127.0.0.1. Remove this flag when you set shared_secret. +allow_unauthenticated = true ``` -Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. + +The `[security]` block above is the explicit loopback development opt-in. It is not a credential. `grpc_listen_addr` and `metrics_listen_addr` stay on the literal IP `127.0.0.1`. The hostname `localhost` is not accepted for `allow_unauthenticated`. An empty secret without that flag does not start the process. ```bash metadbd --config /etc/metadb/standalone.toml ``` +To require `authorization: Bearer ` on metadata, transaction, control-plane, Raft transport, and `GET /metrics`, replace that `[security]` block. Do not leave `allow_unauthenticated` in the file. Both together are rejected. A whitespace-only `shared_secret` is rejected even if the flag remains. Peer Raft clients send the same token. `metadb-ctl --auth-token` (or `METADB_AUTH_TOKEN`) and `metadbd --join` / `--cell-manager` send that header. + +```toml +[security] +shared_secret = "replace-with-a-long-random-string" +``` + --- ## Stufe 2: Dynamisches Shard-Splitting an `PID`-Grenzen `[Implementiert]` diff --git a/docs/guides/fr/deployment.md b/docs/guides/fr/deployment.md index 49eb0ef..e2b79dd 100644 --- a/docs/guides/fr/deployment.md +++ b/docs/guides/fr/deployment.md @@ -34,14 +34,27 @@ locality_tombstone_ratio = 0.50 [sharding] bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 Gio + +[security] +# Loopback development only. Literal 127.0.0.1. Remove this flag when you set shared_secret. +allow_unauthenticated = true ``` -Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. + +The `[security]` block above is the explicit loopback development opt-in. It is not a credential. `grpc_listen_addr` and `metrics_listen_addr` stay on the literal IP `127.0.0.1`. The hostname `localhost` is not accepted for `allow_unauthenticated`. An empty secret without that flag does not start the process. ```bash metadbd --config /etc/metadb/standalone.toml ``` +To require `authorization: Bearer ` on metadata, transaction, control-plane, Raft transport, and `GET /metrics`, replace that `[security]` block. Do not leave `allow_unauthenticated` in the file. Both together are rejected. A whitespace-only secret is rejected even if the flag remains. Peer Raft clients send the same token. `metadb-ctl --auth-token` (or `METADB_AUTH_TOKEN`) and `metadbd --join` / `--cell-manager` send that header. + +```toml +[security] +shared_secret = "replace-with-a-long-random-string" +``` + --- ## Étape 2 : Découpage Dynamique sur Frontière `PID` `[Implémenté]` diff --git a/docs/guides/ja/deployment.md b/docs/guides/ja/deployment.md index 8f03713..4142e4c 100644 --- a/docs/guides/ja/deployment.md +++ b/docs/guides/ja/deployment.md @@ -34,14 +34,27 @@ locality_tombstone_ratio = 0.50 [sharding] bootstrap_table_shards = true shard_split_threshold_bytes = 4294967296 # 4 GiB + +[security] +# Loopback development only. Literal 127.0.0.1. Remove this flag when you set shared_secret. +allow_unauthenticated = true ``` -Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. +Rust 1.100.0 (`rust-toolchain.toml`). Only `all-in-one` starts. This process does not terminate TLS. + +The `[security]` block above is the explicit loopback development opt-in. It is not a credential. `grpc_listen_addr` and `metrics_listen_addr` stay on the literal IP `127.0.0.1`. The hostname `localhost` is not accepted for `allow_unauthenticated`. An empty secret without that flag does not start the process. ```bash metadbd --config /etc/metadb/standalone.toml ``` +To require `authorization: Bearer ` on metadata, transaction, control-plane, Raft transport, and `GET /metrics`, replace that `[security]` block. Do not leave `allow_unauthenticated` in the file. Both together are rejected. A whitespace-only `shared_secret` is rejected even if the flag remains. Peer Raft clients send the same token. `metadb-ctl --auth-token` (or `METADB_AUTH_TOKEN`) and `metadbd --join` / `--cell-manager` send that header. + +```toml +[security] +shared_secret = "replace-with-a-long-random-string" +``` + --- ## Stage 2:単一ホスト上の自動 `PID` 境界シャード分割 `[実装済]` diff --git a/docs/guides/zh/deployment.md b/docs/guides/zh/deployment.md index 72c7cc9..ff1b92c 100644 --- a/docs/guides/zh/deployment.md +++ b/docs/guides/zh/deployment.md @@ -38,18 +38,29 @@ locality_tombstone_ratio = 0.50 [sharding] bootstrap_table_shards = true # 初始化表前缀根分片:1(Meta)、2(Quota)、3(SecondaryIndex) shard_split_threshold_bytes = 4294967296 # 4 GiB 分片分裂阈值 + +[security] +# Loopback development only. Literal 127.0.0.1. Remove this flag when you set shared_secret. +allow_unauthenticated = true ``` ### 启动单机服务 工具链固定为 Rust **1.100.0**(`rust-toolchain.toml`)。当前只有 `all-in-one` 会真正启动;`be` / `proxy` / `cell-manager` / `global-manager` 会被拒绝,而不是静默变成全功能进程。 -Metadata, transaction, control-plane, and Raft gRPC, and the metrics listener, do not terminate TLS. An empty `[security].shared_secret` does not start the process, including on the default `127.0.0.1:7800` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with `allow_unauthenticated` is rejected. A non-empty secret requires `authorization: Bearer ` for metadata, transactions, the control plane, Raft on the same port, and `GET /metrics`. Peer Raft clients send the same token. A TLS or certificate key in the file is rejected rather than served as plaintext. +The `[security]` block above is the explicit loopback development opt-in. It is not a credential. `grpc_listen_addr` and `metrics_listen_addr` stay on the literal IP `127.0.0.1`. The hostname `localhost` is not accepted for `allow_unauthenticated`. An empty secret without that flag does not start the process. ```bash metadbd --config /etc/metadb/standalone.toml ``` +To require `authorization: Bearer ` on metadata, transaction, control-plane, Raft transport, and `GET /metrics`, replace that `[security]` block. Do not leave `allow_unauthenticated` in the file. Both together are rejected. A whitespace-only `shared_secret` is rejected even if the flag remains. Peer Raft clients send the same token. `metadb-ctl --auth-token` (or `METADB_AUTH_TOKEN`) and `metadbd --join` / `--cell-manager` send that header. + +```toml +[security] +shared_secret = "replace-with-a-long-random-string" +``` + --- ## 阶段二:单节点动态 `PID` 边界分片分裂 `[已实现]` diff --git a/docs/ja/architecture.md b/docs/ja/architecture.md index 481e6f5..31bf409 100644 --- a/docs/ja/architecture.md +++ b/docs/ja/architecture.md @@ -88,7 +88,6 @@ MVCC の版は `storage.mvcc_retention_ms`(既定 5,000)のあいだメモ ローカルの各シャードは `openraft` 0.10 のグループです。ログは `.../shards//raft` 以下の分割された CRC32C ファイルです。既定値は TOML から **読み込まれません**(`raft_options` は `#[serde(skip)]`): -That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. | 項目 | 既定 | | :--- | :--- | diff --git a/docs/ja/build-and-run.md b/docs/ja/build-and-run.md index c165ca5..e955197 100644 --- a/docs/ja/build-and-run.md +++ b/docs/ja/build-and-run.md @@ -44,27 +44,41 @@ cargo build --release -p metadb-server --bins `all-in-one` 以外のロールはリスナーをバインドする前に失敗し、`server role ... is not implemented; only all-in-one runs a process` を返します。 -例(ループバックのみ): +`metadbd` with no config file uses an empty `shared_secret` and `allow_unauthenticated = false`, so that process does not start. The file below is the explicit loopback development opt-in. It is not a credential. Bind only a literal loopback IP (`127.0.0.1`). The hostname `localhost` is not accepted for this flag. Do not use it on a non-loopback address. ```bash mkdir -p /tmp/metadb-data -cargo run -p metadb-server --bin metadbd -- \ - --data-dir /tmp/metadb-data \ - --listen 127.0.0.1:7800 \ - --node-id 1 \ - --cell-id 1 \ - --role all-in-one +cat > /tmp/metadb-loopback.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +allow_unauthenticated = true +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-loopback.toml ``` -ファイルを使う場合は [設定](./configuration.md) を参照します。 +A usable secret is a different file. Replace the `[security]` block. Do not set `allow_unauthenticated` in that same file. Both together are rejected. A whitespace-only secret is rejected. ```bash -cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml +mkdir -p /tmp/metadb-data +cat > /tmp/metadb-auth.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +shared_secret = "replace-with-a-long-random-string" +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-auth.toml ``` +Pass that same secret to the client as `metadb-ctl --auth-token` or `METADB_AUTH_TOKEN`. + ログは `tracing-subscriber` の `EnvFilter` を使います。既定のフィルタは `info` です。標準の環境変数 `RUST_LOG` で上書きします。例: `RUST_LOG=debug`。 -An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty `security.shared_secret` does not start the process. Loopback is not an implicit exception. Development without credentials sets `allow_unauthenticated = true` and keeps every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that opt-in. A wildcard or other non-loopback address refuses to listen. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS, certificate, anonymous, or insecure key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C はシャード状態をフラッシュし、OpenRaft グループを止めます(`cluster.shutdown()`)。 diff --git a/docs/ja/configuration.md b/docs/ja/configuration.md index 0b826b9..6f93696 100644 --- a/docs/ja/configuration.md +++ b/docs/ja/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` と `ServerTomlConfig::from_toml_file` / `from_toml_str` は TOML を読みます(`crates/metadb-server/src/config.rs`)。既知のセクションは省略できます。省略した項目は次の既定値になります。 -On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. +A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## 既定値 @@ -27,11 +27,10 @@ On current `main`, a key inside `[security]` other than `shared_secret` fails pa | `sharding.bootstrap_table_shards` | `true` | する。`true` はシャード 1、2、3 を作る。`false` は `[0x01, 0x04)` を覆うシャード 1 を作る | | `sharding.shard_split_threshold_bytes` | `4294967296`(4 GiB) | する。分割判定はシャードの概算サイズを使う | | `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | -| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on a literal loopback IP (`127.0.0.1` or `::1`) only. The hostname `localhost` is not accepted. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | `[raft]` テーブルはありません。`ServerTomlConfig.raft_options` は serde がスキップし、`RaftNodeOptions::default()` のままです(ハートビート 150 ms、選挙 450–900 ms、スナップショットログ保持 0、セグメント 64 MiB)。 -That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. `to_lsm_config` は常に `auto_locality_compaction: true` を設定します。 @@ -78,7 +77,7 @@ CLI フラグはファイルを解析したあとで上書きします。`--node `shared_secret` が空でないとき、`MetadataService`、`TransactionService`、`ControlPlaneService`、`RaftTransportService` は `authorization` が `Bearer ` と完全に一致することを要求します。`metrics_listen_addr` の `GET /metrics` も同じ `Authorization` ヘッダを要求します。ヘッダの欠落、空のベアラ、接頭辞、より長いトークンは拒否されます。失敗したメトリクス応答の本体は Prometheus テキストではありません。Raft ピアは同じベアラを送ります。`metadb-ctl --auth-token`(環境変数 `METADB_AUTH_TOKEN`)と `metadbd --join` / `--cell-manager` も送ります。`metadb-ctl cluster status` は `GetRoutes` を呼び、同じインターセプタの対象です。 -An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty secret does not start the process. Loopback is not an implicit exception. Development without credentials requires `allow_unauthenticated = true` and every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard (`0.0.0.0`, `::`) or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## 設定できないもの diff --git a/docs/zh/architecture.md b/docs/zh/architecture.md index 01ebc99..eb344ab 100644 --- a/docs/zh/architecture.md +++ b/docs/zh/architecture.md @@ -88,7 +88,6 @@ MVCC 版本在内存中保留 `storage.mvcc_retention_ms`(默认 5,000)。 每个本地分片是一个 `openraft` 0.10 组。日志是 `.../shards//raft` 下的分段 CRC32C 文件。下列默认值 **不** 从 TOML 加载(`raft_options` 为 `#[serde(skip)]`): -That skip is current `main`. Unmerged pull request #38 proposes loading `[raft]`. If it merges, this paragraph has to be rewritten. Loading `[raft]` is not current behavior. | 字段 | 默认 | | :--- | :--- | diff --git a/docs/zh/build-and-run.md b/docs/zh/build-and-run.md index 1e72fa7..49a993c 100644 --- a/docs/zh/build-and-run.md +++ b/docs/zh/build-and-run.md @@ -44,27 +44,41 @@ cargo build --release -p metadb-server --bins 除 `all-in-one` 以外的角色在绑定监听器之前失败,错误为 `server role ... is not implemented; only all-in-one runs a process`。 -示例,仅本机回环: +`metadbd` with no config file uses an empty `shared_secret` and `allow_unauthenticated = false`, so that process does not start. The file below is the explicit loopback development opt-in. It is not a credential. Bind only a literal loopback IP (`127.0.0.1`). The hostname `localhost` is not accepted for this flag. Do not use it on a non-loopback address. ```bash mkdir -p /tmp/metadb-data -cargo run -p metadb-server --bin metadbd -- \ - --data-dir /tmp/metadb-data \ - --listen 127.0.0.1:7800 \ - --node-id 1 \ - --cell-id 1 \ - --role all-in-one +cat > /tmp/metadb-loopback.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +allow_unauthenticated = true +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-loopback.toml ``` -使用文件时见 [配置](./configuration.md): +A usable secret is a different file. Replace the `[security]` block. Do not set `allow_unauthenticated` in that same file. Both together are rejected. A whitespace-only secret is rejected. ```bash -cargo run -p metadb-server --bin metadbd -- --config ./standalone.toml +mkdir -p /tmp/metadb-data +cat > /tmp/metadb-auth.toml <<'EOF' +[node] +data_dir = "/tmp/metadb-data" +grpc_listen_addr = "127.0.0.1:7800" + +[security] +shared_secret = "replace-with-a-long-random-string" +EOF +cargo run -p metadb-server --bin metadbd -- --config /tmp/metadb-auth.toml ``` +Pass that same secret to the client as `metadb-ctl --auth-token` or `METADB_AUTH_TOKEN`. + 日志使用 `tracing-subscriber` 的 `EnvFilter`。默认过滤器是 `info`。用标准环境变量 `RUST_LOG` 覆盖,例如 `RUST_LOG=debug`。 -An empty `security.shared_secret` does not start the process, including on the default `127.0.0.1` bind. Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A misspelled secret still fails startup. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS or certificate key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty `security.shared_secret` does not start the process. Loopback is not an implicit exception. Development without credentials sets `allow_unauthenticated = true` and keeps every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that opt-in. A wildcard or other non-loopback address refuses to listen. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. A non-empty `[security].shared_secret` requires the same bearer for metadata, transaction, control-plane, and Raft transport RPCs, and for `GET /metrics`. The process does not terminate TLS. A TLS, certificate, anonymous, or insecure key in the configuration fails startup instead of serving plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. Ctrl-C 会刷出分片状态并停止 OpenRaft 组(`cluster.shutdown()`)。 diff --git a/docs/zh/configuration.md b/docs/zh/configuration.md index 6764784..95f22a7 100644 --- a/docs/zh/configuration.md +++ b/docs/zh/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` 以及 `ServerTomlConfig::from_toml_file` / `from_toml_str` 读取 TOML(`crates/metadb-server/src/config.rs`)。每个已知节都可以省略。省略的字段取下面的默认值。 -On current `main`, a key inside `[security]` other than `shared_secret` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and secret-like keys (`secret`, `password`, `token`, `credential`, `auth`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. Unmerged pull request #35 also rejects `anonymous` and `insecure` anywhere and accepts `[security].allow_unauthenticated` beside `shared_secret`. The empty-secret rules later in this file describe #35, not current `main`. Until #35 merges, `main` still accepts an empty secret on loopback and does not implement `allow_unauthenticated`. +A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## 默认值 @@ -27,11 +27,10 @@ On current `main`, a key inside `[security]` other than `shared_secret` fails pa | `sharding.bootstrap_table_shards` | `true` | 是。`true` 创建分片 1、2、3。`false` 创建覆盖 `[0x01, 0x04)` 的分片 1 | | `sharding.shard_split_threshold_bytes` | `4294967296`(4 GiB) | 是。分裂检查使用分片的近似大小 | | `security.shared_secret` | `""` | Empty does not start the process. Loopback without credentials requires `allow_unauthenticated = true`. A non-empty secret requires the same bearer on gRPC and metrics. A whitespace-only secret is rejected | -| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on loopback only. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | +| `security.allow_unauthenticated` | `false` | Explicit opt-in for an empty secret on a literal loopback IP (`127.0.0.1` or `::1`) only. The hostname `localhost` is not accepted. Rejected together with a usable secret. Rejected on a wildcard or any other non-loopback bind. A whitespace-only secret is rejected even with this flag | 没有 `[raft]` 表。`ServerTomlConfig.raft_options` 被 serde 跳过,保持 `RaftNodeOptions::default()`(心跳 150 ms,选举 450–900 ms,快照日志保留 0,段大小 64 MiB)。 -That skip is current `main`. Unmerged pull request #38 proposes loading a `[raft]` table. If #38 merges, this sentence has to be rewritten. Loading `[raft]` is not current behavior. `to_lsm_config` 总是把 `auto_locality_compaction` 设为 `true`。 @@ -78,7 +77,7 @@ shared_secret = "replace-with-a-long-random-string" `shared_secret` 非空时,`MetadataService`、`TransactionService`、`ControlPlaneService` 和 `RaftTransportService` 要求 `authorization` 精确等于 `Bearer `。`metrics_listen_addr` 上的 `GET /metrics` 要求同一个 `Authorization` 头。缺失的头、空令牌、前缀或更长的令牌都会被拒绝。指标失败响应的正文不是 Prometheus 文本。Raft 对等体发送同一个令牌。`metadb-ctl --auth-token`(环境变量 `METADB_AUTH_TOKEN`)以及 `metadbd --join` / `--cell-manager` 也会发送它。`metadb-ctl cluster status` 调用 `GetRoutes`,走同一个拦截器。 -An empty secret does not start the process, including when every listener is loopback (`127.0.0.0/8`, `::1`, or the name `localhost`). Loopback development without credentials requires `allow_unauthenticated = true`. That flag still refuses a wildcard (`0.0.0.0`, `::`) or any other non-loopback address. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. +An empty secret does not start the process. Loopback is not an implicit exception. Development without credentials requires `allow_unauthenticated = true` and every listener on a literal loopback IP (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard (`0.0.0.0`, `::`) or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. Listeners stay plaintext. Keep an opted-in listener on a trusted network, or put every service behind a proxy that authenticates the client and block direct access to this process. ## 不能配置的内容 From 5520bb3adf511ac3c9e8d29b32ce28e79fd98a77 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 19 Nov 2026 19:50:19 +0000 Subject: [PATCH 5/5] List the full security-key classifier in locale configuration The four opening summaries named only a short set of keys and then said every other unknown key is ignored. Match the substring rule: api_key, bearer, jwt, private_key, encryption, https, ca_file, and a secur prefix are rejected too. Co-authored-by: RustFS --- docs/de/configuration.md | 2 +- docs/fr/configuration.md | 2 +- docs/ja/configuration.md | 2 +- docs/zh/configuration.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/de/configuration.md b/docs/de/configuration.md index 299e35f..a3806ff 100644 --- a/docs/de/configuration.md +++ b/docs/de/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` und `ServerTomlConfig::from_toml_file` / `from_toml_str` lesen TOML (`crates/metadb-server/src/config.rs`). Jeder bekannte Abschnitt ist optional. Ausgelassene Felder nehmen die Vorgaben unten an. -A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. +A key fails parsing when its normalized form (lowercase, hyphens become underscores) contains one of these substrings, including inside nested tables and arrays: `secret`, `password`, `passwd`, `token`, `credential`, `auth`, `anonymous`, `anon`, `insecure`, `api_key`, `apikey`, `bearer`, `jwt`, `private_key`, `privatekey`, `encryption`, `encrypt`, `tls`, `ssl`, `cert`, `x509`, `mtls`, `cipher`, `keystore`, `https`, `ca_file`, `cafile`, or the normalized key starts with `secur`. The only exceptions are the direct keys `[security].shared_secret` and `[security].allow_unauthenticated`. Any other key directly under `[security]` also fails parsing. This is the classifier, not a sample list: a key is not ignored merely because its name is absent from a shorter summary. Keys that do not match this classifier are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## Vorgaben diff --git a/docs/fr/configuration.md b/docs/fr/configuration.md index 9682ac8..7764ac9 100644 --- a/docs/fr/configuration.md +++ b/docs/fr/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` et `ServerTomlConfig::from_toml_file` / `from_toml_str` lisent le TOML (`crates/metadb-server/src/config.rs`). Chaque section connue est facultative. Les champs omis prennent les valeurs par défaut ci-dessous. -A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. +A key fails parsing when its normalized form (lowercase, hyphens become underscores) contains one of these substrings, including inside nested tables and arrays: `secret`, `password`, `passwd`, `token`, `credential`, `auth`, `anonymous`, `anon`, `insecure`, `api_key`, `apikey`, `bearer`, `jwt`, `private_key`, `privatekey`, `encryption`, `encrypt`, `tls`, `ssl`, `cert`, `x509`, `mtls`, `cipher`, `keystore`, `https`, `ca_file`, `cafile`, or the normalized key starts with `secur`. The only exceptions are the direct keys `[security].shared_secret` and `[security].allow_unauthenticated`. Any other key directly under `[security]` also fails parsing. This is the classifier, not a sample list: a key is not ignored merely because its name is absent from a shorter summary. Keys that do not match this classifier are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## Valeurs par défaut diff --git a/docs/ja/configuration.md b/docs/ja/configuration.md index 6f93696..0881486 100644 --- a/docs/ja/configuration.md +++ b/docs/ja/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` と `ServerTomlConfig::from_toml_file` / `from_toml_str` は TOML を読みます(`crates/metadb-server/src/config.rs`)。既知のセクションは省略できます。省略した項目は次の既定値になります。 -A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. +A key fails parsing when its normalized form (lowercase, hyphens become underscores) contains one of these substrings, including inside nested tables and arrays: `secret`, `password`, `passwd`, `token`, `credential`, `auth`, `anonymous`, `anon`, `insecure`, `api_key`, `apikey`, `bearer`, `jwt`, `private_key`, `privatekey`, `encryption`, `encrypt`, `tls`, `ssl`, `cert`, `x509`, `mtls`, `cipher`, `keystore`, `https`, `ca_file`, `cafile`, or the normalized key starts with `secur`. The only exceptions are the direct keys `[security].shared_secret` and `[security].allow_unauthenticated`. Any other key directly under `[security]` also fails parsing. This is the classifier, not a sample list: a key is not ignored merely because its name is absent from a shorter summary. Keys that do not match this classifier are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## 既定値 diff --git a/docs/zh/configuration.md b/docs/zh/configuration.md index 95f22a7..93e5f7c 100644 --- a/docs/zh/configuration.md +++ b/docs/zh/configuration.md @@ -4,7 +4,7 @@ `metadbd --config` 以及 `ServerTomlConfig::from_toml_file` / `from_toml_str` 读取 TOML(`crates/metadb-server/src/config.rs`)。每个已知节都可以省略。省略的字段取下面的默认值。 -A key inside `[security]` other than `shared_secret` and `allow_unauthenticated` fails parsing. TLS-like keys (`tls`, `ssl`, `cert`) and keys named like a secret or an authentication switch (`secret`, `password`, `token`, `credential`, `auth`, `anonymous`, `insecure`) fail anywhere, including nested tables. Unknown keys that do not match those names are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. +A key fails parsing when its normalized form (lowercase, hyphens become underscores) contains one of these substrings, including inside nested tables and arrays: `secret`, `password`, `passwd`, `token`, `credential`, `auth`, `anonymous`, `anon`, `insecure`, `api_key`, `apikey`, `bearer`, `jwt`, `private_key`, `privatekey`, `encryption`, `encrypt`, `tls`, `ssl`, `cert`, `x509`, `mtls`, `cipher`, `keystore`, `https`, `ca_file`, `cafile`, or the normalized key starts with `secur`. The only exceptions are the direct keys `[security].shared_secret` and `[security].allow_unauthenticated`. Any other key directly under `[security]` also fails parsing. This is the classifier, not a sample list: a key is not ignored merely because its name is absent from a shorter summary. Keys that do not match this classifier are still ignored. An empty `shared_secret` does not start the process. Development without credentials requires `allow_unauthenticated = true` and a literal loopback bind (`127.0.0.1` or `::1`). The hostname `localhost` is not accepted for that flag. A wildcard or any other non-loopback address cannot use it. A whitespace-only secret is rejected even with the flag. A usable secret combined with the flag is rejected. ## 默认值