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

Ignore CHECKPOINT errors for DuckDB #107

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions src/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ pub enum Error {
#[snafu(display("Unable to commit transaction: {source}"))]
UnableToCommitTransaction { source: duckdb::Error },

#[snafu(display("Unable to checkpoint duckdb: {source}"))]
UnableToCheckpoint {
source: Box<dyn std::error::Error + Send + Sync>,
},

#[snafu(display("Unable to begin duckdb transaction: {source}"))]
UnableToBeginTransaction { source: duckdb::Error },

Expand Down
11 changes: 7 additions & 4 deletions src/duckdb/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,15 @@ impl DataSink for DuckDBDataSink {

match duckdb_write_handle.await {
Ok(result) => {
// before returning the result, CHECKPOINT to flush the WAL to disk
// before returning the result, attempt to CHECKPOINT to flush the WAL to disk
let mut conn = self.duckdb.connect_sync().map_err(to_datafusion_error)?;
let conn = DuckDB::duckdb_conn(&mut conn).map_err(to_datafusion_error)?;
conn.execute("CHECKPOINT", &[]).map_err(|err| {
to_datafusion_error(super::Error::UnableToCheckpoint { source: err })
})?;

// This may fail if multiple transactions are active (i.e. actively writing data)
// we can ignore the error since it will be written once the last transaction finishes.
if let Err(e) = conn.execute("CHECKPOINT", &[]) {
tracing::trace!("DuckDB CHECKPOINT failed - this is expected if there are multiple active transactions: {e}");
};

result
}
Expand Down