Skip to content
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
20 changes: 19 additions & 1 deletion client/db/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ where
maybe_error = false;
}
}
} else {
// If version 2 data, we just consider this hash a success.
// This can happen if the process was closed in the middle of the migration.
res.success += 1;
maybe_error = false;
}
}
if maybe_error {
Expand All @@ -213,6 +218,12 @@ where
}
db.write(transaction)
.map_err(|_| io::Error::new(ErrorKind::Other, "Failed to commit on migrate_1_to_2"))?;
log::debug!(
target: "fc-db-upgrade",
"🔨 Success {}, error {}.",
res.success,
res.error.len()
);
Ok(())
};

Expand All @@ -228,8 +239,15 @@ where
// Read and update each entry in db transaction batches
const CHUNK_SIZE: usize = 10_000;
let chunks = ethereum_hashes.chunks(CHUNK_SIZE);
for chunk in chunks {
let all_len = ethereum_hashes.len();
for (i, chunk) in chunks.enumerate() {
process_chunk(&db, chunk)?;
log::debug!(
target: "fc-db-upgrade",
"🔨 Processed {} of {} entries.",
(CHUNK_SIZE * (i + 1)),
all_len
);
}
Ok(res)
}
Expand Down