Move LSN waiting declarations and definitions to better place
authorAlexander Korotkov <[email protected]>
Thu, 24 Oct 2024 11:37:53 +0000 (14:37 +0300)
committerAlexander Korotkov <[email protected]>
Thu, 24 Oct 2024 11:37:53 +0000 (14:37 +0300)
3c5db1d6b implemented the pg_wal_replay_wait() stored procedure.  Due to
the  development history, the implementation resided in
src/backend/commands/waitlsn.c (src/include/commands/waitlsn.h for headers).

014f9f34d moved pg_wal_replay_wait() itself to
src/backend/access/transam/xlogfuncs.c near to the WAL-manipulation functions.
But most of the implementation stayed in place.

The code in src/backend/commands/waitlsn.c has nothing to do with commands,
but is related to WAL.  So, this commit moves this code into
src/backend/access/transam/xlogwait.c (src/include/access/xlogwait.h for
headers).

Reported-by: Peter Eisentraut
Discussion: https://postgr.es/m/18c0fa64-0475-415e-a1bd-665d922c5201%40eisentraut.org
Reviewed-by: Pavel Borisov
12 files changed:
src/backend/access/transam/Makefile
src/backend/access/transam/meson.build
src/backend/access/transam/xact.c
src/backend/access/transam/xlog.c
src/backend/access/transam/xlogfuncs.c
src/backend/access/transam/xlogrecovery.c
src/backend/access/transam/xlogwait.c[moved from src/backend/commands/waitlsn.c with 99% similarity]
src/backend/commands/Makefile
src/backend/commands/meson.build
src/backend/storage/ipc/ipci.c
src/backend/storage/lmgr/proc.c
src/include/access/xlogwait.h[moved from src/include/commands/waitlsn.h with 94% similarity]

index 661c55a9db789760b8ec95e22b1d02922d3a2671..a32f473e0a22bd4b4ca8e42d0dacf25e21a2362e 100644 (file)
@@ -36,7 +36,8 @@ OBJS = \
    xlogreader.o \
    xlogrecovery.o \
    xlogstats.o \
-   xlogutils.o
+   xlogutils.o \
+   xlogwait.o
 
 include $(top_srcdir)/src/backend/common.mk
 
index 8a3522557cd904f90ace3c339c74ad293d1c9844..91d258f9df125461726cc50a4919e92624c0bb08 100644 (file)
@@ -24,6 +24,7 @@ backend_sources += files(
   'xlogrecovery.c',
   'xlogstats.c',
   'xlogutils.c',
+  'xlogwait.c',
 )
 
 # used by frontend programs to build a frontend xlogreader
index b0b05e287908d8b7432d12fad82b5207e69fe5d5..d8f6c6584208c0e7a61151589f6c1eef3e83ad08 100644 (file)
@@ -31,6 +31,7 @@
 #include "access/xloginsert.h"
 #include "access/xlogrecovery.h"
 #include "access/xlogutils.h"
+#include "access/xlogwait.h"
 #include "catalog/index.h"
 #include "catalog/namespace.h"
 #include "catalog/pg_enum.h"
@@ -38,7 +39,6 @@
 #include "commands/async.h"
 #include "commands/tablecmds.h"
 #include "commands/trigger.h"
-#include "commands/waitlsn.h"
 #include "common/pg_prng.h"
 #include "executor/spi.h"
 #include "libpq/be-fsstubs.h"
index 9102c8d772e7129152ad1a541cf5962474e74c03..ad9b0b612f4a36ed4fcc0932da432443eb380cf7 100644 (file)
 #include "access/xlogreader.h"
 #include "access/xlogrecovery.h"
 #include "access/xlogutils.h"
+#include "access/xlogwait.h"
 #include "backup/basebackup.h"
 #include "catalog/catversion.h"
 #include "catalog/pg_control.h"
 #include "catalog/pg_database.h"
-#include "commands/waitlsn.h"
 #include "common/controldata_utils.h"
 #include "common/file_utils.h"
 #include "executor/instrument.h"
index 3e3d2bb61895de8c859b7701f5d448798e5b93fe..cbf84ef7d8f7478b681bf1c154d5cd8919f96ba0 100644 (file)
@@ -22,8 +22,8 @@
 #include "access/xlog_internal.h"
 #include "access/xlogbackup.h"
 #include "access/xlogrecovery.h"
+#include "access/xlogwait.h"
 #include "catalog/pg_type.h"
-#include "commands/waitlsn.h"
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "pgstat.h"
index 320b14add1ad9a575f7f25c5b68b9d7663744e84..31caa49d6c30883ff1ad3f11f9f2fa570f19bf41 100644 (file)
 #include "access/xlogreader.h"
 #include "access/xlogrecovery.h"
 #include "access/xlogutils.h"
+#include "access/xlogwait.h"
 #include "backup/basebackup.h"
 #include "catalog/pg_control.h"
 #include "commands/tablespace.h"
-#include "commands/waitlsn.h"
 #include "common/file_utils.h"
 #include "miscadmin.h"
 #include "pgstat.h"
similarity index 99%
rename from src/backend/commands/waitlsn.c
rename to src/backend/access/transam/xlogwait.c
index 501938f4330712b5ae7bde79585dad353cf302cf..eef58ce69ced4b3a8193226e818d8b1d533b26b0 100644 (file)
@@ -1,13 +1,13 @@
 /*-------------------------------------------------------------------------
  *
- * waitlsn.c
+ * xlogwait.c
  *   Implements waiting for the given replay LSN, which is used in
  *   CALL pg_wal_replay_wait(target_lsn pg_lsn, timeout float8).
  *
  * Copyright (c) 2024, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *   src/backend/commands/waitlsn.c
+ *   src/backend/access/transam/xlogwait.c
  *
  *-------------------------------------------------------------------------
  */
@@ -20,7 +20,7 @@
 #include "pgstat.h"
 #include "access/xlog.h"
 #include "access/xlogrecovery.h"
-#include "commands/waitlsn.h"
+#include "access/xlogwait.h"
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "storage/latch.h"
index cede90c3b98c0282aaef9d9a87bd64d3478a40fd..48f7348f91c72274edda9723f42ccc7f246917d6 100644 (file)
@@ -61,7 +61,6 @@ OBJS = \
    vacuum.o \
    vacuumparallel.o \
    variable.o \
-   view.o \
-   waitlsn.o
+   view.o
 
 include $(top_srcdir)/src/backend/common.mk
index 7549be5dc3b75b8135556da80e07b3585d8d4b2b..6dd00a4abdeaf625e65103679d37d932fecc98b4 100644 (file)
@@ -50,5 +50,4 @@ backend_sources += files(
   'vacuumparallel.c',
   'variable.c',
   'view.c',
-  'waitlsn.c',
 )
index 10fc18f252943859434dc3708b44e686e1797b5d..9ff687045f41e02a2133cff40940eac9555efaee 100644 (file)
@@ -24,8 +24,8 @@
 #include "access/twophase.h"
 #include "access/xlogprefetcher.h"
 #include "access/xlogrecovery.h"
+#include "access/xlogwait.h"
 #include "commands/async.h"
-#include "commands/waitlsn.h"
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "postmaster/autovacuum.h"
index eaf3916f282305f7dde80c19e7e2fafc0bdfd1a8..260e7029f5039d6fe05e3bf6ef6f61b14ee4dc3e 100644 (file)
@@ -36,7 +36,7 @@
 #include "access/transam.h"
 #include "access/twophase.h"
 #include "access/xlogutils.h"
-#include "commands/waitlsn.h"
+#include "access/xlogwait.h"
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "postmaster/autovacuum.h"
similarity index 94%
rename from src/include/commands/waitlsn.h
rename to src/include/access/xlogwait.h
index bb5ac858dcc8765c212dfc60bbb9b893c7c0f6bf..31e208cb7ade41595eaed3a31091dbaa7f48ffe5 100644 (file)
@@ -1,16 +1,16 @@
 /*-------------------------------------------------------------------------
  *
- * waitlsn.h
+ * xlogwait.h
  *   Declarations for LSN replay waiting routines.
  *
  * Copyright (c) 2024, PostgreSQL Global Development Group
  *
- * src/include/commands/waitlsn.h
+ * src/include/access/xlogwait.h
  *
  *-------------------------------------------------------------------------
  */
-#ifndef WAIT_LSN_H
-#define WAIT_LSN_H
+#ifndef XLOG_WAIT_H
+#define XLOG_WAIT_H
 
 #include "lib/pairingheap.h"
 #include "postgres.h"
@@ -78,4 +78,4 @@ extern void WaitLSNSetLatches(XLogRecPtr currentLSN);
 extern void WaitLSNCleanup(void);
 extern void WaitForLSNReplay(XLogRecPtr targetLSN, int64 timeout);
 
-#endif                         /* WAIT_LSN_H */
+#endif                         /* XLOG_WAIT_H */