From 1ff5333a1bff07ec13f3c5c1def2dbb161371c3f Mon Sep 17 00:00:00 2001 From: Konstantin Knizhnik Date: Wed, 13 Nov 2024 08:50:01 +0200 Subject: [PATCH] Do not wallog AUX files at replica (#9457) ## Problem Attempt to persist LR stuff at replica cause cannot make new WAL entries during recovery` error. See https://neondb.slack.com/archives/C07S7RBFVRA/p1729280401283389 ## Summary of changes Do not wallog AUX files at replica. Related Postgres PRs: https://github.com/neondatabase/postgres/pull/517 https://github.com/neondatabase/postgres/pull/516 https://github.com/neondatabase/postgres/pull/515 https://github.com/neondatabase/postgres/pull/514 ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. ## Checklist before merging - [ ] Do not forget to reformat commit message to not include the above checklist --------- Co-authored-by: Konstantin Knizhnik Co-authored-by: Heikki Linnakangas --- .../test_physical_and_logical_replicaiton.py | 53 +++++++++++++++++-- vendor/postgres-v14 | 2 +- vendor/postgres-v15 | 2 +- vendor/postgres-v16 | 2 +- vendor/postgres-v17 | 2 +- vendor/revisions.json | 8 +-- 6 files changed, 58 insertions(+), 11 deletions(-) diff --git a/test_runner/regress/test_physical_and_logical_replicaiton.py b/test_runner/regress/test_physical_and_logical_replicaiton.py index ec14e08a14..ad2d0871b8 100644 --- a/test_runner/regress/test_physical_and_logical_replicaiton.py +++ b/test_runner/regress/test_physical_and_logical_replicaiton.py @@ -5,7 +5,8 @@ import time from fixtures.neon_fixtures import NeonEnv, logical_replication_sync -def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg): +def test_physical_and_logical_replication_slot_not_copied(neon_simple_env: NeonEnv, vanilla_pg): + """Test read replica of a primary which has a logical replication publication""" env = neon_simple_env n_records = 100000 @@ -13,7 +14,6 @@ def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg): primary = env.endpoints.create_start( branch_name="main", endpoint_id="primary", - config_lines=["min_wal_size=32MB", "max_wal_size=64MB"], ) p_con = primary.connect() p_cur = p_con.cursor() @@ -30,7 +30,6 @@ def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg): secondary = env.endpoints.new_replica_start( origin=primary, endpoint_id="secondary", - config_lines=["min_wal_size=32MB", "max_wal_size=64MB"], ) s_con = secondary.connect() @@ -48,3 +47,51 @@ def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg): # Check that LR slot is not copied to replica s_cur.execute("select count(*) from pg_replication_slots") assert s_cur.fetchall()[0][0] == 0 + + +def test_aux_not_logged_at_replica(neon_simple_env: NeonEnv, vanilla_pg): + """Test that AUX files are not saved at replica""" + env = neon_simple_env + + n_records = 20000 + + primary = env.endpoints.create_start( + branch_name="main", + endpoint_id="primary", + ) + p_con = primary.connect() + p_cur = p_con.cursor() + p_cur.execute("CREATE TABLE t(pk bigint primary key, payload text default repeat('?',200))") + p_cur.execute("create publication pub1 for table t") + + # start subscriber + vanilla_pg.start() + vanilla_pg.safe_psql("CREATE TABLE t(pk bigint primary key, payload text)") + connstr = primary.connstr().replace("'", "''") + vanilla_pg.safe_psql(f"create subscription sub1 connection '{connstr}' publication pub1") + + for pk in range(n_records): + p_cur.execute("insert into t (pk) values (%s)", (pk,)) + + # LR snapshot is stored each 15 seconds + time.sleep(16) + + # start replica + secondary = env.endpoints.new_replica_start( + origin=primary, + endpoint_id="secondary", + ) + + s_con = secondary.connect() + s_cur = s_con.cursor() + + logical_replication_sync(vanilla_pg, primary) + + assert vanilla_pg.safe_psql("select count(*) from t")[0][0] == n_records + s_cur.execute("select count(*) from t") + assert s_cur.fetchall()[0][0] == n_records + + vanilla_pg.stop() + secondary.stop() + primary.stop() + assert not secondary.log_contains("cannot make new WAL entries during recovery") diff --git a/vendor/postgres-v14 b/vendor/postgres-v14 index 2199b83fb7..de0a000daf 160000 --- a/vendor/postgres-v14 +++ b/vendor/postgres-v14 @@ -1 +1 @@ -Subproject commit 2199b83fb72680001ce0f43bf6187a21dfb8f45d +Subproject commit de0a000dafc2e66ce2e39282d3aa1c704fe0390e diff --git a/vendor/postgres-v15 b/vendor/postgres-v15 index 22e580fe9f..fd631a9590 160000 --- a/vendor/postgres-v15 +++ b/vendor/postgres-v15 @@ -1 +1 @@ -Subproject commit 22e580fe9ffcea7e02592110b1c9bf426d83cada +Subproject commit fd631a959049dfe2b82f67409c8b8b0d3e0016d1 diff --git a/vendor/postgres-v16 b/vendor/postgres-v16 index e131a9c027..03b43900ed 160000 --- a/vendor/postgres-v16 +++ b/vendor/postgres-v16 @@ -1 +1 @@ -Subproject commit e131a9c027b202ce92bd7b9cf2569d48a6f9948e +Subproject commit 03b43900edc5d8d6eecec460bfc89aec7174bd84 diff --git a/vendor/postgres-v17 b/vendor/postgres-v17 index 9ad2f3c5c3..ae4cc30dba 160000 --- a/vendor/postgres-v17 +++ b/vendor/postgres-v17 @@ -1 +1 @@ -Subproject commit 9ad2f3c5c37c08069a01c1e3f6b7cf275437e0cb +Subproject commit ae4cc30dba24f3910533e5a48e8103c3f2fff300 diff --git a/vendor/revisions.json b/vendor/revisions.json index 18bde18359..8d5885d07a 100644 --- a/vendor/revisions.json +++ b/vendor/revisions.json @@ -1,18 +1,18 @@ { "v17": [ "17.0", - "9ad2f3c5c37c08069a01c1e3f6b7cf275437e0cb" + "ae4cc30dba24f3910533e5a48e8103c3f2fff300" ], "v16": [ "16.4", - "e131a9c027b202ce92bd7b9cf2569d48a6f9948e" + "03b43900edc5d8d6eecec460bfc89aec7174bd84" ], "v15": [ "15.8", - "22e580fe9ffcea7e02592110b1c9bf426d83cada" + "fd631a959049dfe2b82f67409c8b8b0d3e0016d1" ], "v14": [ "14.13", - "2199b83fb72680001ce0f43bf6187a21dfb8f45d" + "de0a000dafc2e66ce2e39282d3aa1c704fe0390e" ] }