disk idx: restart re-uses disk index files (#33382)

This commit is contained in:
Jeff Washington (jwash) 2023-09-24 12:25:50 -07:00 committed by GitHub
parent 967a78bbc1
commit 5c57641313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -88,13 +88,21 @@ impl<T: Clone + Copy + Debug + PartialEq> BucketMap<T> {
);
let max_search = config.max_search.unwrap_or(MAX_SEARCH_DEFAULT);
if let Some(drives) = config.drives.as_ref() {
Self::erase_previous_drives(drives);
let mut restart = Restart::get_restart_file(&config);
if restart.is_none() {
// If we were able to load a restart file from the previous run, then don't wipe the accounts index drives from last time.
// Unused files will be wiped by `get_restartable_buckets`
if let Some(drives) = config.drives.as_ref() {
Self::erase_previous_drives(drives);
}
}
let stats = Arc::default();
let restart = Restart::new(&config);
if restart.is_none() {
restart = Restart::new(&config);
}
let mut temp_dir = None;
let drives = config.drives.unwrap_or_else(|| {
@ -129,7 +137,8 @@ impl<T: Clone + Copy + Debug + PartialEq> BucketMap<T> {
max_buckets_pow2: log2(config.max_buckets) as u8,
stats,
temp_dir,
erase_drives_on_drop: true,
// if we are keeping track of restart, then don't wipe the drives on drop
erase_drives_on_drop: restart.is_none(),
}
}