]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix variable usage in wakeupWaiters()
authorAlexander Korotkov <akorotkov@postgresql.org>
Tue, 6 Jan 2026 08:03:26 +0000 (10:03 +0200)
committerAlexander Korotkov <akorotkov@postgresql.org>
Tue, 6 Jan 2026 08:04:28 +0000 (10:04 +0200)
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 <thomas.munro@gmail.com>
Reviewed-by: Ruikai Peng <ruikai@pwno.io>
src/backend/access/transam/xlogwait.c

index 5020ae1e52d4ea596c348a1b9b8c74ddaf94c21b..cab7e5082dc0a7812fc60a77aae14747cb041898 100644 (file)
@@ -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);
 }