postgres.git / summary / log / commit / refs

commit    e37662f22158c29bc55eda4eda1757f444cf701a
Author:   Alexander Korotkov <akorotkov@postgresql.org>
Date:     Wed Apr 03 08:23:21 2024 +0000

    Minor improvements for waitlsn.c
    
     * Remove extra includes
     * Fill 'cur' in addLSNWaiter() before taking the spinlock
     * Initialize 'endtime' with zero in WaitForLSN() to avoid compiler warning
    
    Reported-by: Alvaro Herrera, Masahiko Sawada, Daniel Gustafsson
    Discussion: https://postgr.es/m/202404030658.hhj3vfxeyhft%40alvherre.pgsql
    Discussion: https://postgr.es/m/CAD21AoAx7irptnPH1OkkkNh9E0M6X-phfX7sYZfwoMsc1qV1sQ%40mail.gmail.com


src/backend/commands/waitlsn.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/backend/commands/waitlsn.c b/src/backend/commands/waitlsn.c index 6679378156c..63e9ebf1730 100644 --- a/src/backend/commands/waitlsn.c +++ b/src/backend/commands/waitlsn.c @@ -18,28 +18,18 @@ #include <math.h> #include "pgstat.h" -#include "fmgr.h" -#include "access/transam.h" -#include "access/xact.h" #include "access/xlog.h" -#include "access/xlogdefs.h" #include "access/xlogrecovery.h" -#include "catalog/pg_type.h" #include "commands/waitlsn.h" -#include "executor/spi.h" #include "funcapi.h" #include "miscadmin.h" -#include "storage/ipc.h" #include "storage/latch.h" -#include "storage/pmsignal.h" #include "storage/proc.h" #include "storage/shmem.h" -#include "storage/sinvaladt.h" -#include "utils/builtins.h" #include "utils/pg_lsn.h" #include "utils/snapmgr.h" -#include "utils/timestamp.h" #include "utils/fmgrprotos.h" +#include "utils/wait_event_types.h" /* Add to / delete from shared memory array */ static void addLSNWaiter(XLogRecPtr lsn); @@ -88,11 +78,11 @@ addLSNWaiter(XLogRecPtr lsn) WaitLSNProcInfo cur; int i; - SpinLockAcquire(&waitLSN->mutex); - cur.procnum = MyProcNumber; cur.waitLSN = lsn; + SpinLockAcquire(&waitLSN->mutex); + for (i = 0; i < waitLSN->numWaitedProcs; i++) { if (waitLSN->procInfos[i].waitLSN >= cur.waitLSN) @@ -226,7 +216,7 @@ void WaitForLSN(XLogRecPtr targetLSN, int64 timeout) { XLogRecPtr currentLSN; - TimestampTz endtime; + TimestampTz endtime = 0; /* Shouldn't be called when shmem isn't initialized */ Assert(waitLSN); [parent: 9301308bd196]