From 55ea67d3438e646235b456ba3ebfc76cebde7a23 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 14 Mar 2024 01:02:55 +0100 Subject: [PATCH] fix: show current pid before acquiring lock --- backend/windmill-api/src/db.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/backend/windmill-api/src/db.rs b/backend/windmill-api/src/db.rs index 5d03dabbdd..eb8939e447 100644 --- a/backend/windmill-api/src/db.rs +++ b/backend/windmill-api/src/db.rs @@ -48,11 +48,15 @@ impl Migrate for CustomMigrator { &mut self, ) -> futures::prelude::future::BoxFuture<'_, Result<(), sqlx::migrate::MigrateError>> { async { - tracing::info!("Acquiring global PG lock for migration purposes (if there are migrations to apply, will apply migrations or wait for the first acquirer of the lock to apply them)"); + let pid = sqlx::query_scalar!("SELECT pg_backend_pid()") + .fetch_one(&mut *self.inner) + .await?; + tracing::info!("Acquiring global PG lock for potential migration with pid: {pid:?}"); let r = self.inner.lock().await; - tracing::info!("Acquired global PG lock for migration purposes"); + tracing::info!("Acquired global PG lock"); r - }.boxed() + } + .boxed() } fn unlock( @@ -63,8 +67,8 @@ impl Migrate for CustomMigrator { let r = self.inner.unlock().await; tracing::info!("Released PG lock"); r - }.boxed() - + } + .boxed() } fn apply<'e: 'm, 'm>( @@ -83,7 +87,8 @@ impl Migrate for CustomMigrator { let r = self.inner.apply(migration).await; tracing::info!("Finished applying migration {}", migration.version); r - }.boxed() + } + .boxed() } fn revert<'e: 'm, 'm>(