From: Alexander Korotkov Date: Wed, 3 Apr 2024 08:23:21 +0000 (+0300) Subject: Minor improvements for waitlsn.c X-Git-Tag: REL_17_BETA1~433 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e37662f221;p=thirdparty%2Fpostgresql.git 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 --- 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 #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);