Skip to content

Commit e550dd0

Browse files
committed
Auto merge of #2192 - jtgeibel:prod/revert-2157, r=jtgeibel
Revert changes to update_downloads task in #2157 It appears that the additional wrapper transaction added around the update_downloads task causes delays and timeouts to download requests whenever the background job is run. Reverting so that master can be deployed. r? @ghost
2 parents cf6e9a8 + 5aef9e7 commit e550dd0

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

src/tasks.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,3 @@ mod update_downloads;
33

44
pub use dump_db::dump_db;
55
pub use update_downloads::update_downloads;
6-
7-
use diesel::sql_types::BigInt;
8-
sql_function!(fn pg_try_advisory_xact_lock(key: BigInt) -> Bool);
9-
10-
const UPDATE_DOWNLOADS_ADVISORY_LOCK_KEY: i64 = 1;

src/tasks/update_downloads.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use super::pg_try_advisory_xact_lock;
2-
use super::UPDATE_DOWNLOADS_ADVISORY_LOCK_KEY as LOCK_KEY;
31
use crate::{
42
background_jobs::Environment,
53
models::VersionDownload,
@@ -11,17 +9,9 @@ use swirl::PerformError;
119

1210
#[swirl::background_job]
1311
pub fn update_downloads(env: &Environment) -> Result<(), PerformError> {
14-
use diesel::select;
15-
1612
let conn = env.connection()?;
17-
conn.transaction::<_, PerformError, _>(|| {
18-
// If this job runs concurrently with itself, it could result in a overcount
19-
if !select(pg_try_advisory_xact_lock(LOCK_KEY)).get_result(&*conn)? {
20-
return Err("The advisory lock for update_downloads is already taken".into());
21-
}
22-
23-
update(&conn).map_err(Into::into)
24-
})
13+
update(&conn)?;
14+
Ok(())
2515
}
2616

2717
fn update(conn: &PgConnection) -> QueryResult<()> {

0 commit comments

Comments
 (0)