Switching WAL encryption on and off makes us unable to read old WAL

Description

Could possibly be related to https://perconadev.atlassian.net/browse/PG-1413 but I do not think so.

export PGPORT=6432 bin/pg_ctl -D data stop rm -r data bin/initdb -D data -k --set shared_preload_libraries=pg_tde --set wal_level=logical bin/pg_ctl -D data start bin/psql postgres <<"EOS" CREATE EXTENSION IF NOT EXISTS pg_tde; SELECT pg_tde_add_global_key_provider_file('file-keyring-010','/tmp/pg_tde_test_keyring010.per'); SELECT pg_tde_set_server_principal_key('global-db-principal-key', 'file-keyring-010'); ALTER SYSTEM SET pg_tde.wal_encrypt = on; EOS bin/pg_ctl -D data restart bin/psql postgres <<"EOS" SHOW pg_tde.wal_encrypt; SELECT pg_create_logical_replication_slot('tde_slot', 'test_decoding'); CREATE TABLE test_wal (id SERIAL, k INTEGER, PRIMARY KEY (id)); INSERT INTO test_wal (k) VALUES (1), (2); ALTER SYSTEM SET pg_tde.wal_encrypt = off; EOS bin/pg_ctl -D data restart bin/psql postgres <<"EOS" SHOW pg_tde.wal_encrypt; INSERT INTO test_wal (k) VALUES (3), (4); ALTER SYSTEM SET pg_tde.wal_encrypt = on; EOS bin/pg_ctl -D data restart bin/psql postgres <<"EOS" SHOW pg_tde.wal_encrypt; INSERT INTO test_wal (k) VALUES (5), (6); SELECT * FROM pg_logical_slot_get_changes('tde_slot', NULL, NULL); EOS

Gives us the following error

ERROR: could not find record for logical decoding: incorrect resource manager data checksum in record at 0/188EF90

Environment

None

Activity

shahidullah.khan 
April 8, 2025 at 11:45 AM

I have verified above scenario with both encrypted and non-encrypted tables. No error message appeared on executing scenario. SELECT * FROM pg_logical_slot_get_changes('tde_slot', NULL, NULL);
verified with
commit ID: 2616e27844571b3dcebce54d4f2c598763dd5f87

db1=# SELECT * FROM pg_logical_slot_get_changes('tde_slot1', NULL, NULL); 2025-04-08 11:38:14.908 UTC [1167140] STATEMENT: SELECT * FROM pg_logical_slot_get_changes('tde_slot1', NULL, NULL); lsn | xid | data -----------+-----+----------------------------------------------------------- 0/1D49600 | 757 | BEGIN 757 0/1D6EF10 | 757 | COMMIT 757 0/1D6EF48 | 758 | BEGIN 758 0/1D6EFB0 | 758 | table public.test_wal: INSERT: id[integer]:1 k[integer]:1 0/1D6F090 | 758 | table public.test_wal: INSERT: id[integer]:2 k[integer]:2 0/1D6F140 | 758 | COMMIT 758 0/1D71210 | 759 | BEGIN 759 0/1D71278 | 759 | table public.test_wal: INSERT: id[integer]:3 k[integer]:3 0/1D713E0 | 759 | table public.test_wal: INSERT: id[integer]:4 k[integer]:4 0/1D71490 | 759 | COMMIT 759 0/1D71578 | 760 | BEGIN 760 0/1D715E0 | 760 | table public.test_wal: INSERT: id[integer]:5 k[integer]:5 0/1D717B8 | 760 | table public.test_wal: INSERT: id[integer]:6 k[integer]:6 0/1D71868 | 760 | COMMIT 760 (14 rows) db1=#
Done

Details

Assignee

Reporter

Needs QA

Components

Sprint

Fix versions

Priority

Created April 5, 2025 at 9:42 PM
Updated May 5, 2025 at 2:18 PM
Resolved April 8, 2025 at 11:45 AM