Skip to content

Commit

Permalink
Merge pull request #1869 from tursodatabase/lucio/try-pull-err
Browse files Browse the repository at this point in the history
libsql: Clean up error handling in try_pull
  • Loading branch information
penberg authored Dec 6, 2024
2 parents 223c853 + 019c2ce commit 105748d
Showing 1 changed file with 14 additions and 6 deletions.
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

0 comments on commit 105748d

Please sign in to comment.