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

Commit 897adb2

Browse files
authored
Update the directory naming for incorrect shred version backup (#35158)
The directory is currently named with the expected_shred_version; however, the backup contains shreds that do NOT match the expected_shred_version. So, use the found (incorrect) shred version in the name instead.
1 parent bf1becb commit 897adb2

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

core/src/validator.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2097,12 +2097,13 @@ fn maybe_warp_slot(
20972097
Ok(())
20982098
}
20992099

2100-
/// Searches the blockstore for data shreds with the incorrect shred version.
2101-
fn blockstore_contains_bad_shred_version(
2100+
/// Searches the blockstore for data shreds with a shred version that differs
2101+
/// from the passed `expected_shred_version`
2102+
fn blockstore_contains_incorrect_shred_version(
21022103
blockstore: &Blockstore,
21032104
start_slot: Slot,
21042105
expected_shred_version: u16,
2105-
) -> Result<bool, BlockstoreError> {
2106+
) -> Result<Option<u16>, BlockstoreError> {
21062107
const TIMEOUT: Duration = Duration::from_secs(60);
21072108
let timer = Instant::now();
21082109
// Search for shreds with incompatible version in blockstore
@@ -2113,15 +2114,15 @@ fn blockstore_contains_bad_shred_version(
21132114
let shreds = blockstore.get_data_shreds_for_slot(slot, 0)?;
21142115
for shred in &shreds {
21152116
if shred.version() != expected_shred_version {
2116-
return Ok(true);
2117+
return Ok(Some(shred.version()));
21172118
}
21182119
}
21192120
if timer.elapsed() > TIMEOUT {
21202121
info!("Didn't find incorrect shreds after 60 seconds, aborting");
21212122
break;
21222123
}
21232124
}
2124-
Ok(false)
2125+
Ok(None)
21252126
}
21262127

21272128
/// If the blockstore contains any shreds with the incorrect shred version,
@@ -2134,10 +2135,13 @@ fn backup_and_clear_blockstore(
21342135
) -> Result<(), BlockstoreError> {
21352136
let blockstore =
21362137
Blockstore::open_with_options(ledger_path, blockstore_options_from_config(config))?;
2137-
let do_copy_and_clear =
2138-
blockstore_contains_bad_shred_version(&blockstore, start_slot, expected_shred_version)?;
2138+
let incorrect_shred_version = blockstore_contains_incorrect_shred_version(
2139+
&blockstore,
2140+
start_slot,
2141+
expected_shred_version,
2142+
)?;
21392143

2140-
if do_copy_and_clear {
2144+
if let Some(incorrect_shred_version) = incorrect_shred_version {
21412145
// .unwrap() safe because getting to this point implies blockstore has slots/shreds
21422146
let end_slot = blockstore.highest_slot()?.unwrap();
21432147

@@ -2149,7 +2153,7 @@ fn backup_and_clear_blockstore(
21492153
.ledger_column_options
21502154
.shred_storage_type
21512155
.blockstore_directory(),
2152-
expected_shred_version,
2156+
incorrect_shred_version,
21532157
start_slot,
21542158
end_slot
21552159
);

0 commit comments

Comments
 (0)