Skip to content

Commit 07d51ef

Browse files
committed
Make pg_rewind work with encrypted WAL
1 parent 443d33c commit 07d51ef

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/bin/pg_rewind/meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,21 @@ if host_system == 'windows'
1919
'--FILEDESC', 'pg_rewind - synchronize a data directory with another one forked from'])
2020
endif
2121

22+
link_w = []
23+
include_dirs = [postgres_inc]
24+
25+
if percona_ext == true
26+
link_w = [pg_tde_frontend]
27+
include_dirs = [postgres_inc, pg_tde_inc]
28+
endif
29+
2230
pg_rewind = executable('pg_rewind',
2331
pg_rewind_sources,
2432
dependencies: [frontend_code, libpq, lz4, zstd],
2533
c_args: ['-DFRONTEND'], # needed for xlogreader et al
2634
kwargs: default_bin_args,
35+
include_directories: include_dirs,
36+
link_with: link_w,
2737
)
2838
bin_targets += pg_rewind
2939

src/bin/pg_rewind/parsexlog.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#include "fe_utils/archive.h"
2424
#include "filemap.h"
2525
#include "pg_rewind.h"
26+
#ifdef PERCONA_EXT
27+
#include "access/pg_tde_xlog_smgr.h"
28+
#include "access/xlog_smgr.h"
29+
#endif
2630

2731
/*
2832
* RmgrNames is an array of the built-in resource manager names, to make error
@@ -356,6 +360,11 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
356360
*/
357361
Assert(xlogreadfd != -1);
358362

363+
#ifdef PERCONA_EXT
364+
r = xlog_smgr->seg_read(xlogreadfd, readBuf, XLOG_BLCKSZ, (off_t) targetPageOff,
365+
targetHistory[private->tliIndex].tli,
366+
xlogreadsegno, WalSegSz);
367+
#else
359368
/* Read the requested page */
360369
if (lseek(xlogreadfd, (off_t) targetPageOff, SEEK_SET) < 0)
361370
{
@@ -365,6 +374,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
365374

366375

367376
r = read(xlogreadfd, readBuf, XLOG_BLCKSZ);
377+
#endif
368378
if (r != XLOG_BLCKSZ)
369379
{
370380
if (r < 0)

src/bin/pg_rewind/pg_rewind.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "pg_rewind.h"
3232
#include "rewind_source.h"
3333
#include "storage/bufpage.h"
34+
#ifdef PERCONA_EXT
35+
#include "pg_tde.h"
36+
#include "access/pg_tde_fe_init.h"
37+
#include "access/pg_tde_xlog_smgr.h"
38+
#include "catalog/tde_global_space.h"
39+
#endif
3440

3541
static void usage(const char *progname);
3642

@@ -364,6 +370,15 @@ main(int argc, char **argv)
364370
target_tli = Max(ControlFile_target.minRecoveryPointTLI,
365371
ControlFile_target.checkPointCopy.ThisTimeLineID);
366372

373+
#ifdef PERCONA_EXT
374+
{
375+
/* TDOD: tde_path setup should be moved to the pg_tde side? */
376+
char tde_path[MAXPGPATH];
377+
snprintf(tde_path, sizeof(tde_path), "%s/%s", datadir_target, PG_TDE_DATA_DIR);
378+
pg_tde_fe_init(tde_path);
379+
TDEXLogSmgrInit();
380+
}
381+
#endif
367382
/*
368383
* Find the common ancestor timeline between the clusters.
369384
*

0 commit comments

Comments
 (0)