Skip to content

Conversation

@dAdAbird
Copy link
Member

@dAdAbird dAdAbird commented Apr 16, 2025

Before this commit, we Xlogged the binary result of the _map file content during key rotation. This led to issues:

  1. Replicas would rewrite their own WAL keys with the primary's ones. And WAL keys are different on replicas. The same would have happened with SMGR keys since we're also planning to have them different across replicas.
  2. The crash recovery would rewrite the latest WAL key as it's being created before redo.

This commit switches to rather Xlogging the event of rotation (to which key should rotate) and lets redo/replicas perform the actual rotation.

Fixes PG-1468, PG-1541

@dAdAbird dAdAbird requested a review from dutow as a code owner April 16, 2025 16:14
@dAdAbird dAdAbird requested review from dutow and jeltz and removed request for dutow April 16, 2025 16:14
@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2025

Codecov Report

Attention: Patch coverage is 29.41176% with 24 lines in your changes missing coverage. Please review.

Project coverage is 75.45%. Comparing base (14a3d36) to head (b1da29f).
Report is 18 commits behind head on TDE_REL_17_STABLE.

❌ Your project status has failed because the head coverage (75.45%) 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     #225      +/-   ##
=====================================================
- Coverage              76.29%   75.45%   -0.85%     
=====================================================
  Files                     23       22       -1     
  Lines                   2523     2465      -58     
  Branches                 395      388       -7     
=====================================================
- Hits                    1925     1860      -65     
- Misses                   521      532      +11     
+ Partials                  77       73       -4     
Components Coverage Δ
access 72.44% <80.00%> (+0.92%) ⬆️
catalog 84.28% <8.33%> (-1.32%) ⬇️
common 92.50% <ø> (ø)
encryption 71.90% <ø> (-7.27%) ⬇️
keyring 69.87% <ø> (ø)
src 52.80% <ø> (-0.16%) ⬇️
smgr 96.93% <ø> (+0.13%) ⬆️
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

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

I like the general approach but I have some feedback on the code.

@dAdAbird dAdAbird requested a review from jeltz April 18, 2025 09:20
Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

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

Found two small things.

Before this commit, we Xlogged the binary result of the _map file
content during key rotation. This led to issues:
1. Replicas would rewrite their own WAL keys with the primary's ones.
And WAL keys are different on replicas. The same would have happened
with SMGR keys since we're also planning to have them different across
replicas.
2. The crash recovery would rewrite the latest WAL key as it's being
created before redo.

This commit switches to rather Xlogging the event of rotation (to which
key should rotate) and lets redo/replicas perform the actual rotation.

Fixes PG-1468, PG-1541
Copy link
Collaborator

@jeltz jeltz left a comment

Choose a reason for hiding this comment

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

Looks good but it would be nice if we could also start writing TAP tests for things like this. I started with a very simple TAP test for replication.

@dAdAbird dAdAbird merged commit 0d86245 into percona:TDE_REL_17_STABLE Apr 22, 2025
22 checks passed
@dAdAbird dAdAbird deleted the xlog_rotate_key branch April 22, 2025 15:08
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.

3 participants