You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite. Learn more
Review: fix(sqlite-storage): open v1 migration stages
The core logic is sound. prepare_v1_migration now correctly mirrors the open pattern (insert into open_dbs first, update generation on success, remove on error), and the ConcurrentTakeover error is the right signal for callers to disconnect the actor.
A few things worth looking at before merging:
Potential open_dbs leak in invalidate_v1_migration
prepare_v1_migration inserts a generation-0 sentinel into open_dbs and updates it on success. When concurrent takeover is later detected inside invalidate_v1_migration (origin not MigratingFromV1 with require_stage_in_progress=true), reset_v1_migration returns Ok(None) and invalidate_v1_migration does not remove the entry:
if reset.is_some(){self.open_dbs.remove_async(&actor_id.to_string()).await;}
This leaves a stale open_dbs entry. Future calls to open or prepare_v1_migration for the same actor will hit the "sqlite db already open for actor" guard. Whether this is safe depends on whether the caller reliably invokes force_close on all non-Some returns. If Ok(None) always means "close the migration", unconditional cleanup is safer:
let reset = self.reset_v1_migration(actor_id, now_ms,true).await?;self.open_dbs.remove_async(actor_id).await;Ok(reset.is_some())
Unusual None.context(...) idiom
The Ok(None) arm in prepare_v1_migration uses None.context(...) to produce an error. It works, but is visually surprising. Minor nit.
Unnecessary allocations
In the cleanup arms of prepare_v1_migration, actor_id is &str. The .to_string() calls create needless String allocations. scc::HashMap accepts Q where K: Borrow<Q>, so actor_id works directly.
Missing test coverage
No tests cover the new error path. Two cases worth adding:
prepare_v1_migration on an actor whose origin is no longer MigratingFromV1 should return ConcurrentTakeover and leave open_dbs clean so a subsequent open succeeds.
invalidate_v1_migration when concurrent takeover is detected should return Ok(false) without leaving a stale open_dbs entry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: