mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-05 01:43:48 +00:00
fix: sqlx::macro db cleanup race condition by adding a margin to current timestamp (#2640)
* fix: sqlx::macro db cleanup race condition by adding a margin to current timestamp * feat: increase margin to 2 seconds
This commit is contained in:
committed by
GitHub
parent
5ebe296ecb
commit
3c2471e2dc
@@ -183,7 +183,8 @@ async fn test_context(args: &TestArgs) -> Result<TestContext<Postgres>, Error> {
|
||||
}
|
||||
|
||||
async fn do_cleanup(conn: &mut PgConnection, created_before: Duration) -> Result<usize, Error> {
|
||||
let created_before = i64::try_from(created_before.as_secs()).unwrap();
|
||||
// since SystemTime is not monotonic we added a little margin here to avoid race conditions with other threads
|
||||
let created_before = i64::try_from(created_before.as_secs()).unwrap() - 2;
|
||||
|
||||
let delete_db_names: Vec<String> = query_scalar(
|
||||
"select db_name from _sqlx_test.databases \
|
||||
|
||||
Reference in New Issue
Block a user