-
Notifications
You must be signed in to change notification settings - Fork 11
PG-1710 Create helpers for decrypting/encrypting archived WAL #487
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
PG-1710 Create helpers for decrypting/encrypting archived WAL #487
Conversation
5dc0f74
to
6c75dba
Compare
I am aware documentation us missing but I want some early feedback so that I don't waste more time if this is wrong. |
6c75dba
to
39cdf06
Compare
Codecov Report❌ Patch coverage is ❌ Your project status has failed because the head coverage (81.87%) 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 #487 +/- ##
=====================================================
- Coverage 83.68% 81.87% -1.82%
=====================================================
Files 21 24 +3
Lines 2771 3001 +230
Branches 435 489 +54
=====================================================
+ Hits 2319 2457 +138
- Misses 368 446 +78
- Partials 84 98 +14
🚀 New features to boost your workflow:
|
aea6c32
to
1903471
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Though I'm not that familiar with the archive_command, but from what I've read, this PR looks sound.
pg_fatal("mismatch of segment size in WAL file \"%s\" (header: %d bytes, file size: %ld bytes)", | ||
segname, walsegsz, fsize); | ||
|
||
if (!IsValidWalSegSize(walsegsz)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this part be a helper function to avoid the duplication in the two tools? And is_segment
is also common
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the duplicated code is enough to bother but I could give it a shot and see if anything improves.
Now that we will soon be adding more bianries having them at the top level only makes things confusing for developers.
e555fa8
to
56f4484
Compare
To support some common WAL archiving tools, e.g. PgBackRest, we implement an archive_command and a restore_command which can wrap any command and use pipe() to create fake file to either read from or write to. The restore command makes sure to write encrypted files if WAL encryption is enabled. It uses the fresh WAL key generated by the server on the current start which works fine because we then just let the first invocation of the restore command set the start LSN of the key. For e.g. PgBackRest you would have the following commands: archive_command = 'pg_tde_archive_decrypt %p pgbackrest --stanza=demo archive-push %p' restore_command = 'pg_tde_restore_encrypt %f %p pgbackrest --stanza=demo archive-get %f "%p"'
56f4484
to
675d3f0
Compare
To support some common WAL archiving tools, e.g. PgBackRest, we implement an
archive_command
and arestore_command
which can wrap any command and usepipe()
to create fake file to either read from or write to. The restore command makes sure to write encrypted files if WAL encryption is enabled. It uses the fresh WAL key generated by the server on the current start which works fine because we then just let the first invocation of the restore command set the start LSN of the key.For e.g. PgBackRest you would have the following commands:
An alternative if we want to make sure to use
system()
likearchive_command
andrestore_command
it would instead be, but feels a bit risky since people would have to remember to do %% for it to work.