Skip to content

Pull 99% of walproposer code into extension. #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ SUBDIRS = \
isn \
lo \
ltree \
neon \
neon_test_utils \
oid2name \
old_snapshot \
pageinspect \
Expand Down
10 changes: 9 additions & 1 deletion contrib/neon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
MODULE_big = neon
OBJS = \
$(WIN32RES) \
inmem_smgr.o libpagestore.o pagestore_smgr.o relsize_cache.o neon.o
inmem_smgr.o \
libpagestore.o \
libpqwalproposer.o \
pagestore_smgr.o \
relsize_cache.o \
neon.o \
walproposer.o \
walproposer_utils.o

PG_CPPFLAGS = -I$(libpq_srcdir)
SHLIB_LINK_INTERNAL = $(libpq)
Expand All @@ -13,6 +20,7 @@ EXTENSION = neon
DATA = neon--1.0.sql
PGFILEDESC = "neon - cloud storage for PostgreSQL"


ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
Expand Down
9 changes: 4 additions & 5 deletions contrib/neon/libpagestore.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
#include "pgstat.h"
#include "utils/guc.h"

#include "replication/walproposer.h"
#include "neon.h"
#include "walproposer.h"
#include "walproposer_utils.h"

PG_MODULE_MAGIC;

void _PG_init(void);

#define PageStoreTrace DEBUG5

Expand Down Expand Up @@ -355,7 +354,7 @@ substitute_pageserver_password(const char *page_server_connstring_raw)
* Module initialization function
*/
void
_PG_init(void)
pg_init_libpagestore(void)
{
DefineCustomStringVariable("neon.pageserver_connstring",
"connection string to the page server",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#include "postgres.h"

#include "replication/walproposer.h"
#include "libpq-fe.h"

/* Required for anything that's dynamically loaded */
PG_MODULE_MAGIC;
void _PG_init(void);
#include "neon.h"
#include "walproposer.h"

/* Header in walproposer.h -- Wrapper struct to abstract away the libpq connection */
struct WalProposerConn
Expand Down Expand Up @@ -46,7 +43,7 @@ static WalProposerFunctionsType PQWalProposerFunctions = {

/* Module initialization */
void
_PG_init(void)
pg_init_libpqwalproposer(void)
{
if (WalProposerFunctions != NULL)
elog(ERROR, "libpqwalproposer already loaded");
Expand Down
15 changes: 14 additions & 1 deletion contrib/neon/neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,24 @@
#include "storage/bufmgr.h"
#include "catalog/pg_type.h"
#include "replication/walsender.h"
#include "replication/walproposer.h"
#include "funcapi.h"
#include "access/htup_details.h"
#include "utils/pg_lsn.h"

#include "neon.h"
#include "walproposer.h"

PG_MODULE_MAGIC;
void _PG_init(void);


void _PG_init(void)
{
pg_init_libpagestore();
pg_init_libpqwalproposer();
pg_init_walproposer();
}

PG_FUNCTION_INFO_V1(pg_cluster_size);
PG_FUNCTION_INFO_V1(backpressure_lsns);

Expand Down
19 changes: 19 additions & 0 deletions contrib/neon/neon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*-------------------------------------------------------------------------
*
* neon.h
* Functions used in the initialization of this extension.
*
* IDENTIFICATION
* contrib/neon/neon.h
*
*-------------------------------------------------------------------------
*/

#ifndef NEON_H
#define NEON_H

extern void pg_init_libpagestore(void);
extern void pg_init_libpqwalproposer(void);
extern void pg_init_walproposer(void);

#endif /* NEON_H */
2 changes: 1 addition & 1 deletion contrib/neon/pagestore_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extern void zenith_write(SMgrRelation reln, ForkNumber forknum,
extern void zenith_writeback(SMgrRelation reln, ForkNumber forknum,
BlockNumber blocknum, BlockNumber nblocks);
extern BlockNumber zenith_nblocks(SMgrRelation reln, ForkNumber forknum);
extern int64 zenith_dbsize(Oid dbNode);
extern const int64 zenith_dbsize(Oid dbNode);
extern void zenith_truncate(SMgrRelation reln, ForkNumber forknum,
BlockNumber nblocks);
extern void zenith_immedsync(SMgrRelation reln, ForkNumber forknum);
Expand Down
2 changes: 1 addition & 1 deletion contrib/neon/pagestore_smgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ zenith_nblocks(SMgrRelation reln, ForkNumber forknum)
/*
* zenith_db_size() -- Get the size of the database in bytes.
*/
int64
const int64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean for a function to be const?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know - it was required for signature checks and was pre-existing in the signature for the db_size hook - I didn't want to change this annotation without knowing why it was annotated.

zenith_dbsize(Oid dbNode)
{
ZenithResponse *resp;
Expand Down
Loading