chore: sqlite v1 to v2 data migration#4692
chore: sqlite v1 to v2 data migration#4692NathanFlurry wants to merge 1 commit into04-19-chore_move_rivetkit_to_task_modelfrom
Conversation
|
🚅 Deployed to the rivet-pr-4692 environment in rivet-frontend
|
Code Review: SQLite v1 to v2 Data MigrationThis is a solid, well-tested migration path. The core logic is correct and the test coverage is comprehensive. A few items to address before merging: Bug / CorrectnessIndentation in The body of if let Some(existing_meta) =
udb::tx_get_value_serializable(&tx, &subspace, &meta_storage_key).await?
{
let existing_head = decode_db_head(&existing_meta)?; // ← should be one tab deeper
ensure!(
matches!(existing_head.origin, SqliteOrigin::MigratingFromV1),
SqliteStorageError::ConcurrentTakeover
);
}Should be: if let Some(existing_meta) =
udb::tx_get_value_serializable(&tx, &subspace, &meta_storage_key).await?
{
let existing_head = decode_db_head(&existing_meta)?;
ensure!(
matches!(existing_head.origin, SqliteOrigin::MigratingFromV1),
SqliteStorageError::ConcurrentTakeover
);
}Performance ConcernsEvery actor start scans v1 KV keys even after a successful migration After migration succeeds, the v1 KV keys are intentionally not deleted. As a result, every subsequent actor start still runs:
This is 2 extra KV round-trips on every warm start for any actor that was ever on v1. If v1 actors are numerous, this adds up at scale. Consider adding a test for idempotent call behavior, and a TODO comment explaining why v1 data is not cleaned up post-migration (or clean it up in a follow-up). Wrong histogram bucket set for
pub static ref SQLITE_MIGRATION_PAGES: Histogram = register_histogram_with_registry!(
"pegboard_envoy_sqlite_migration_pages",
"Number of pages imported during sqlite v1 to v2 migration.",
vec![1.0, 4.0, 16.0, 64.0, 256.0, 1024.0, 4096.0, 16384.0, 32768.0],
*REGISTRY
).unwrap();CLAUDE.md Convention Violations
CLAUDE.md: "Never use These profile tests print timing summaries with
CLAUDE.md: "Prefer anyhow's Affected lines: // database.rs
.ok_or_else(|| anyhow!("missing sqlite startup data for actor {actor_id}"))?;
.map_err(|e| anyhow!("failed to register sqlite VFS: {e}"))?;
.map_err(|e| anyhow!("failed to open sqlite database: {e}"))
// udb.rs
return Err(anyhow::anyhow!(
"unknown sqlite-storage value marker {other} for key {:?}", key
));Minor / Design Notes (no action required)
When the new
When v1 data never explicitly cleaned up post-migration Test Coverage AssessmentCoverage is excellent:
Missing: a test that calls SummaryThe architecture is sound. The key fixes before merging are:
|
c2fbb00 to
daf7aa8
Compare
710f2df to
5b8e173
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: