Skip to content

Utility for migrating from memiavl to flatKV#3275

Open
cody-littley wants to merge 22 commits intomainfrom
cjl/migration-2
Open

Utility for migrating from memiavl to flatKV#3275
cody-littley wants to merge 22 commits intomainfrom
cjl/migration-2

Conversation

@cody-littley
Copy link
Copy Markdown
Contributor

Describe your changes and provide context

This PR introduces a utility for migrating data from database A to database B. It's generic so that we can encapsulate migration logic. Additionally, we can reuse this utility in the future if we ever have a future migration of similar nature.

Testing performed to validate your change

Lots of unit tests.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedApr 21, 2026, 6:23 PM

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 96.08802% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.38%. Comparing base (c5cad2b) to head (2debcb1).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/state_db/sc/migration/migration_manager.go 95.76% 4 Missing and 4 partials ⚠️
...tate_db/sc/migration/memiavl_migration_iterator.go 92.20% 3 Missing and 3 partials ⚠️
sei-db/state_db/sc/migration/migration_types.go 80.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3275      +/-   ##
==========================================
+ Coverage   59.29%   59.38%   +0.08%     
==========================================
  Files        2070     2075       +5     
  Lines      169775   170184     +409     
==========================================
+ Hits       100663   101056     +393     
- Misses      60321    60330       +9     
- Partials     8791     8798       +7     
Flag Coverage Δ
sei-chain-pr 96.08% <96.08%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/state_db/sc/migration/migration_boundary.go 100.00% <100.00%> (ø)
...b/state_db/sc/migration/mock_migration_iterator.go 100.00% <100.00%> (ø)
sei-db/state_db/sc/migration/migration_types.go 80.00% <80.00%> (ø)
...tate_db/sc/migration/memiavl_migration_iterator.go 92.20% <92.20%> (ø)
sei-db/state_db/sc/migration/migration_manager.go 95.76% <95.76%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

newErr = e
newDone = true
case <-ctx.Done():
return ctx.Err()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to drain both channels before returning here?

case MigrationComplete:
return len(treeNames)
}
return sort.Search(len(treeNames), func(i int) bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think tree name is guaranteed to be sorted?

// Write the value to the new DB.
putPair(newDBPairsByStore, value.ModuleName, &proto.KVPair{Key: value.Key, Value: value.Value})
// Delete the value from the old DB.
putPair(oldDBPairsByStore, value.ModuleName, &proto.KVPair{Key: value.Key, Delete: true})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would recommend add a metrics how how many keys are migrated successfully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants