Skip to content

Commit 0f5bc97

Browse files
authored
worker/jobs/daily_db_maintenance: Remove spawn_blocking() usage (#9653)
1 parent 9866e32 commit 0f5bc97

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/worker/jobs/daily_db_maintenance.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use crate::tasks::spawn_blocking;
21
use crate::worker::Environment;
32
use crates_io_worker::BackgroundJob;
4-
use diesel::{sql_query, RunQueryDsl};
5-
use diesel_async::async_connection_wrapper::AsyncConnectionWrapper;
3+
use diesel::sql_query;
4+
use diesel_async::RunQueryDsl;
65
use std::sync::Arc;
76

87
#[derive(Serialize, Deserialize)]
@@ -24,15 +23,13 @@ impl BackgroundJob for DailyDbMaintenance {
2423
/// archive daily download counts and drop historical data, we can drop this task and rely on
2524
/// auto-vacuum again.
2625
async fn run(&self, env: Self::Context) -> anyhow::Result<()> {
27-
let conn = env.deadpool.get().await?;
28-
spawn_blocking(move || {
29-
let conn: &mut AsyncConnectionWrapper<_> = &mut conn.into();
26+
let mut conn = env.deadpool.get().await?;
3027

31-
info!("Running VACUUM on version_downloads table");
32-
sql_query("VACUUM version_downloads;").execute(conn)?;
33-
info!("Finished running VACUUM on version_downloads table");
34-
Ok(())
35-
})
36-
.await
28+
info!("Running VACUUM on version_downloads table");
29+
sql_query("VACUUM version_downloads;")
30+
.execute(&mut conn)
31+
.await?;
32+
info!("Finished running VACUUM on version_downloads table");
33+
Ok(())
3734
}
3835
}

0 commit comments

Comments
 (0)