Skip to content

PG-1651 Do not try the fetch key from old provider when changing provider settings #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jeltz
Copy link
Collaborator

@jeltz jeltz commented Jun 5, 2025

We used to verify that all keys are still accessible by fetching the key from cache and if not cached from the current provider settings when changing the key provider setting but this makes things fragile and prone to user error in the case where a principal key is not cached.

Instead we can rely on the AEAD tag in the header of each file, which has two advantages 1) the cached and non-cache code path works the same and 2) we do not need to care about if the old provider is accessible, only that the new one is and that it contains the right key (i.e. one that can verify the header tag).

…ider settings

We used to verify that all keys are still accessible by fetching the key
from cache and if not cached from the current provider settings when
changing the key provider setting but this makes things fragile and
prone to user error in the case where a principal key is not cached.

Instead we can rely on the AEAD tag in the header of each file, which
has two advantages 1) the cached and non-cache code path works the same
and 2) we do not need to care about if the old provider is accessible,
only that the new one is and that it contains the right key (i.e. one
that can verify the header tag).
@jeltz jeltz requested review from dutow and dAdAbird as code owners June 5, 2025 07:20
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.25%. Comparing base (d37fa69) to head (5767d45).

❌ Your project status has failed because the head coverage (85.25%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@                  Coverage Diff                  @@
##           TDE_REL_17_STABLE     #395      +/-   ##
=====================================================
+ Coverage              85.20%   85.25%   +0.05%     
=====================================================
  Files                     22       22              
  Lines                   2534     2536       +2     
  Branches                 384      386       +2     
=====================================================
+ Hits                    2159     2162       +3     
+ Misses                   301      300       -1     
  Partials                  74       74              
Components Coverage Δ
access 84.20% <100.00%> (ø)
catalog 88.11% <85.71%> (+0.14%) ⬆️
common 91.80% <ø> (ø)
encryption 72.56% <ø> (ø)
keyring 72.00% <ø> (ø)
src 91.40% <ø> (ø)
smgr 97.41% <ø> (ø)
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -677,9 +677,7 @@ pg_tde_get_key_info(PG_FUNCTION_ARGS, Oid dbOid)
#endif /* FRONTEND */

/*
* Gets principal key form the keyring.
*
* Caller should hold an exclusive tde_lwlock_enc_keys lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the reason for removing this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the assert is there and protects the caller.

@jeltz jeltz merged commit 5c33f38 into percona:TDE_REL_17_STABLE Jun 6, 2025
16 checks passed
@jeltz jeltz deleted the tde/change-key-provider-no-cache branch June 6, 2025 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants