Skip to content

Commit f665c42

Browse files
hlinnakaMMeent
authored andcommitted
Move walredo process code under pgxn in the main 'neon' repository.
- Refactor the way the WalProposerMain function is called when started with --sync-safekeepers. The postgres binary now explicitly loads the 'neon.so' library and calls the WalProposerMain in it. This is simpler than the global function callback "hook" we previously used. - Move the WAL redo process code to a new library, neon_walredo.so, and use the same mechanism as for --sync-safekeepers to call the WalRedoMain function, when launched with --walredo argument. - Also move the seccomp code to neon_walredo.so library. I kept the configure check in the postgres side for now, though.
1 parent fe5b81b commit f665c42

File tree

17 files changed

+50
-1226
lines changed

17 files changed

+50
-1226
lines changed

src/backend/main/main.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737

3838
#include "bootstrap/bootstrap.h"
3939
#include "common/username.h"
40+
#include "miscadmin.h"
4041
#include "port/atomics.h"
4142
#include "postmaster/postmaster.h"
42-
#include "replication/walpropshim.h"
4343
#include "storage/spin.h"
4444
#include "tcop/tcopprot.h"
4545
#include "utils/help_config.h"
@@ -56,6 +56,41 @@ static void init_locale(const char *categoryname, int category, const char *loca
5656
static void help(const char *progname);
5757
static void check_root(const char *progname);
5858

59+
typedef int (*MainFunc) (int argc, char *argv[]);
60+
61+
static int
62+
CallExtMain(char *library_name, char *main_func_name, int argc, char *argv[])
63+
{
64+
MainFunc main_func;
65+
66+
/*
67+
* Perform just enough initialization that we can load external libraries
68+
*/
69+
InitStandaloneProcess(argv[0]);
70+
71+
SetProcessingMode(InitProcessing);
72+
73+
/*
74+
* Set default values for command-line options.
75+
*/
76+
InitializeGUCOptions();
77+
78+
/* Acquire configuration parameters */
79+
if (!SelectConfigFiles(NULL, progname))
80+
exit(1);
81+
82+
/*
83+
* Imitate we are early in bootstrap loading shared_preload_libraries;
84+
* neon extension sets PGC_POSTMASTER gucs requiring this.
85+
*/
86+
process_shared_preload_libraries_in_progress = true;
87+
88+
main_func = load_external_function(library_name, main_func_name, true, NULL);
89+
90+
process_shared_preload_libraries_in_progress = false;
91+
92+
return main_func(argc, argv);
93+
}
5994

6095
/*
6196
* Any Postgres server process begins execution here.
@@ -200,11 +235,9 @@ main(int argc, char *argv[])
200235
PostgresSingleUserMain(argc, argv,
201236
strdup(get_user_name_or_exit(progname)));
202237
else if (argc > 1 && strcmp(argv[1], "--wal-redo") == 0)
203-
WalRedoMain(argc, argv,
204-
NULL, /* no dbname */
205-
strdup(get_user_name_or_exit(progname))); /* does not return */
238+
CallExtMain("neon_walredo", "WalRedoMain", argc, argv);
206239
else if (argc > 1 && strcmp(argv[1], "--sync-safekeepers") == 0)
207-
WalProposerSync(argc, argv);
240+
CallExtMain("neon", "WalProposerSync", argc, argv);
208241
else
209242
PostmasterMain(argc, argv);
210243
/* the functions above should not return */

src/backend/postmaster/Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,4 @@ OBJS = \
2727
syslogger.o \
2828
walwriter.o
2929

30-
ifeq ($(with_libseccomp),yes)
31-
OBJS += \
32-
seccomp.o
33-
endif
34-
3530
include $(top_srcdir)/src/backend/common.mk

src/backend/postmaster/bgworker.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "postmaster/postmaster.h"
2323
#include "replication/logicallauncher.h"
2424
#include "replication/logicalworker.h"
25-
#include "replication/walpropshim.h"
2625
#include "storage/dsm.h"
2726
#include "storage/ipc.h"
2827
#include "storage/latch.h"

src/backend/postmaster/postmaster.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
#include "postmaster/syslogger.h"
120120
#include "replication/logicallauncher.h"
121121
#include "replication/walsender.h"
122-
#include "replication/walpropshim.h"
123122
#include "storage/fd.h"
124123
#include "storage/ipc.h"
125124
#include "storage/pg_shmem.h"

src/backend/postmaster/seccomp.c

Lines changed: 0 additions & 249 deletions
This file was deleted.

src/backend/replication/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ OBJS = \
2222
syncrep_gram.o \
2323
walreceiver.o \
2424
walreceiverfuncs.o \
25-
walsender.o \
26-
walpropcompat.o
25+
walsender.o
2726

2827
SUBDIRS = logical
2928

0 commit comments

Comments
 (0)