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

handle ancient overflow case correctly #29458

Merged
merged 1 commit into from
Jan 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4506,7 +4506,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:
Expand Down Expand Up @@ -4537,8 +4538,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 =
Expand Down