Skip to content

Commit

Permalink
Lock principal keys in RAM
Browse files Browse the repository at this point in the history
We just lock the hash table entry. Although it will lock the whole mem
page we ok with that potential waste. The number of principal keys
should be less than internal and allocated in the shared memory once
for all backends (unlike internal keys in the TopMemoryContext of every
backend). Plus hash table (via dsa) allocates in 4kb pages and
hopefully, principal keys end up compactly placed.
  • Loading branch information
dAdAbird committed Sep 13, 2024
1 parent b62b165 commit da4718d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/catalog/tde_principal_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "utils/builtins.h"
#include "pg_tde.h"
#include "access/pg_tde_xlog.h"
#include <sys/mman.h>
#include <sys/time.h>

#include "access/pg_tde_tdemap.h"
Expand Down Expand Up @@ -662,6 +663,10 @@ push_principal_key_to_cache(TDEPrincipalKey *principalKey)
if (!found)
memcpy(cacheEntry, principalKey, sizeof(TDEPrincipalKey));
dshash_release_lock(get_principal_key_Hash(), cacheEntry);

/* we don't want principal keys to end up paged to the swap */
if (mlock(cacheEntry, sizeof(TDEPrincipalKey)) == -1)
elog(ERROR, "could not mlock principal key cache entry: %m");
}

/*
Expand Down

0 comments on commit da4718d

Please sign in to comment.