fix(pegboard): move sqlite v1 migration into actor workflow#4787
Conversation
Code Review: fix(pegboard): move sqlite v1 migration into actor workflow
OverviewThis PR refactors the SQLite v1→v2 migration by:
The motivation is sound: running migration as a workflow activity gives it proper retry semantics, error surfacing, and isolation from the actor dispatch path. IssuesMigration locks map grows unboundedly// actor_sqlite.rs
static SQLITE_MIGRATION_LOCKS: OnceLock<HashMap<String, Arc<Mutex<()>>>> = OnceLock::new();
async fn actor_migration_lock(actor_id: &str) -> Arc<Mutex<()>> {
match migration_locks().entry_async(actor_id).await {
Entry::Occupied(entry) => Arc::clone(entry.get()),
Entry::Vacant(entry) => Arc::clone(entry.insert_entry(Arc::new(Mutex::new(()))).get()),
}
}Entries are never evicted from Duplicate constants between impl and test
Three duplicate call sites for migration step
60-second lease may be shorter than the migration itself
WAL/SHM rejection is terminal with no recovery pathensure!(
!v1_file_exists(db, recipient, FILE_TAG_WAL).await?,
"unexpected sqlite v1 WAL sidecar present"
);If a v1 actor snapshot has a WAL sidecar, migration hard-fails permanently — v2 data doesn't exist and migration will never succeed. At minimum, include the actor ID in the error and ensure it surfaces in alerting. Consider whether the WAL can be merged into the main file using rusqlite's SuggestionsTempdir disk I/O for large databases. The recovery step writes the full v1 main and journal bytes to a tempdir before opening with rusqlite. For databases near 128 MiB this means ~256 MiB of disk writes.
Metrics are well-instrumented. Per-phase failure labels on Double-checked locking pattern is correct. The Test coverage is thorough. The new Minor style notes (per CLAUDE.md)
|
Preview packages published to npmInstall with: npm install rivetkit@pr-4787All packages published as Engine binary is shipped via Docker images: docker pull rivetdev/engine:slim-4a3bf94
docker pull rivetdev/engine:full-4a3bf94Individual packagesnpm install rivetkit@pr-4787
npm install @rivetkit/react@pr-4787
npm install @rivetkit/rivetkit-napi@pr-4787
npm install @rivetkit/workflow-engine@pr-4787 |
24d59db to
81b9731
Compare
7ecf3ef to
7b73290
Compare
81b9731 to
6d8d78f
Compare
7b73290 to
796c8b3
Compare
6d8d78f to
fffe86c
Compare
796c8b3 to
63dbe6f
Compare
PR Review: fix(pegboard): move sqlite v1 migration into actor workflowThis PR relocates the SQLite v1-to-v2 migration from Critical
SignificantMigration lock removed without concurrency analysis The old code held a per-actor Journal sidecar behavior is a silent regression The old
The new code calls ModerateDuplicate constant definitions in test file
Confirm that existing Per-call The MinorCLAUDE.md section rename drops constraints The rename from "Important Domain Information" to "Terminology" removes the "Never claim zero cold start" bullet and the
SummaryThe structural decision to move migration into the workflow is sound and the test coverage in |
63dbe6f to
fc55a97
Compare
fffe86c to
1b1fb61
Compare
3e13940 to
f6d9a16
Compare
01215ac to
7d7aa2d
Compare
7d7aa2d to
a9093f9
Compare
a9093f9 to
c1976e3
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: