Skip to content
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

Make pg_rewind read encrypted XLog #22

Open
wants to merge 1 commit into
base: TDE_REL_17_STABLE
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/bin/pg_rewind/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ OBJS = \

EXTRA_CLEAN = xlogreader.c

ifeq ($(enable_percona_ext),yes)
# TODO: Ideally should be built in pg_tde as a static lib
include $(top_srcdir)/contrib/pg_tde/Makefile.tools

TDE_OBJS2 = $(TDE_OBJS:%=$(top_srcdir)/contrib/pg_tde/%)

OBJS += \
$(top_srcdir)/src/fe_utils/simple_list.o \
$(TDE_OBJS2)

override CPPFLAGS := -I$(top_srcdir)/contrib/pg_tde/src/include -I$(top_srcdir)/contrib/pg_tde/src/libkmip/libkmip/include $(CPPFLAGS)
endif

all: pg_rewind

pg_rewind: $(OBJS) | submake-libpq submake-libpgport
Expand Down
4 changes: 3 additions & 1 deletion src/bin/pg_rewind/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pg_rewind_sources = files(
)

pg_rewind_sources += xlogreader_sources
pg_rewind_sources += tde_decrypt_sources

if host_system == 'windows'
pg_rewind_sources += rc_bin_gen.process(win32ver_rc, extra_args: [
Expand All @@ -21,9 +22,10 @@ endif

pg_rewind = executable('pg_rewind',
pg_rewind_sources,
dependencies: [frontend_code, libpq, lz4, zstd],
dependencies: [frontend_code, libpq, lz4, zstd, tde_deps],
c_args: ['-DFRONTEND'], # needed for xlogreader et al
kwargs: default_bin_args,
include_directories: [postgres_inc, tde_include],
)
bin_targets += pg_rewind

Expand Down
8 changes: 8 additions & 0 deletions src/bin/pg_rewind/parsexlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "filemap.h"
#include "pg_rewind.h"

#ifdef PERCONA_EXT
#include "access/pg_tde_xlog_encrypt_fe.h"
#endif

/*
* RmgrNames is an array of the built-in resource manager names, to make error
* messages a bit nicer.
Expand Down Expand Up @@ -364,7 +368,11 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
}


#ifdef PERCONA_EXT
r = xlog_smgr->seg_read(xlogreadfd, readBuf, XLOG_BLCKSZ, 0);
#else
r = read(xlogreadfd, readBuf, XLOG_BLCKSZ);
#endif
if (r != XLOG_BLCKSZ)
{
if (r < 0)
Expand Down
11 changes: 11 additions & 0 deletions src/bin/pg_rewind/pg_rewind.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "rewind_source.h"
#include "storage/bufpage.h"

#ifdef PERCONA_EXT
#include "access/pg_tde_xlog_encrypt_fe.h"
#endif

static void usage(const char *progname);

static void perform_rewind(filemap_t *filemap, rewind_source *source,
Expand Down Expand Up @@ -364,6 +368,13 @@ main(int argc, char **argv)
target_tli = Max(ControlFile_target.minRecoveryPointTLI,
ControlFile_target.checkPointCopy.ThisTimeLineID);

#ifdef PERCONA_EXT
/* TDOD: tde_path setup should be moved to the pg_tde side */
char tde_path[MAXPGPATH];
snprintf(tde_path, sizeof(tde_path), "%s/%s", datadir_target, PG_TDE_DATA_DIR);
TDE_XLOG_INIT(tde_path);
#endif

/*
* Find the common ancestor timeline between the clusters.
*
Expand Down
Loading