- Created T026-practical-test task.yaml for MVP smoke testing - Added k8shost-server to flake.nix (packages, apps, overlays) - Staged all workspace directories for nix flake build - Updated flake.nix shellHook to include k8shost Resolves: T026.S1 blocker (R8 - nix submodule visibility)
3.7 KiB
3.7 KiB
FlareDB Metadata Adoption Design
Date: 2025-12-08 Task: T020 Status: Design Phase
1. Problem Statement
Current services (LightningSTOR, FlashDNS, FiberLB) and the upcoming NovaNET (T019) use ChainFire (Raft+Gossip) for metadata storage.
ChainFire is intended for cluster membership, not general-purpose metadata.
FlareDB is the designated DBaaS/Metadata store, offering better scalability and strong consistency (CAS) modes.
2. Gap Analysis
To replace ChainFire with FlareDB, we need:
- Delete Operations: ChainFire supports
delete(key). FlareDB currently supports onlyPut/Get/Scan(Raw) andCAS/Get/Scan(Strong).CasWritein Raft only inserts/updates. - Prefix Scan: ChainFire has
get_prefix(prefix). FlareDB hasScan(start, end). Client wrapper needed. - Atomic Updates: ChainFire uses simple LWW or transactions. FlareDB
KvCasprovidesCompareAndSwapwhich is superior for metadata consistency.
3. Protocol Extensions (T020.S2)
3.1 Proto (kvrpc.proto)
Add Delete to KvCas (Strong Consistency):
service KvCas {
// ...
rpc CompareAndDelete(CasDeleteRequest) returns (CasDeleteResponse);
}
message CasDeleteRequest {
bytes key = 1;
uint64 expected_version = 2; // Required for safe deletion
string namespace = 3;
}
message CasDeleteResponse {
bool success = 1;
uint64 current_version = 2; // If failure
}
Add RawDelete to KvRaw (Eventual Consistency):
service KvRaw {
// ...
rpc RawDelete(RawDeleteRequest) returns (RawDeleteResponse);
}
message RawDeleteRequest {
bytes key = 1;
string namespace = 2;
}
message RawDeleteResponse {
bool success = 1;
}
3.2 Raft Request (types.rs)
Add CasDelete and KvDelete to FlareRequest:
pub enum FlareRequest {
// ...
KvDelete {
namespace_id: u32,
key: Vec<u8>,
ts: u64,
},
CasDelete {
namespace_id: u32,
key: Vec<u8>,
expected_version: u64,
ts: u64,
},
}
3.3 State Machine (storage.rs)
Update apply_request to handle deletion:
KvDelete: Remove fromkv_data.CasDelete: Checkexpected_versionmatchescurrent_version. If yes, remove fromcas_data.
4. Client Extensions (RdbClient)
impl RdbClient {
// Strong Consistency
pub async fn cas_delete(&mut self, key: Vec<u8>, expected_version: u64) -> Result<bool, Status>;
// Eventual Consistency
pub async fn raw_delete(&mut self, key: Vec<u8>) -> Result<(), Status>;
// Helper
pub async fn scan_prefix(&mut self, prefix: Vec<u8>) -> Result<Vec<(Vec<u8>, Vec<u8>)>, Status> {
// Calculate end_key = prefix + 1 (lexicographically)
let start = prefix.clone();
let end = calculate_successor(&prefix);
self.cas_scan(start, end, ...)
}
}
5. Schema Migration
Mapping ChainFire keys to FlareDB keys:
- Namespace: Use
defaultor service-specific (e.g.,fiberlb,novanet). - Keys: Keep same hierarchical path structure (e.g.,
/fiberlb/loadbalancers/...). - Values: JSON strings (UTF-8 bytes).
| Service | Key Prefix | FlareDB Namespace | Mode |
|---|---|---|---|
| FiberLB | /fiberlb/ |
fiberlb |
Strong (CAS) |
| FlashDNS | /flashdns/ |
flashdns |
Strong (CAS) |
| LightningSTOR | /lightningstor/ |
lightningstor |
Strong (CAS) |
| NovaNET | /novanet/ |
novanet |
Strong (CAS) |
| PlasmaVMC | /plasmavmc/ |
plasmavmc |
Strong (CAS) |
6. Migration Strategy
- Implement Delete support (T020.S2).
- Create
FlareDbMetadataStoreimplementation in each service alongsideChainFireMetadataStore. - Switch configuration to use FlareDB.
- (Optional) Write migration tool to copy ChainFire -> FlareDB.