Skip to content

PG-1710 Decrypt partial WAL segments when archvining them #496

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 1 commit into from
Jul 31, 2025

Conversation

jeltz
Copy link
Collaborator

@jeltz jeltz commented Jul 30, 2025

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().

@codecov-commenter
Copy link

codecov-commenter commented Jul 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.76%. Comparing base (f631753) to head (7a01d20).

❌ Your project status has failed because the head coverage (81.76%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@                Coverage Diff                 @@
##           TDE_REL_17_STABLE     #496   +/-   ##
==================================================
  Coverage              81.75%   81.76%           
==================================================
  Files                     24       24           
  Lines                   2987     2988    +1     
  Branches                 485      485           
==================================================
+ Hits                    2442     2443    +1     
  Misses                   444      444           
  Partials                 101      101           
Components Coverage Δ
access 81.17% <ø> (ø)
catalog 87.85% <ø> (ø)
common 77.77% <ø> (ø)
encryption 73.45% <ø> (ø)
keyring 73.21% <ø> (ø)
src 94.15% <ø> (ø)
smgr 94.85% <ø> (ø)
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeltz jeltz force-pushed the tde/archive-restore-partial branch from b69f88a to 4ca2d67 Compare July 30, 2025 14:27
@@ -16,7 +16,8 @@
static bool
is_segment(const char *filename)
{
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN && filename[XLOG_FNAME_LEN] == '\0';
return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN &&
(filename[XLOG_FNAME_LEN] == '\0' && strcmp(filename + XLOG_FNAME_LEN, ".partial"));
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be

 	return strspn(filename, "0123456789ABCDEF") == XLOG_FNAME_LEN &&
 		(filename[XLOG_FNAME_LEN] == '\0' || strcmp(filename + XLOG_FNAME_LEN, ".partial") == 0);

and the same in contrib/pg_tde/src/bin/pg_tde_restore_encrypt.c

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, I was interrupted in the middle of writing the code and did not check it before submitting the PR. My apologies. :(

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().
@jeltz jeltz force-pushed the tde/archive-restore-partial branch from 4ca2d67 to 7a01d20 Compare July 30, 2025 17:05
@jeltz jeltz merged commit 3a4db71 into percona:TDE_REL_17_STABLE Jul 31, 2025
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants