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

libsql: Clean up error handling in try_pull #1869

Merged
merged 1 commit into from
Dec 6, 2024
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: 14 additions & 6 deletions libsql/src/local/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,25 +471,33 @@ impl Database {
let mut frame_no = sync_ctx.durable_frame_num() + 1;
let conn = self.connect()?;
conn.wal_insert_begin()?;

let mut err = None;

loop {
match sync_ctx.pull_one_frame(generation, frame_no).await {
Ok(frame) => {
conn.wal_insert_frame(&frame)?;
frame_no += 1;
}
Err(e) => {
println!("pull_one_frame error: {:?}", e);
tracing::debug!("pull_one_frame error: {:?}", e);
err.replace(e);
break;
}
}

}
conn.wal_insert_end()?;
sync_ctx.write_metadata().await?;
Ok(crate::database::Replicated {
frame_no: None,
frames_synced: 1,
})

if let Some(err) = err {
Err(err)
} else {
Ok(crate::database::Replicated {
frame_no: None,
frames_synced: 1,
})
}
}

pub(crate) fn path(&self) -> &str {
Expand Down
Loading