From c848bc456e351ade0ecadd5ef8ee07a618eedc25 Mon Sep 17 00:00:00 2001 From: Suhas Thalanki Date: Thu, 19 Mar 2026 17:40:58 -0700 Subject: [PATCH 1/2] give startup process in replica priority to apply locks --- src/backend/storage/lmgr/lwlock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index ba664df7cce..81676644ffa 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -79,6 +79,7 @@ #include "miscadmin.h" #include "pg_trace.h" #include "pgstat.h" +#include "access/xlogrecovery.h" #include "port/pg_bitutils.h" #include "postmaster/postmaster.h" #include "storage/proc.h" @@ -1057,7 +1058,7 @@ LWLockQueueSelf(LWLock *lock, LWLockMode mode) MyProc->lwWaitMode = mode; /* LW_WAIT_UNTIL_FREE waiters are always at the front of the queue */ - if (mode == LW_WAIT_UNTIL_FREE) + if (mode == LW_WAIT_UNTIL_FREE || (AmStartupProcess() && StandbyMode)) proclist_push_head(&lock->waiters, MyProcNumber, lwWaitLink); else proclist_push_tail(&lock->waiters, MyProcNumber, lwWaitLink); From 75d8f5b0acbecdf608b98d21ec5a9b847230507e Mon Sep 17 00:00:00 2001 From: Suhas Thalanki Date: Mon, 23 Mar 2026 11:15:51 -0700 Subject: [PATCH 2/2] remove unnecessary standby mode check --- src/backend/storage/lmgr/lwlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 81676644ffa..e9061cab7a6 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -1058,7 +1058,7 @@ LWLockQueueSelf(LWLock *lock, LWLockMode mode) MyProc->lwWaitMode = mode; /* LW_WAIT_UNTIL_FREE waiters are always at the front of the queue */ - if (mode == LW_WAIT_UNTIL_FREE || (AmStartupProcess() && StandbyMode)) + if (mode == LW_WAIT_UNTIL_FREE || AmStartupProcess()) proclist_push_head(&lock->waiters, MyProcNumber, lwWaitLink); else proclist_push_tail(&lock->waiters, MyProcNumber, lwWaitLink);