feat(depot): materialize capped database forks on bucket fork access#5223
Conversation
|
Stack for rivet-dev/rivet
Get stack: |
Review: feat(depot): materialize capped database forks on bucket fork accessThis PR implements lazy database materialization for bucket forks — a clean and correct design. Reads through a forked bucket now freeze at the fork point, and the first write builds on inherited state rather than shadowing it with an empty branch. The test coverage is solid for the core scenarios. A few concerns to flag. Bug: history pointer written with In both rollback code paths ( let cur_ptr = DatabasePointer {
current_branch: cur_branch,
last_swapped_at_ms: 0,
};
// ...
let encoded_history_pointer = encode_database_pointer(cur_ptr.clone())?;
tx.informal().set(&keys::database_pointer_history_key(...), &encoded_history_pointer);The original code used Potential correctness gap: if !bucket.initialized {
if let Some(branch_id) = branch::resolve_or_materialize_in_bucket_branch(...) { ... }
}
// fallthrough -> new_v4(), database_initialized: trueWhen In practice, SQLite's read-before-write page pattern means if let Some(branch_id) = branch::resolve_or_materialize_in_bucket_branch(...).await? {
return Ok(BranchResolution { branch_id, ..., database_initialized: false });
}Missing test: multi-database bucket fork write path No test covers: fork bucket -> commit DB1 (bucket becomes initialized) -> commit DB2 without a prior read (bucket already initialized, DB2 not yet materialized). This is the exact scenario that exercises the Minor: tombstone check ordering on nil branch In if current_branch_id == BucketBranchId::nil() {
return Ok(None);
}
if tx.get(tombstone_key).await?.is_some() { ... }Tombstones on the nil branch are never evaluated. This matches the original What's well done
|
No description provided.