Fix XLogging of rotated key

Before this commit, we XLogged the provider ID (keyringId) of the old
key. Yet, we then attempt to fetch the new key from the old provider
during the Redo, which obviously fails and crashes the recovery.
So the next steps lead to the recovery stalemate:
- Create new provider (with new destination - mount_path, url etc).
- Create new server/global key.
- Rotate key.
- <Crash!>

This commit fixes it by Xlogging the new key's provider ID.

For: PG-1895
pull/238/head
Andrew Pogrebnoy 2 weeks ago committed by Andrew Pogrebnoi
parent a711d8befa
commit 2364be29cc
  1. 4
      contrib/pg_tde/src/access/pg_tde_tdemap.c
  2. 4
      contrib/pg_tde/src/access/pg_tde_xlog_keys.c

@ -317,8 +317,8 @@ pg_tde_perform_rotate_key(const TDEPrincipalKey *principal_key, const TDEPrincip
{ {
XLogPrincipalKeyRotate xlrec; XLogPrincipalKeyRotate xlrec;
xlrec.databaseId = principal_key->keyInfo.databaseId; xlrec.databaseId = new_principal_key->keyInfo.databaseId;
xlrec.keyringId = principal_key->keyInfo.keyringId; xlrec.keyringId = new_principal_key->keyInfo.keyringId;
memcpy(xlrec.keyName, new_principal_key->keyInfo.name, sizeof(new_principal_key->keyInfo.name)); memcpy(xlrec.keyName, new_principal_key->keyInfo.name, sizeof(new_principal_key->keyInfo.name));
XLogBeginInsert(); XLogBeginInsert();

@ -738,8 +738,8 @@ pg_tde_perform_rotate_server_key(const TDEPrincipalKey *principal_key,
{ {
XLogPrincipalKeyRotate xlrec; XLogPrincipalKeyRotate xlrec;
xlrec.databaseId = principal_key->keyInfo.databaseId; xlrec.databaseId = new_principal_key->keyInfo.databaseId;
xlrec.keyringId = principal_key->keyInfo.keyringId; xlrec.keyringId = new_principal_key->keyInfo.keyringId;
memcpy(xlrec.keyName, new_principal_key->keyInfo.name, sizeof(new_principal_key->keyInfo.name)); memcpy(xlrec.keyName, new_principal_key->keyInfo.name, sizeof(new_principal_key->keyInfo.name));
XLogBeginInsert(); XLogBeginInsert();

Loading…
Cancel
Save