Skip to content

Commit 6bbc596

Browse files
committed
store: Asyncify advisory_lock::lock
1 parent f093799 commit 6bbc596

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

store/postgres/src/advisory_lock.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Scope {
5353

5454
/// Lock the deployment in this scope with the given id. Blocks until we
5555
/// can get the lock
56-
fn lock(&self, conn: &mut PgConnection, id: DeploymentId) -> Result<(), StoreError> {
56+
async fn lock(&self, conn: &mut PgConnection, id: DeploymentId) -> Result<(), StoreError> {
5757
sql_query(format!("select pg_advisory_lock({}, {id})", self.id))
5858
.execute(conn)
5959
.map(|_| ())
@@ -102,8 +102,8 @@ where
102102

103103
/// Take the lock used to keep two copy operations to run simultaneously on
104104
/// the same deployment. Block until we can get the lock
105-
pub(crate) fn lock_copying(conn: &mut PgConnection, dst: &Site) -> Result<(), StoreError> {
106-
COPY.lock(conn, dst.id)
105+
pub(crate) async fn lock_copying(conn: &mut PgConnection, dst: &Site) -> Result<(), StoreError> {
106+
COPY.lock(conn, dst.id).await
107107
}
108108

109109
/// Release the lock acquired with `lock_copying`.

store/postgres/src/copy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -701,12 +701,12 @@ impl LockTrackingConnection {
701701
}
702702
}
703703

704-
fn lock(&mut self, logger: &Logger, dst: &Site) -> Result<(), StoreError> {
704+
async fn lock(&mut self, logger: &Logger, dst: &Site) -> Result<(), StoreError> {
705705
if self.has_lock {
706706
warn!(logger, "already acquired copy lock for {}", dst);
707707
return Ok(());
708708
}
709-
advisory_lock::lock_copying(&mut self.inner, dst)?;
709+
advisory_lock::lock_copying(&mut self.inner, dst).await?;
710710
self.has_lock = true;
711711
Ok(())
712712
}
@@ -1311,7 +1311,7 @@ impl Connection {
13111311
let Some(conn) = self.conn.as_mut() else {
13121312
return Err(internal_error!("copy connection went missing (copy_data)"));
13131313
};
1314-
conn.lock(&self.logger, &dst_site)?;
1314+
conn.lock(&self.logger, &dst_site).await?;
13151315

13161316
let res = self.copy_data_internal(index_list).await;
13171317

0 commit comments

Comments
 (0)