Ignore recovery conflict errors

This commit is contained in:
Konstantin Knizhnik
2024-01-25 14:43:15 +02:00
parent 6101e7d981
commit 1e9dac2d0e

View File

@@ -1,5 +1,5 @@
import time
import threading
import time
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnv, PgBin, wait_replica_caughtup
@@ -8,7 +8,6 @@ from fixtures.neon_fixtures import NeonEnv, PgBin, wait_replica_caughtup
def test_replication_lag(neon_simple_env: NeonEnv, pg_bin: PgBin):
env = neon_simple_env
n_iterations = 10
max_retries = 10
# Use aggressive GC and checkpoint settings
tenant, _ = env.neon_cli.create_tenant(
@@ -36,7 +35,9 @@ def test_replication_lag(neon_simple_env: NeonEnv, pg_bin: PgBin):
with env.endpoints.new_replica_start(origin=primary, endpoint_id="secondary") as secondary:
wait_replica_caughtup(primary, secondary)
time.sleep(1) # Without this sleep replica sometime failed to find relation: could not open relation with OID 16404
time.sleep(
1
) # Without this sleep replica sometime failed to find relation: could not open relation with OID 16404
for _ in range(1, n_iterations):
primary_lsn = primary.safe_psql_scalar(
"SELECT pg_current_wal_flush_lsn()::text", log_query=False
@@ -44,19 +45,16 @@ def test_replication_lag(neon_simple_env: NeonEnv, pg_bin: PgBin):
secondary_lsn = secondary.safe_psql_scalar(
"SELECT pg_last_wal_replay_lsn()", log_query=False
)
retries = 0
while True:
try:
balance = secondary.safe_psql_scalar(
"select sum(abalance) from pgbench_accounts"
)
break
except Exception as error:
print(f"Query failed: {error}")
if retries < max_retries:
retries += 1
else:
raise
try:
balance = secondary.safe_psql_scalar(
"select sum(abalance) from pgbench_accounts"
)
except Exception as error:
print(f"Query failed: {error}")
if not str(error).startswith(
"canceling statement due to conflict with recovery"
):
raise
log.info(
f"primary_lsn={primary_lsn}, secondary_lsn={secondary_lsn}, balance={balance}"
)