summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2023-06-30 01:45:33 -0700
committeriximeow <me@iximeow.net>2023-06-30 01:45:33 -0700
commit9de08fd8c3eb7b825153f6d2a960b18993f75616 (patch)
tree4eacbd4dad8d4c2bb81f083a37aacd5e4cd45a93 /src
parent1589853ea765f5512ea776a74535d6022812e289 (diff)
release db connection lock so as to not deadlock ci_driver
afaict holding the lock over an await point gives tokio an opportunity to run a different task - perhaps a different API request that would try acquring the db connection lock. then it deadlocks; the second task holds the thread hostage while waiting for the first task to release its lock, which it can't do due to no thread being available for it to run on.
Diffstat (limited to 'src')
-rw-r--r--src/ci_driver.rs3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ci_driver.rs b/src/ci_driver.rs
index c4a791d..0f629e7 100644
--- a/src/ci_driver.rs
+++ b/src/ci_driver.rs
@@ -71,6 +71,7 @@ async fn activate_job(dbctx: Arc<DbCtx>, job: &PendingJob, clients: &mut mpsc::R
let commit_sha: String = connection
.query_row("select sha from commits where id=?1", [job.commit_id], |row| row.get(0))
.expect("can run query");
+ std::mem::drop(connection);
let artifacts: PathBuf = match &job.artifacts {
Some(artifacts) => PathBuf::from(artifacts),
@@ -126,11 +127,13 @@ async fn activate_job(dbctx: Arc<DbCtx>, job: &PendingJob, clients: &mut mpsc::R
let run_host = client_job.client.name.clone();
+ let connection = dbctx.conn.lock().unwrap();
connection.execute(
"update jobs set started_time=?1, run_host=?2, state=1, artifacts_path=?3, build_token=?4 where id=?5",
(now as u64, run_host, format!("{}", artifacts.display()), &client_job.client.build_token, job.id)
)
.expect("can update");
+ std::mem::drop(connection);
spawn(async move {
client_job.run().await