Don't rewrite _map files on the save_principal_key redo

We create a new WAL key during the extension init, which happens before
the redo. This means that in case of a crash,
pg_tde_save_principal_key_redo was rewriting a WAL _map file and destroying
a newly created key.

Since we emit an XLog record after the key was successfully written to
the file (the file was created), we can safely assume that we should
not change the file if it exists.
This commit is contained in:
Andrew Pogrebnoy 2025-04-15 10:53:59 +03:00 committed by Andrew Pogrebnoi
parent e735727c8e
commit 1fa786fa29

View File

@ -309,7 +309,7 @@ pg_tde_save_principal_key_redo(const TDESignedPrincipalKeyInfo *signed_key_info)
LWLockAcquire(tde_lwlock_enc_keys(), LW_EXCLUSIVE);
map_fd = pg_tde_open_file_write(db_map_path, signed_key_info, true, &curr_pos);
map_fd = pg_tde_open_file_write(db_map_path, signed_key_info, false, &curr_pos);
close(map_fd);
LWLockRelease(tde_lwlock_enc_keys());