Fixup accounts count when importing snapshot append vecs#7010
Fixup accounts count when importing snapshot append vecs#7010sakridge merged 1 commit intosolana-labs:masterfrom
Conversation
8f86207 to
56944fb
Compare
Codecov Report
@@ Coverage Diff @@
## master #7010 +/- ##
========================================
- Coverage 79.1% 74.2% -5%
========================================
Files 230 229 -1
Lines 44285 47197 +2912
========================================
- Hits 35051 35029 -22
- Misses 9234 12168 +2934 |
|
@ryoqun I didn't really start to look into the root cause. As you said, this is more of a workaround. I think we would still like to root cause the actual issue. |
|
@sakridge Ok! Thanks for explaining! Also, I just noticed the mention of this PR in the |
|
This may not help actually. |
c9782f7 to
14e6357
Compare
| .verify_hash_internal_state(self.slot(), &self.ancestors) | ||
| && !self.has_accounts_with_zero_lamports() | ||
| { | ||
| info!( |
There was a problem hiding this comment.
+1 for more detailed message!
Eventually verify_snapshot_bank causes termination, so can warn! be more appropriate?
There was a problem hiding this comment.
Well, I'm thinking if you are running a test which is designed to hit this, then it is not a problem and in the case that we panic, the error is already obvious from that, this just gives some extra detail.
ryoqun
left a comment
There was a problem hiding this comment.
LGTM with nits. (commented concerns are clarified already; thanks for quick replies)
14e6357 to
e41ec15
Compare
78fd99b to
22c7e61
Compare
Snapshots do not load the original index, so they must purge zero lamport accounts again.
22c7e61 to
942c81e
Compare
| } | ||
|
|
||
| let mut counts = HashMap::new(); | ||
| for slot_list in accounts_index.account_maps.values() { |
There was a problem hiding this comment.
@ryoqun I think this should be more accurate to capture the updated count, can you take a look?
There was a problem hiding this comment.
Yeah, this looks good! This's kind of reverse of my implementation. Simper, nicer :)
| let accounts = AccountsDB::new_single(); | ||
| let mut pubkeys: Vec<Pubkey> = vec![]; | ||
|
|
||
| // Create 100 accounts in slot 0 |
There was a problem hiding this comment.
+1 +1 +1 Got really more readable! :)
|
The CI passed! |
Yep. I merged. If you can look at your tests to see if there are any cases which are still not covered now, can you add them? |
I've tested this PR locally with tests from #7013 and found there is no such uncovered cases! It seems that this works really well! Thanks for the work! |
| count, | ||
| store.count_and_status.read().unwrap().0 | ||
| ); | ||
| store.count_and_status.write().unwrap().0 = *count; |
There was a problem hiding this comment.
This discards the original value (=deserialized from snapshot) of count of count_and_status by unconditionally overwriting it.
Problem
count_and_status is not accurate from the serialized snapshot, because the snapshot creator could have removed some accounts from it's append vec view and thus decremented the count.
Summary of Changes
Update count_and_status by reading in the append_vec and correcting the accounts count.
Fixes #