Allow replacing tombstone with a non-tombstone (#31494)

This commit is contained in:
Pankaj Garg 2023-05-04 13:56:39 -07:00 committed by GitHub
parent 555520b640
commit de43ac44fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -328,6 +328,10 @@ impl LoadedPrograms {
Ordering::Relaxed,
);
second_level.swap_remove(entry_index);
} else if existing.is_tombstone() && !entry.is_tombstone() {
// The old entry is tombstone and the new one is not. Let's give the new entry
// a chance.
second_level.swap_remove(entry_index);
} else {
return (true, existing.clone());
}
@ -809,6 +813,23 @@ mod tests {
});
}
#[test]
fn test_replace_tombstones() {
let mut cache = LoadedPrograms::default();
let program1 = Pubkey::new_unique();
set_tombstone(
&mut cache,
program1,
10,
LoadedProgramType::FailedVerification,
);
let loaded_program = new_test_loaded_program(10, 10);
let (existing, program) = cache.replenish(program1, loaded_program.clone());
assert!(!existing);
assert_eq!(program, loaded_program);
}
#[test]
fn test_tombstone() {
let tombstone = LoadedProgram::new_tombstone(0, LoadedProgramType::FailedVerification);