Skip to content

Commit 1ff5333

Browse files
knizhnikKonstantin Knizhnikhlinnaka
authored
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: neondatabase/postgres#517 neondatabase/postgres#516 neondatabase/postgres#515 neondatabase/postgres#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 <[email protected]> Co-authored-by: Heikki Linnakangas <[email protected]>
1 parent d8f5d43 commit 1ff5333

File tree

6 files changed

+58
-11
lines changed

6 files changed

+58
-11
lines changed

test_runner/regress/test_physical_and_logical_replicaiton.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
from fixtures.neon_fixtures import NeonEnv, logical_replication_sync
66

77

8-
def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg):
8+
def test_physical_and_logical_replication_slot_not_copied(neon_simple_env: NeonEnv, vanilla_pg):
9+
"""Test read replica of a primary which has a logical replication publication"""
910
env = neon_simple_env
1011

1112
n_records = 100000
1213

1314
primary = env.endpoints.create_start(
1415
branch_name="main",
1516
endpoint_id="primary",
16-
config_lines=["min_wal_size=32MB", "max_wal_size=64MB"],
1717
)
1818
p_con = primary.connect()
1919
p_cur = p_con.cursor()
@@ -30,7 +30,6 @@ def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg):
3030
secondary = env.endpoints.new_replica_start(
3131
origin=primary,
3232
endpoint_id="secondary",
33-
config_lines=["min_wal_size=32MB", "max_wal_size=64MB"],
3433
)
3534

3635
s_con = secondary.connect()
@@ -48,3 +47,51 @@ def test_physical_and_logical_replication(neon_simple_env: NeonEnv, vanilla_pg):
4847
# Check that LR slot is not copied to replica
4948
s_cur.execute("select count(*) from pg_replication_slots")
5049
assert s_cur.fetchall()[0][0] == 0
50+
51+
52+
def test_aux_not_logged_at_replica(neon_simple_env: NeonEnv, vanilla_pg):
53+
"""Test that AUX files are not saved at replica"""
54+
env = neon_simple_env
55+
56+
n_records = 20000
57+
58+
primary = env.endpoints.create_start(
59+
branch_name="main",
60+
endpoint_id="primary",
61+
)
62+
p_con = primary.connect()
63+
p_cur = p_con.cursor()
64+
p_cur.execute("CREATE TABLE t(pk bigint primary key, payload text default repeat('?',200))")
65+
p_cur.execute("create publication pub1 for table t")
66+
67+
# start subscriber
68+
vanilla_pg.start()
69+
vanilla_pg.safe_psql("CREATE TABLE t(pk bigint primary key, payload text)")
70+
connstr = primary.connstr().replace("'", "''")
71+
vanilla_pg.safe_psql(f"create subscription sub1 connection '{connstr}' publication pub1")
72+
73+
for pk in range(n_records):
74+
p_cur.execute("insert into t (pk) values (%s)", (pk,))
75+
76+
# LR snapshot is stored each 15 seconds
77+
time.sleep(16)
78+
79+
# start replica
80+
secondary = env.endpoints.new_replica_start(
81+
origin=primary,
82+
endpoint_id="secondary",
83+
)
84+
85+
s_con = secondary.connect()
86+
s_cur = s_con.cursor()
87+
88+
logical_replication_sync(vanilla_pg, primary)
89+
90+
assert vanilla_pg.safe_psql("select count(*) from t")[0][0] == n_records
91+
s_cur.execute("select count(*) from t")
92+
assert s_cur.fetchall()[0][0] == n_records
93+
94+
vanilla_pg.stop()
95+
secondary.stop()
96+
primary.stop()
97+
assert not secondary.log_contains("cannot make new WAL entries during recovery")

vendor/revisions.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"v17": [
33
"17.0",
4-
"9ad2f3c5c37c08069a01c1e3f6b7cf275437e0cb"
4+
"ae4cc30dba24f3910533e5a48e8103c3f2fff300"
55
],
66
"v16": [
77
"16.4",
8-
"e131a9c027b202ce92bd7b9cf2569d48a6f9948e"
8+
"03b43900edc5d8d6eecec460bfc89aec7174bd84"
99
],
1010
"v15": [
1111
"15.8",
12-
"22e580fe9ffcea7e02592110b1c9bf426d83cada"
12+
"fd631a959049dfe2b82f67409c8b8b0d3e0016d1"
1313
],
1414
"v14": [
1515
"14.13",
16-
"2199b83fb72680001ce0f43bf6187a21dfb8f45d"
16+
"de0a000dafc2e66ce2e39282d3aa1c704fe0390e"
1717
]
1818
}

0 commit comments

Comments
 (0)