From: Alexander Korotkov Date: Tue, 6 Jan 2026 08:03:26 +0000 (+0200) Subject: Fix variable usage in wakeupWaiters() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf308639bfcfa38541e24733e074184153a8ab7f;p=thirdparty%2Fpostgresql.git Fix variable usage in wakeupWaiters() Mistakenly, `i` was used both as an integer representation of lsnType and an index in wakeUpProcs array. Discussion: https://postgr.es/m/CA%2BhUKG%2BL0OQR8dQtsNBSaA3FNNyQeFabdeRVzurm0b7Xtp592g%40mail.gmail.com Reviewed-by: Thomas Munro Reviewed-by: Ruikai Peng --- diff --git a/src/backend/access/transam/xlogwait.c b/src/backend/access/transam/xlogwait.c index 5020ae1e52d..cab7e5082dc 100644 --- a/src/backend/access/transam/xlogwait.c +++ b/src/backend/access/transam/xlogwait.c @@ -264,6 +264,8 @@ wakeupWaiters(WaitLSNType lsnType, XLogRecPtr currentLSN) do { + int j; + numWakeUpProcs = 0; LWLockAcquire(WaitLSNLock, LW_EXCLUSIVE); @@ -303,8 +305,8 @@ wakeupWaiters(WaitLSNType lsnType, XLogRecPtr currentLSN) * at worst we may set a latch for the wrong process or for no process * at all, which is harmless. */ - for (i = 0; i < numWakeUpProcs; i++) - SetLatch(&GetPGProcByNumber(wakeUpProcs[i])->procLatch); + for (j = 0; j < numWakeUpProcs; j++) + SetLatch(&GetPGProcByNumber(wakeUpProcs[j])->procLatch); } while (numWakeUpProcs == WAKEUP_PROC_STATIC_ARRAY_SIZE); }