Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refetch store len to be safe against rollbacks #771

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions iris-mpc/src/bin/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,10 @@ async fn server_main(config: Config) -> eyre::Result<()> {

let mut stream = select_all(vec![stream_s3, stream_db]);

// fetch again in case we rolled back storage
let store_len = store.count_irises().await?;
let max_serial_id = store.get_max_serial_id().await?;

let now = Instant::now();
let mut now_load_summary = Instant::now();
let mut time_waiting_for_stream = time::Duration::from_secs(0);
Expand All @@ -1021,6 +1025,18 @@ async fn server_main(config: Config) -> eyre::Result<()> {
iris
}
IrisSource::S3(iris) => {
// Do not load possibly rolled back items from S3
if iris.id() > max_serial_id as i64 {
tracing::warn!(
"Skip loading record from S3 with serial_id: {} > \
max_serial_id: {}",
iris.id(),
max_serial_id,
);
continue;
}

// Do not override record already loaded from DB with S3 record
if serial_ids_from_db.contains(&iris.id()) {
tracing::warn!(
"Skip overriding record already loaded via DB with S3 \
Expand Down
Loading