Do not try to fetch the last key when we do not have to

This is likely a leftover from when the logic for unencrypted keys
was different from the one for real encryption keys.
pull/238/head
Andreas Karlsson 3 weeks ago committed by Andreas Karlsson
parent aed49c0847
commit 1338ceb137
  1. 5
      contrib/pg_tde/src/access/pg_tde_xlog_smgr.c

@ -368,12 +368,10 @@ tdeheap_xlog_seg_write(int fd, const void *buf, size_t count, off_t offset,
lastKeyUsable = (writeKeyLoc.lsn != 0);
afterWriteKey = wal_location_cmp(writeKeyLoc, loc) <= 0;
if (EncryptionKey.type != WAL_KEY_TYPE_INVALID && !lastKeyUsable && afterWriteKey)
if (EncryptionKey.type != WAL_KEY_TYPE_INVALID && !lastKeyUsable && afterWriteKey && !crashRecovery)
{
WALKeyCacheRec *last_key = pg_tde_get_last_wal_key();
if (!crashRecovery)
{
if (last_key == NULL || last_key->start.lsn < loc.lsn)
{
pg_tde_wal_last_key_set_location(loc);
@ -382,7 +380,6 @@ tdeheap_xlog_seg_write(int fd, const void *buf, size_t count, off_t offset,
lastKeyUsable = true;
}
}
}
if ((!afterWriteKey || !lastKeyUsable) && EncryptionKey.type != WAL_KEY_TYPE_INVALID)
{

Loading…
Cancel
Save