Skip to content

Commit 1338ceb

Browse files
committed
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.
1 parent aed49c0 commit 1338ceb

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

contrib/pg_tde/src/access/pg_tde_xlog_smgr.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,16 @@ tdeheap_xlog_seg_write(int fd, const void *buf, size_t count, off_t offset,
368368
lastKeyUsable = (writeKeyLoc.lsn != 0);
369369
afterWriteKey = wal_location_cmp(writeKeyLoc, loc) <= 0;
370370

371-
if (EncryptionKey.type != WAL_KEY_TYPE_INVALID && !lastKeyUsable && afterWriteKey)
371+
if (EncryptionKey.type != WAL_KEY_TYPE_INVALID && !lastKeyUsable && afterWriteKey && !crashRecovery)
372372
{
373373
WALKeyCacheRec *last_key = pg_tde_get_last_wal_key();
374374

375-
if (!crashRecovery)
375+
if (last_key == NULL || last_key->start.lsn < loc.lsn)
376376
{
377-
if (last_key == NULL || last_key->start.lsn < loc.lsn)
378-
{
379-
pg_tde_wal_last_key_set_location(loc);
380-
EncryptionKey.wal_start = loc;
381-
TDEXLogSetEncKeyLocation(EncryptionKey.wal_start);
382-
lastKeyUsable = true;
383-
}
377+
pg_tde_wal_last_key_set_location(loc);
378+
EncryptionKey.wal_start = loc;
379+
TDEXLogSetEncKeyLocation(EncryptionKey.wal_start);
380+
lastKeyUsable = true;
384381
}
385382
}
386383

0 commit comments

Comments
 (0)