handle ancient overflow case correctly (#29458)

This commit is contained in:
Jeff Washington (jwash) 2023-01-02 14:39:59 -06:00 committed by GitHub
parent 8397f295c0
commit e99afb4e85
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -4501,7 +4501,8 @@ impl AccountsDb {
return; // skipping slot with no useful accounts to write
}
let (shrink_in_progress, time) = measure!(current_ancient.create_if_necessary(slot, self));
let (mut shrink_in_progress, time) =
measure!(current_ancient.create_if_necessary(slot, self));
let mut create_and_insert_store_elapsed_us = time.as_us();
let available_bytes = current_ancient.append_vec().accounts.remaining_bytes();
// split accounts in 'slot' into:
@ -4532,8 +4533,17 @@ impl AccountsDb {
// Assert: it cannot be the case that we already had an ancient append vec at this slot and
// yet that ancient append vec does not have room for the accounts stored at this slot currently
assert_ne!(slot, current_ancient.slot());
let (_, time) = measure!(current_ancient.create_ancient_append_vec(slot, self));
let (shrink_in_progress_overflow, time) =
measure!(current_ancient.create_ancient_append_vec(slot, self));
create_and_insert_store_elapsed_us += time.as_us();
// We cannot possibly be shrinking the original slot that created an ancient append vec
// AND not have enough room in the ancient append vec at that slot
// to hold all the contents of that slot.
// We need this new 'shrink_in_progress' to be used in 'remove_old_stores_shrink' below.
// All non-overflow accounts were put in a prior slot's ancient append vec. All overflow accounts
// are essentially being shrunk into a new ancient append vec in 'slot'.
assert!(shrink_in_progress.is_none());
shrink_in_progress = Some(shrink_in_progress_overflow);
// write the overflow accounts to the next ancient storage
let timing =