fix(flatkv): fix state sync panic on nil DB handles during snapshot restore#3003
fix(flatkv): fix state sync panic on nil DB handles during snapshot restore#3003blindchaser merged 3 commits intomainfrom
Conversation
…estore rootmulti.Restore closes the SC store before calling Importer(), leaving all DB handles nil. The old code created a KVImporter against the closed store, which panicked in commitGlobalMetadata() on the nil metadataDB. A second bug in composite.SnapshotImporter.AddModule() never set currentModule, so the EVM importer received zero nodes — masking the nil-DB crash until Close() reached commitGlobalMetadata(). Fixes: - Reopen the store in Importer() when isClosed() is true - Set currentModule in composite SnapshotImporter.AddModule() - Move flatkv data dir under data/ to align with evm_ss convention - Add isClosed() helper to avoid spreading the nil-check assumption
|
The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3003 +/- ##
==========================================
- Coverage 58.30% 58.30% -0.01%
==========================================
Files 2108 2108
Lines 173672 173680 +8
==========================================
Hits 101262 101262
- Misses 63390 63398 +8
Partials 9020 9020
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
sei-db/state_db/sc/flatkv/store.go
Outdated
|
|
||
| func (s *CommitStore) flatkvDir() string { | ||
| return filepath.Join(s.homeDir, flatkvRootDir) | ||
| return filepath.Join(s.homeDir, "data", flatkvRootDir) |
There was a problem hiding this comment.
We should do the appending to the dir when we initialize FlatKV in CompositeSC layer instead of changing the function here. We probably don't wanna change the test as well, just use whatever is passed in should be good ?
| ) | ||
|
|
||
| // isClosed reports whether the store's DB handles have been released. | ||
| func (s *CommitStore) isClosed() bool { |
There was a problem hiding this comment.
Shall we add an atomic bool just to make sure this is thread safe in the future?
There was a problem hiding this comment.
closed flag alone is probably not sufficient since other store fields are still unsynchronized. I’d avoid that for now and revisit when/if we decide to make CommitStore concurrent-safe.
…estore (#3003) Issue: rootmulti.Restore closes the SC store before calling Importer(), leaving all DB handles nil. The old code created a KVImporter against the closed store, which panicked in commitGlobalMetadata() on the nil metadataDB. A second bug in composite.SnapshotImporter.AddModule() never set currentModule, so the EVM importer received zero nodes — masking the nil-DB crash until Close() reached commitGlobalMetadata(). Fixes: - Reopen the store in Importer() when isClosed() is true - Set currentModule in composite SnapshotImporter.AddModule() - Move flatkv data dir under data/ to align with evm_ss convention - Add isClosed() helper to avoid spreading the nil-check assumption ## Describe your changes and provide context ## Testing performed to validate your change
Issue:
rootmulti.Restore closes the SC store before calling Importer(), leaving all DB handles nil. The old code created a KVImporter against the closed store, which panicked in commitGlobalMetadata() on the nil metadataDB.
A second bug in composite.SnapshotImporter.AddModule() never set currentModule, so the EVM importer received zero nodes — masking the nil-DB crash until Close() reached commitGlobalMetadata().
Fixes:
Describe your changes and provide context
Testing performed to validate your change