Skip to content

Commit b69f88a

Browse files
committed
PG-1710 Decrypt partial WAL segments when archvining them
While the restore_command will never be called for partial WAL segments we should sitll make sure to decrypt them when archiving so a sysadmin manually could use them. As the comemnt explains we also add the same logic to the restore command for symmetry and if someone ever would call it manually or PostgreSQL would add support for restoring partial WAL segments. If you want to learn more about partial WAL segments read the comment for CleanupAfterArchiveRecovery().
1 parent f631753 commit b69f88a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

contrib/pg_tde/src/bin/pg_tde_archive_decrypt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
static bool
1717
is_segment(const char *filename)
1818
{
19-
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN && filename[XLOG_FNAME_LEN] == '\0';
19+
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN &&
20+
(filename[XLOG_FNAME_LEN] == '\0' && strcmp(filename + XLOG_FNAME_LEN, ".partial"));
2021
}
2122

2223
static void

contrib/pg_tde/src/bin/pg_tde_restore_encrypt.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,17 @@
1313

1414
#define TMPFS_DIRECTORY "/dev/shm"
1515

16+
/*
17+
* Partial WAL segments are archived but never automatically fetched from the
18+
* archive by the restore_command. We support them here for symmetry though
19+
* since if someone would want to fetch a partial segment from the archive and
20+
* write it to pg_wal then they would want it encrypted.
21+
*/
1622
static bool
1723
is_segment(const char *filename)
1824
{
19-
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN && filename[XLOG_FNAME_LEN] == '\0';
25+
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN &&
26+
(filename[XLOG_FNAME_LEN] == '\0' && strcmp(filename + XLOG_FNAME_LEN, ".partial"));
2027
}
2128

2229
static void

0 commit comments

Comments
 (0)