Skip to content

Scan accounts panics if get_account_accessor returns Cached(None) #6929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025

Conversation

roryharr
Copy link

Problem

get_loaded_account expects that the account accessor refers to a valid entry. This may not be the case during scan_accounts as it can run concurrently with flush_write_cache.

Summary of Changes

Modified scan_accounts to return an error when a Cached(None) account accessor is found.

Fixes #

let account_slot = self
.get_account_accessor(slot, pubkey, &account_info.storage_location())
.get_loaded_account(|loaded_account| {
let mut account_accessor =
Copy link
Author

@roryharr roryharr Jul 10, 2025

Choose a reason for hiding this comment

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

Cached(None) can occur in two situations:

  1. The account is flushed from cache to storage between scan_accounts finding the account, and get_account_accessor being called
  2. The slot/account is removed entirely between scan_accounts finding the account and get_account_accessor being called.

Both cases result in a panic with the current code. This modifies both cases to be errors, at which point another RPC call can be done.

It might be better to handle the first case explicitly, but that would be a larger change, and this is better than the existing behaviour in both scenarios.

The other option considered was using retry_to_get_account_accessor, but that still results in a panic in scenario 2.

@roryharr roryharr requested review from brooksprumo and HaoranYi July 10, 2025 23:07
@roryharr roryharr changed the title Scan accounts should not use get_loaded_account Scan accounts panics if get_account_accessor returns Cached(None) Jul 10, 2025
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.2%. Comparing base (ca5877f) to head (8cd6eca).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #6929     +/-   ##
=========================================
- Coverage    83.2%    83.2%   -0.1%     
=========================================
  Files         853      853             
  Lines      377591   377593      +2     
=========================================
- Hits       314527   314520      -7     
- Misses      63064    63073      +9     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roryharr
Copy link
Author

In general I would like to add a sleep to get_account_accessor, but I can't do that in this PR as there are other bugs to resolve first.

Copy link

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

:shipit:

@roryharr roryharr merged commit 3e76cb1 into anza-xyz:master Jul 11, 2025
41 checks passed
@HaoranYi
Copy link

lgtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants