Skip to content

Commit ec0dcd2

Browse files
yihong0618Xuanwo
andauthored
fix: sqlite may dead lock in ci (#5738)
* fix: sqlite may dead lock in ci Signed-off-by: yihong0618 <[email protected]> * fix: lint things Signed-off-by: yihong0618 <[email protected]> * fix: use temp error and add co-author Signed-off-by: yihong0618 <[email protected]> Co-authored-by: Xuanwo <[email protected]> * fix: lint Signed-off-by: yihong0618 <[email protected]> * fix: address comments and make the code simple and easy to understand Signed-off-by: yihong0618 <[email protected]> * fix: happy the clippy Signed-off-by: yihong0618 <[email protected]> --------- Signed-off-by: yihong0618 <[email protected]> Co-authored-by: Xuanwo <[email protected]>
1 parent 41b2f82 commit ec0dcd2

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

core/src/services/sqlite/backend.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,20 @@ impl kv::Adapter for Adapter {
308308
}
309309

310310
fn parse_sqlite_error(err: sqlx::Error) -> Error {
311-
Error::new(ErrorKind::Unexpected, "unhandled error from sqlite").set_source(err)
311+
let is_temporary = matches!(
312+
&err,
313+
sqlx::Error::Database(db_err) if db_err.code().is_some_and(|c| c == "5" || c == "6")
314+
);
315+
316+
let message = if is_temporary {
317+
"database is locked or busy"
318+
} else {
319+
"unhandled error from sqlite"
320+
};
321+
322+
let mut error = Error::new(ErrorKind::Unexpected, message).set_source(err);
323+
if is_temporary {
324+
error = error.set_temporary();
325+
}
326+
error
312327
}

0 commit comments

Comments
 (0)