Skip to content

Commit 75c0b0b

Browse files
committed
store: Asyncify advisory_lock::unlock
1 parent 6bbc596 commit 75c0b0b

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

store/postgres/src/advisory_lock.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl Scope {
6161
}
6262

6363
/// Unlock the deployment in this scope with the given id.
64-
fn unlock(&self, conn: &mut PgConnection, id: DeploymentId) -> Result<(), StoreError> {
64+
async fn unlock(&self, conn: &mut PgConnection, id: DeploymentId) -> Result<(), StoreError> {
6565
sql_query(format!("select pg_advisory_unlock({}, {id})", self.id))
6666
.execute(conn)
6767
.map(|_| ())
@@ -107,8 +107,8 @@ pub(crate) async fn lock_copying(conn: &mut PgConnection, dst: &Site) -> Result<
107107
}
108108

109109
/// Release the lock acquired with `lock_copying`.
110-
pub(crate) fn unlock_copying(conn: &mut PgConnection, dst: &Site) -> Result<(), StoreError> {
111-
COPY.unlock(conn, dst.id)
110+
pub(crate) async fn unlock_copying(conn: &mut PgConnection, dst: &Site) -> Result<(), StoreError> {
111+
COPY.unlock(conn, dst.id).await
112112
}
113113

114114
/// Take the lock used to keep two operations from writing to the deployment
@@ -123,11 +123,11 @@ pub(crate) async fn lock_deployment_session(
123123
}
124124

125125
/// Release the lock acquired with `lock_deployment_session`.
126-
pub(crate) fn unlock_deployment_session(
126+
pub(crate) async fn unlock_deployment_session(
127127
conn: &mut PgConnection,
128128
site: &Site,
129129
) -> Result<(), StoreError> {
130-
WRITE.unlock(conn, site.id)
130+
WRITE.unlock(conn, site.id).await
131131
}
132132

133133
/// Try to take the lock used to prevent two prune operations from running at the
@@ -139,6 +139,6 @@ pub(crate) async fn try_lock_pruning(
139139
PRUNE.try_lock(conn, site.id).await
140140
}
141141

142-
pub(crate) fn unlock_pruning(conn: &mut PgConnection, site: &Site) -> Result<(), StoreError> {
143-
PRUNE.unlock(conn, site.id)
142+
pub(crate) async fn unlock_pruning(conn: &mut PgConnection, site: &Site) -> Result<(), StoreError> {
143+
PRUNE.unlock(conn, site.id).await
144144
}

store/postgres/src/copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,15 +711,15 @@ impl LockTrackingConnection {
711711
Ok(())
712712
}
713713

714-
fn unlock(&mut self, logger: &Logger, dst: &Site) -> Result<(), StoreError> {
714+
async fn unlock(&mut self, logger: &Logger, dst: &Site) -> Result<(), StoreError> {
715715
if !self.has_lock {
716716
error!(
717717
logger,
718718
"tried to release copy lock for {} even though we are not the owner", dst
719719
);
720720
return Ok(());
721721
}
722-
advisory_lock::unlock_copying(&mut self.inner, dst)?;
722+
advisory_lock::unlock_copying(&mut self.inner, dst).await?;
723723
self.has_lock = false;
724724
Ok(())
725725
}
@@ -1327,7 +1327,7 @@ impl Connection {
13271327
);
13281328
}
13291329
Some(conn) => {
1330-
conn.unlock(&self.logger, &dst_site)?;
1330+
conn.unlock(&self.logger, &dst_site).await?;
13311331
}
13321332
}
13331333

store/postgres/src/deployment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,6 @@ where
13961396
backoff.sleep();
13971397
}
13981398
let res = f(conn).await;
1399-
advisory_lock::unlock_deployment_session(conn, site)?;
1399+
advisory_lock::unlock_deployment_session(conn, site).await?;
14001400
res
14011401
}

store/postgres/src/deployment_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ impl DeploymentStore {
896896
// kick off a pruning run while this node might still be pruning
897897
if advisory_lock::try_lock_pruning(conn, &site).await? {
898898
let res = do_prune(store, conn, site.cheap_clone(), cancel, req, reporter).await;
899-
advisory_lock::unlock_pruning(conn, &site)?;
899+
advisory_lock::unlock_pruning(conn, &site).await?;
900900
res
901901
} else {
902902
Ok(reporter)

0 commit comments

Comments
 (0)