Skip to content

Conversation

@jeltz
Copy link
Collaborator

@jeltz jeltz commented Apr 17, 2025

Instead of replicating relation keys we generate new ones on replay of
the XLOG_TDE_ADD_RELATION_KEY record at the replica server. This means a
replica and its master server will end up with different sets of
relation keys making a simple binary diff impossible but that is a
dubious advantage since the WAL keys will differ anyway and on on the
flip-side the new code is simpler and easier to reason about. Especially
since now WAL keys and relation keys are treated in a bit more similar
ways.

To prevent duplicate keys in the key file we skip generating and adding
a key if there already is an entry in the file for the same relation.

Also while changing this we make sure to add a simple replication test plus add code preventing the SMGR code at a replica from generating any new keys. Keys should only be created on WAL replay. But these changes should have been done either way.

@jeltz jeltz requested review from dAdAbird and dutow as code owners April 17, 2025 23:48
@codecov-commenter
Copy link

codecov-commenter commented Apr 17, 2025

Codecov Report

Attention: Patch coverage is 77.55102% with 11 lines in your changes missing coverage. Please review.

Project coverage is 77.13%. Comparing base (4724ecb) to head (1e92263).

❌ Your project status has failed because the head coverage (77.13%) 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     #234      +/-   ##
=====================================================
+ Coverage              75.60%   77.13%   +1.53%     
=====================================================
  Files                     22       22              
  Lines                   2492     2489       -3     
  Branches                 394      394              
=====================================================
+ Hits                    1884     1920      +36     
+ Misses                   531      490      -41     
- Partials                  77       79       +2     
Components Coverage Δ
access 78.13% <62.06%> (+5.31%) ⬆️
catalog 83.64% <ø> (+0.44%) ⬆️
common 92.50% <ø> (ø)
encryption 71.90% <ø> (ø)
keyring 72.07% <ø> (ø)
src 53.79% <ø> (+0.99%) ⬆️
smgr 98.01% <100.00%> (+1.05%) ⬆️
transam ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeltz jeltz force-pushed the tde/no-relkey-replication branch from 3fa064b to 01a5801 Compare April 17, 2025 23:57
Copy link
Member

@dAdAbird dAdAbird left a comment

Choose a reason for hiding this comment

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

LGTM overall. Just following the discussion in another PR, the question is if we want XLogInsert (therefore replicated event) before we successfully applied it on the source

@jeltz jeltz force-pushed the tde/no-relkey-replication branch 5 times, most recently from cd787b1 to 582e4c4 Compare April 22, 2025 15:56
@jeltz
Copy link
Collaborator Author

jeltz commented Apr 22, 2025

Moved the WAL writing.

@jeltz jeltz requested a review from dAdAbird April 22, 2025 16:51
@jeltz jeltz force-pushed the tde/no-relkey-replication branch from 582e4c4 to 62f8e25 Compare April 22, 2025 17:05
@jeltz jeltz force-pushed the tde/no-relkey-replication branch from 62f8e25 to b5e72b0 Compare April 23, 2025 07:28
@jeltz jeltz force-pushed the tde/no-relkey-replication branch 4 times, most recently from 407a31b to cc40c89 Compare April 23, 2025 11:52
jeltz added 4 commits April 23, 2025 14:17
The old code was harder to read than necessary since it had exactly two
callers of which one had each value of the boolean flag. Breaking it up
into two functions makes the intent clearer. While at it we also clean
up the flow a bit more.
This way we can avoid obvious regression when refactoring the code for
replicating keys in future commits. This test can in the future be
expanded to test more interesting cases.
Make sure we can never generate relation keys on a streaming replica or
in recovery in the SMGR code. Instead the key should always have been
already generated when replaying the XLOG_TDE_ADD_RELATION_KEY record.
Instead of replicating relation keys we generate new ones on replay of
the XLOG_TDE_ADD_RELATION_KEY record at the replica server. This means a
replica and its master server will end up with different sets of
relation keys making a simple binary diff impossible but that is a
dubious advantage since the WAL keys will differ anyway and on on the
flip-side the new code is simpler and easier to reason about. Especially
since now WAL keys and relation keys are treated in a bit more similar
ways.

To prevent duplicate keys in the key file we skip generating and adding
a key if there already is an entry in the file for the same relation.
@jeltz jeltz force-pushed the tde/no-relkey-replication branch from cc40c89 to 1e92263 Compare April 23, 2025 12:17
@jeltz jeltz merged commit e450170 into percona:TDE_REL_17_STABLE Apr 23, 2025
22 checks passed
@jeltz jeltz deleted the tde/no-relkey-replication branch April 26, 2025 14:34
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