Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Fixup accounts count when importing snapshot append vecs#7010

Merged
sakridge merged 1 commit intosolana-labs:masterfrom
sakridge:snapshot-zero-account-purge
Nov 23, 2019
Merged

Fixup accounts count when importing snapshot append vecs#7010
sakridge merged 1 commit intosolana-labs:masterfrom
sakridge:snapshot-zero-account-purge

Conversation

@sakridge
Copy link
Copy Markdown
Contributor

@sakridge sakridge commented Nov 18, 2019

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 #

@sakridge sakridge force-pushed the snapshot-zero-account-purge branch from 8f86207 to 56944fb Compare November 18, 2019 02:51
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 18, 2019

Codecov Report

Merging #7010 into master will decrease coverage by 4.9%.
The diff coverage is 60.6%.

@@           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
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 18, 2019

@sakridge Thanks for this PR! FYI, I'm currently working on this as part of #6890. Am I correct to regard this as a temporary fix until my upcoming fix to the root cause? Or have you started to work on this? I'm just asking this to avoid any overlapping work. :)

@sakridge
Copy link
Copy Markdown
Contributor Author

@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.

@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 18, 2019

@sakridge Ok! Thanks for explaining! Also, I just noticed the mention of this PR in the #network-protocols channel of our Discord server.

@mvines mvines added the v0.20 label Nov 18, 2019
@sakridge
Copy link
Copy Markdown
Contributor Author

This may not help actually.

@sakridge sakridge added the work in progress This isn't quite right yet label Nov 18, 2019
@mvines mvines removed the v0.20 label Nov 20, 2019
@sakridge sakridge force-pushed the snapshot-zero-account-purge branch 2 times, most recently from c9782f7 to 14e6357 Compare November 22, 2019 21:46
@sakridge sakridge removed the work in progress This isn't quite right yet label Nov 22, 2019
@sakridge sakridge changed the title Purge snapshot of 0 lamport accounts before snapshot verify Fixup accounts count when importing snapshot append vecs Nov 22, 2019
Comment thread runtime/src/bank.rs Outdated
.verify_hash_internal_state(self.slot(), &self.ancestors)
&& !self.has_accounts_with_zero_lamports()
{
info!(
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.

+1 for more detailed message!

Eventually verify_snapshot_bank causes termination, so can warn! be more appropriate?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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 see!

Comment thread runtime/src/accounts_db.rs Outdated
Comment thread runtime/src/accounts_db.rs Outdated
Comment thread runtime/src/accounts_db.rs Outdated
Comment thread runtime/src/bank.rs
ryoqun
ryoqun previously approved these changes Nov 23, 2019
Copy link
Copy Markdown
Contributor

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

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

LGTM with nits. (commented concerns are clarified already; thanks for quick replies)

@sakridge sakridge force-pushed the snapshot-zero-account-purge branch from 14e6357 to e41ec15 Compare November 23, 2019 00:40
@mergify mergify Bot dismissed ryoqun’s stale review November 23, 2019 00:41

Pull request has been modified.

@sakridge sakridge force-pushed the snapshot-zero-account-purge branch 2 times, most recently from 78fd99b to 22c7e61 Compare November 23, 2019 00:47
Snapshots do not load the original index, so they must
purge zero lamport accounts again.
@sakridge sakridge force-pushed the snapshot-zero-account-purge branch from 22c7e61 to 942c81e Compare November 23, 2019 00:53
}

let mut counts = HashMap::new();
for slot_list in accounts_index.account_maps.values() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ryoqun I think this should be more accurate to capture the updated count, can you take a look?

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.

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
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.

+1 +1 +1 Got really more readable! :)

@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 23, 2019

The CI passed!

@sakridge sakridge merged commit 6c89226 into solana-labs:master Nov 23, 2019
@sakridge sakridge deleted the snapshot-zero-account-purge branch November 23, 2019 02:22
@sakridge
Copy link
Copy Markdown
Contributor Author

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?

@ryoqun
Copy link
Copy Markdown
Contributor

ryoqun commented Nov 24, 2019

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;
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.

This discards the original value (=deserialized from snapshot) of count of count_and_status by unconditionally overwriting it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants