Skip to content

Commit d7f2232

Browse files
authored
Merge pull request #1954 from tursodatabase/fix-busy-timeouts
Fix busy timeouts
2 parents 4c7ed18 + f402441 commit d7f2232

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

libsql-server/src/connection/connection_core.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::ffi::{c_int, c_void};
21
use std::path::{Path, PathBuf};
32
use std::sync::atomic::{AtomicBool, Ordering};
43
use std::sync::Arc;
@@ -88,18 +87,6 @@ impl<W: Wal + Send + 'static> CoreConnection<W> {
8887
config.max_row_size as i32,
8988
);
9089

91-
unsafe {
92-
const MAX_RETRIES: c_int = 8;
93-
extern "C" fn do_nothing(_: *mut c_void, n: c_int) -> c_int {
94-
(n < MAX_RETRIES) as _
95-
}
96-
libsql_sys::ffi::sqlite3_busy_handler(
97-
conn.handle(),
98-
Some(do_nothing),
99-
std::ptr::null_mut(),
100-
);
101-
}
102-
10390
let canceled = Arc::new(AtomicBool::new(false));
10491

10592
conn.progress_handler(100, {

libsql-server/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ where
383383
}
384384
retry = match connection_maker.untracked().await {
385385
Ok(conn) => {
386+
conn.with_raw(|c| c.busy_timeout(std::time::Duration::from_secs(5)))?;
386387
if let Err(e) = conn.vacuum_if_needed().await {
387388
tracing::warn!("vacuum failed: {}", e);
388389
}

libsql-sys/src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<W: Wal> Connection<W> {
266266
}
267267
}
268268

269-
conn.busy_timeout(std::time::Duration::from_secs(5000))?;
269+
conn.busy_timeout(std::time::Duration::from_millis(100))?;
270270

271271
conn
272272
};

0 commit comments

Comments
 (0)