概要 · English · Français · Deutsch · 简体中文
bootstrap_table_shards = true でブートストラップしたあと:
<data_dir>/
global_allocator/ID_ALLOCATOR_STATE
cell_<cell_id>/CELL_MANAGER_STATE
be/NODE_SHARD_REGISTRY
be/shards/00000000000000000001/lsm/ # MetaTable
be/shards/00000000000000000001/raft/
be/shards/00000000000000000002/... # QuotaTable
be/shards/00000000000000000003/... # SecondaryIndexTable
シャード ID は 10 進で、20 桁になるまでゼロ埋めされます。分割で作られた子シャードは be/shards/ の下の追加ディレクトリです。CELL_MANAGER_STATE と ID_ALLOCATOR_STATE は CRC32C フレームです。シャードディレクトリが残っているあいだ NODE_SHARD_REGISTRY を消さないでください。ホストは分割の子を回復するためにこれを使います。
ディレクトリをコピーする前に、Ctrl-C(または PersistentMetaDbCluster::shutdown)でプロセスを止めてください。生きているプロセスはシャードごとに LSM の LOCK ファイルを保持します。
グローバルフラグ:
| フラグ | 既定 | 意味 |
|---|---|---|
--endpoint |
127.0.0.1:7800 |
ホスト:ポート、またはすでに http:// か https:// で始まる URL |
--auth-token |
空 | ベアラトークン。METADB_AUTH_TOKEN からも読む |
クライアントはコマンドごとに新しい gRPC チャネルを開きます。RaftTransportService は話しません。
cell_id = 0 で GetRoutes を呼びます。各シャードについて shard、cell、leader、投票者数、epoch=(conf_ver, ver)、dual_mode、jumbo を印字します。It then prints local CELL_CONTROL_PLANE placement rows (phase, phase_code, dedicated_node, dominant_pid, moves, attempt timestamps, reason) and placement_automatic_transfer_enabled=false. Those rows are not routes. A remote cell contributes no placement rows. It does not print disk free space, QPS, Raft watermarks, or MOVE_STAGED / MOVE_LIVE. The reconciler does not publish phase recorded. It does not stamp transfer_attempt_unix_ms. A new row stores 0. A later reconcile keeps a non-zero value already in the file.
そのセルの GetRoutes を呼びます(キャッシュされたすべてのルートには 0)。shard、cell、生の開始キーと終了キー、エポック (conf_ver, version) を印字し、その後に同じローカル placement 行を印字します。A remote cell prints Placements: 0.
TriggerShardSplit を呼び、シャードが shard_split_threshold_bytes 未満でも分割検査を強制します。On success it prints split_executed, child_shard_id, and the placement fields. When no placement row exists, including an ordinary split, the line is placement_phase= and placement_phase_code=0. Code 0 is only that no-record case. Stored rows use codes 1–4. split_executed=false は子シャードを作らなかったことを意味します(キーが 2 つ未満、またはジャンボ候補が placement 行を書いても split_executed=false のまま)。
EnableDualModeSplit を呼びます。CLI は空の split_name を送ります。サーバは dual_mode_pid を保存し、すぐには分割しません。
ScaleShardReplicas を呼びます。サーバは、そのセルのノード表にすでに target_voters 件あることを要求します。新しい all-in-one セルのノードは 1 つなので、--target-voters 3 は need 3 registered nodes in cell <id>, have 1 の形の合意エラーを返します。成功時は、メンバー変更へ渡したローカルシャードの数を印字します。
RegisterCell を呼びます。エンドポイントのルートが要求範囲をちょうど覆うときだけ、サーバは GLOBAL_CELL_DIRECTORY を fsync します。キーを省略すると [01, 04) を送り、これは既定セルと重なるため metadb-ctl は非ゼロで終了します。そのセルに含まれる後続の要求は、保存されたエンドポイントへ転送されます。
バインドパラメータなしで ExecuteSql を呼びます。文は アーキテクチャ の 20 テンプレートの 1 つで、? の代わりにリテラルを使います。
metadb-ctl --endpoint 127.0.0.1:7800 sql \
"SELECT * FROM MetaTable WHERE pid = 1 AND name = '_attr_'"See Tests and benches. Remote hotspot-create and bulk-ttl-delete are a client against a running server. They print JSON with attempted, succeeded, and failed, and the process exits non-zero unless succeeded equals --ops. --embedded and --workload mixed run the in-process stress harness instead of dialing the endpoint. That path passes when errors and correctness_errors are both zero, and it prints latency percentiles in microseconds. Neither path is a Cargo benchmark target. The repository does not check in a throughput number for either path. A printed line is not a service-level result and is not the official 1,000,000-create profile.
The separate prefix-load harness (100 prefixes × 10,000 creates, then 100,000 SetAttr overwrites, then 100,000 deletes, concurrency 64) is documented in Tests and benches. GitHub Actions runs only the small profile. It does not run the 1,000,000-create profile.
node.metrics_listen_addr を設定します(例: 127.0.0.1:9100)。open_and_serve がそのアドレスで TCP 接続を受けます。GET /metrics は Prometheus テキストを返します。他のパスは 404、他のメソッドは 405 です。[security].shared_secret が空でないとき、このリスナーのすべての要求は Authorization: Bearer <shared_secret> を送らなければなりません。欠落、空、または誤ったベアラは 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. When [security.tls].mode is off, listeners are plaintext. tls and mtls are refused before listen. This process does not terminate TLS. See docs/designs/transport_security.md.
render_prometheus_metrics のゲージとカウンタ:
| 名前 | 種類 |
|---|---|
metadb_cells_total |
gauge |
metadb_shards_total |
gauge |
metadb_in_memory_mvcc_writes_total |
counter |
metadb_pruned_mvcc_versions_total |
counter |
metadb_persistent_kv_writes_total |
counter |
metadb_active_physical_tombstones |
gauge |
metadb_tombstones_traversed_on_scans_total |
counter |
metadb_locality_compactions_total |
counter |
metadb_min_raft_safe_purge_index |
gauge |
metadb_placement_records |
gauge, local placement rows |
metadb_placement_phase_recorded |
gauge; the reconciler does not publish this phase |
metadb_placement_phase_leader_on_dedicated |
gauge |
metadb_placement_phase_dedicated_not_shared |
gauge |
metadb_placement_phase_blocked |
gauge |
metadb_placement_moves_leadership |
gauge |
metadb_placement_moves_voter_replaced |
gauge |
metadb_placement_rows_with_transfer_attempt |
gauge; the reconciler does not stamp a new value and keeps one already in the file |
metadb_placement_rows_with_replace_attempt |
gauge |
metadb_placement_automatic_transfer_enabled |
gauge, 0 in this build |
There is no metadb_raft_watermark_lag_entries series and no per-shard placement label. There is no MOVE_STAGED or MOVE_LIVE series. metadb_cells_total counts rows in this process's GLOBAL_CELL_DIRECTORY, including a remote cell after RegisterCell. metadb_shards_total counts only local shards. A fresh process has one cell. The English operability page lists the readiness gauges that this table does not repeat.
1 プロセスの中で動くもの:
- シャードを増やす。
shard_split_threshold_bytesを超える成長、またはmetadb-ctl shard splitは、同じbe/shardsディレクトリの下にシャードグループを追加できます。親は左側のキー範囲を保持し、子はこのノード上の別の 1 投票者グループとして起動します。再起動は両方を開き直します。 - デュアルモードフラグ。
shard enable-dual-modeは 1 つの親 ID を印します。そのシャードの後の分割は(pid, name)で切ることがあります。 - ジャンボフラグ。1 つの親がシャード上の
MetaTableバイトの 85% を超えるとき、またはシャードの親が 1 つのとき、ルートはJumboIsolatedになります。専用ノード ID は、このセルにすでに登録されたノードから選ばれます。ノードが 1 つのとき、フラグはこのプロセスを指します。フラグ自体はファイルを別ホストへ移しません。ループバックのMOVE_STAGED/MOVE_LIVEは127.0.0.1のリスナーへディレクトリを置けます。metadbdはそのリスナーを起動せず、Raft を開かず、transfer_leaderを呼ばず、本番のホスト間コピーではありません。docs/en/scale-control-plane-status.mdを参照。 - プロセス内の投票者。
DurableCellManager::scale_out_replicasは、それらのノード ID が登録されており、かつ 各アドレスがそのシャードのグループに対してすでにRaftTransportServiceを提供しているときに、learner を追加して昇格できます。crates/metadb-raft/tests/multi_raft_failover_tests.rsは、1 つのテストプロセス内の 3 つのリスナーと基本的な KV ステートマシンでこれを行います。メタデータのステートマシンではなく、metadbdを 3 プロセス起動するのでもありません。
これらのプロセスが行うこと:
metadbd --role beはローカルの Raft レプリカを持ち、そのメタデータを提供します。セルを公開せず、ID ブロックもリネームリースも発行しません。2 つ目のbeは[cluster] joinで最初のプロセスに参加できます。metadbd --role proxyは[cluster] upstreamを必要とし、Raft グループを開きません。メタデータ呼び出し、ExecuteSql、またはユーザキーを持つトランザクションは、それを含む登録済みセルへx-metadb-cell-forwarded付きで接続されます。ディレクトリが無い、一つのセルに含まれない、キーが二つのセルに分かれる、または範囲がセルに重なるだけで含まれない場合は、配置エラーを返し、upstream には送りません。CommitPrimary2pc、ApplyAuxBatch、ForwardRouter、GetRoutesはその upstream を使うことがあります。AllocateIdBlockは拒否されます。--role global-managerはGLOBAL_CELL_DIRECTORYを提供し、shared_id_allocator/SHARED_ID_ALLOCATORを開いて、そのファイルからAllocateIdBlockを付与します。登録済みセルに含まれる要求もそのセルへ転送します。シャードグループを開かないため、このプロセスのディレクトリファイルは Raft ログへコピーされず、それ自体も Raft グループではありません。--role cell-managerはローカルセルを一つ持ち、公開できます。ディレクトリファイルは引き続き独自の Raft グループではありません。ブートストラップのリーダーは、ディレクトリとCELL_MANAGER_STATEのスナップショットを、最も番号の小さいローカルシャードの既存 Raft ログへコピーします。- 2 つ目の
metadbd --role all-in-oneは、データディレクトリが空で--joinまたは--cell-managerが現在のリーダーを指すとき、既存の Raft グループに参加します。リーダーは空エントリを追記してスナップショットを取り、参加者を learner から voter へ昇格します。--joinはそのリーダーに届く必要があります。すでに Raft 状態があるディレクトリはそれを開き直し、新しい join アドレスを無視します。ノード ID 2 から 32767 の新しいアロケータは、そのノード自身の inode、file id、shard id 名前空間から始まるため、ノード 1 が既に発行した ID を再発行しません。既に低い ID を発行したアロケータファイルは移し替えません。リーダーが分かっている follower へのLookup、ディレクトリ一覧、ディレクトリ統計、GetDirPartitionStat、クォータ読み取り、セカンダリインデックス読み取りは、そのリーダーへ転送します。リーダーが不明な follower は引き続きNotLeaderを返します。メンバーシップが joint の間、GetRoutesは適用済みの全投票者、現在のリーダー、適用済み epoch を報告します。均一構成がコミットされた後、それらの投票者とconf_verは Raft と一致します。参加は一時的なエラーを 45 秒間再試行し、その後リスナーとローカル Raft グループを止めてエラーを返します。metadbdが終わるのは、起動がそのエラーを返したためです。最初の失敗だけではプロセスを中断しません。 metadb-ctl cell registerは、そのセルのルートが要求範囲を覆ったあとでのみ第二のセルを記録します。その後、そのセルに含まれる要求は転送されます。open_and_serveは設定が妥当ならall-in-one、be、proxy、cell-manager、global-managerを起動します。- テスト
T1–T6が使うメモリ内のMetaDbEngine::new_single_nodeは、メモリ上の投票者数を 3 に増やせます。そのオブジェクトにはディスクも Raft もありません。metadbdのスケールアウトではありません。
topology_distributed still uses DurableCellManager::scale_out_replicas with localhost voters inside one OS process. join_existing_group starts real metadbd processes and joins them. The shared-secret case in that file opens two clusters inside the test process; it does not start two metadbd OS processes. be、proxy、cell-manager、global-manager は妥当な設定で起動します。これは分離した本番配置ではありません。第二のセルはこのプロセスのディレクトリに記録できますが、本番の複数セル配置ではありません。 This process can copy its own jumbo shard directory onto jumbo_dedicated_root. A loopback MOVE_STAGED / MOVE_LIVE placement is specified in docs/en/scale-control-plane-status.md. It does not call transfer_leader, does not replicate the cell directory, and is not a production move.
変種は crates/metadb-core/src/error.rs で定義されています。gRPC メソッドは通常、非 OK ステータスではなく応答の error フィールドに変種を返します。
| 変種 | コードが上げるとき |
|---|---|
ReservedEntryName |
空の名前、NUL、またはユーザエントリとしての _attr_ |
AlreadyExists / NotFound |
(pid, name) の作成または検索 |
DirectoryNotEmpty |
子が残っている rmdir。属性フラッシュの前も含む |
InvalidEntryType |
ファイルへの rmdir、またはディレクトリへの unlink |
TransactionTimeout |
スナップショット HLC がメモリ内 MVCC 窓より古い |
ClockSkewExceeded |
遠隔 HLC がローカルの壁時計より max_clock_drift_ms を超えて進んでいる |
EpochMismatch / NotLeader |
古いルートエポック、またはこのレプリカがリーダーではない。リーダーが分かっている follower の読み取りは転送される。複数キーの Prepare での EpochMismatch はそのラウンドを中止して再グループ化し、同じバッチを再提案しない |
RetryableConsensus |
リーダー交代で書き込みログが破棄された、またはクォーラムが応答しなかった。同一シャードの書き込みと 2PC は既存のルーティング予算内で再試行する。一つの論理書き込みは同じ提案 ID を使う。その ID が既にコミット済みなら、シャードは元の結果を返し、コマンドを再実行しない。ストレージ障害と停止した Raft ノードは ConsensusError のままで再試行しない |
UnsplittableJumboShard |
メモリ内スプリッタ(shard.rs)。永続ジャンボ経路ではない。永続経路は JumboIsolated を立て、子シャードなしで成功を返す |
WriteIntentConflict / TransactionAborted |
2PC の衝突、またはディレクトリリネームのリースがすでに保持されている |
InvalidRenameCycle |
ディレクトリを自分自身または子孫へリネームする |
ConsensusError |
登録ノード不足、learner の追いつきタイムアウト(10 秒)、または OpenRaft のメンバーシップエラー |
SqlParseError |
文が 20 テンプレートのどれでもない |
不正なロールの組み合わせと不正な TOML は CodecError です。be、proxy、cell-manager、global-manager はその拒否ではありません。妥当な設定なら起動します。
all-in-one、cell-manager、global-manager、be、proxyは妥当な設定で起動します。beはローカルレプリカを持ち、ID を発行しません。proxyは含まれるメタデータ呼び出し、ExecuteSql、またはユーザキー付きトランザクションを登録済みセルへ送り、そうでなければ失敗して閉じます。CommitPrimary2pc、ApplyAuxBatch、ForwardRouter、GetRoutesは引き続き[cluster] upstreamを使うことがあります。AllocateIdBlockは拒否されます。proxy は Raft を持ちません。global-managerにローカルシャードはありません。登録済みセルに含まれる要求は転送し、SHARED_ID_ALLOCATORから共有 ID ブロックを付与します。シャードグループを開かないため、そのディレクトリファイルはシャードログへコピーされません。cell-managerは引き続き Raft グループを同じプロセスに置きます。- 2 つ目の all-in-one プロセスは
[cluster] joinで同じセルに参加できます。その参加は第二のセルを作りません。RegisterCellはルートが要求範囲を覆うとき、別のセルを記録します。このプロセスは、そのセルに含まれる後続の要求を転送します。 - 未知で非ゼロの
cell_idに対するGetRoutesは失敗して閉じる。StoreHeartbeatはキャッシュ済みルートを置き換えない。 - ジャンボ隔離はルートフラグと、ローカルノード表から選んだノード ID である。他のシャードをディスクから追い出すことはしない。
- Registered-node liveness is fsynced in
CELL_CONTROL_PLANE.metadbdpersists its own record about every 3 seconds and sends it to the current leader when this process is not the leader. Descriptors on that RPC are annotations, not routes. The observation does not schedule placement. See Scale control plane. - A secret that contains a non-whitespace character authenticates Raft, the other three gRPC services, and the metrics listener, including
/livez,/readyz, and/healthz, with the same bearer. An empty secret does not start the process.allow_unauthenticated = trueis the explicit exception for literal loopback IPs (127.0.0.0/8or::1) and still refuses a wildcard bind. The hostnamelocalhostis not accepted for that exception. The bound socket is checked again after listen. A whitespace-only secret is rejected and is not compared as a bearer. A usable secret combined with the flag is rejected. When[security.tls].modeisoff, listeners are plaintext.tlsandmtlsare refused before listen. This process does not terminate TLS. Seedocs/designs/transport_security.md. memtable_size_bytesはアクティブな memtable を封印してフラッシュする。max_imm_memtablesはキューに積まれた不変テーブルの数を抑える。[raft]timers andmax_segment_bytesapply when a group starts. They are not reloaded from a changed file, and the segment size does not rewrite segments already on disk.hotspot-createとbulk-ttl-deleteのmetadb-ctl benchは JSON 行を印字する。bench_pidを含むヘッダのあと、attempted、succeeded、failed とレイテンシのパーセンタイルを持つフェーズ報告が続く。要求した操作がすべて成功しない限り、プロセスは非ゼロで終了する。--workload mixedまたは--embeddedはプロセス内のストレステストを実行する。sqlは応答を JSON で印字し、アプリケーションエラーでは非ゼロで終了する。
次の項目は製品に無いため、このガイドは手順を書けません。
- 全シャードの本番 MetaCache でも、分離した本番配置でもありません。
be、proxy、cell-manager、global-managerは妥当な設定で起動します。 RegisterCellはエラーのままではありません。ルートが範囲を覆うとGLOBAL_CELL_DIRECTORYを書き、そのセルに含まれる後続の要求を転送します。join は現在のリーダーに届く必要があります。follower はメンバーシップ変更を転送しません。- ジャンボシャードを専用マシンに置き、他のシャードをそのマシンから移すこと。ループバックのリスナーは
MOVE_STAGED/MOVE_LIVEでジャンボディレクトリを受け取れます。それはmetadbdではなく、認証もなく、Raft を開かず、transfer_leaderを呼ばず、別ホストへの本番コピーではありません。 - プロセス内の TLS。このプロセスは TLS を終端しない。TLS や証明書を求める設定キーは、平文で提供する代わりに拒否される。終端は外部プロキシに置く。シークレットがあるとき、Raft とメトリクスは他のサービスと同じベアラを使う。これは相互 TLS ではない。ハートビート駆動の制御ループは未実装である。
- A gRPC health RPC, probes when
metrics_listen_addris unset, and per-shard Prometheus series./readyzdoes not wait for the 250 ms 2PC recovery pass. A leader election makes/readyzand/healthzreturn 503 on replicas that do not know a leader.[raft]is loaded and is not#[serde(skip)]. Its values apply when a group starts and are not reloaded. See Operability. - 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.