Undo adding set_redo_start_lsn function to walproposer API

This commit is contained in:
Konstantin Knizhnik
2025-05-18 17:06:26 +03:00
parent b94054dca0
commit d7cecc485c
4 changed files with 25 additions and 28 deletions

View File

@@ -1379,12 +1379,7 @@ ProcessPropStartPos(WalProposer *wp)
* we must bail out, as clog and other non rel data is inconsistent.
*/
walprop_shared = wp->api.get_shmem_state(wp);
if (wp->api.get_shmem_state(wp)->bgw_started)
{
/* Replica promotion */
wp->api.set_redo_start_lsn(wp, wp->propTermStartLsn);
}
else if (!wp->config->syncSafekeepers)
if (!wp->config->syncSafekeepers && !wp->api.get_shmem_state(wp)->bgw_started)
{
/*
* Basebackup LSN always points to the beginning of the record (not

View File

@@ -675,12 +675,6 @@ typedef struct walproposer_api
*/
XLogRecPtr (*get_redo_start_lsn) (WalProposer *wp);
/*
* Get a basebackup LSN. Used to cross-validate with the latest available
* LSN on the safekeepers.
*/
void (*set_redo_start_lsn) (WalProposer *wp, XLogRecPtr lsn);
/*
* Finish sync safekeepers with the given LSN. This function should not
* return and should exit the program.

View File

@@ -2040,13 +2040,6 @@ walprop_pg_get_redo_start_lsn(WalProposer *wp)
return GetRedoStartLsn();
}
static void
walprop_pg_set_redo_start_lsn(WalProposer *wp, XLogRecPtr lsn)
{
#if PG_VERSION_NUM >= 150000
SetRedoStartLsn(lsn);
#endif
}
static bool
walprop_pg_strong_random(WalProposer *wp, void *buf, size_t len)
@@ -2103,7 +2096,6 @@ static const walproposer_api walprop_pg = {
.wait_event_set = walprop_pg_wait_event_set,
.strong_random = walprop_pg_strong_random,
.get_redo_start_lsn = walprop_pg_get_redo_start_lsn,
.set_redo_start_lsn = walprop_pg_set_redo_start_lsn,
.finish_sync_safekeepers = walprop_pg_finish_sync_safekeepers,
.process_safekeeper_feedback = walprop_pg_process_safekeeper_feedback,
.log_internal = walprop_pg_log_internal,

View File

@@ -5,12 +5,14 @@ This far, only contains a test that we don't break and that the data is persiste
"""
import psycopg2
import pytest
import time
from fixtures.neon_fixtures import Endpoint, NeonEnv, wait_replica_caughtup
from fixtures.pg_version import PgVersion
from fixtures.log_helper import log
from pytest import raises
@pytest.mark.timeout(6000)
def test_replica_promotes(neon_simple_env: NeonEnv, pg_version: PgVersion):
"""
Test that a replica safely promotes, and can commit data updates which
@@ -79,18 +81,32 @@ def test_replica_promotes(neon_simple_env: NeonEnv, pg_version: PgVersion):
secondary_cur.execute(f"alter system set neon.safekeepers='{safekeepers}'")
secondary_cur.execute("select pg_reload_conf()");
new_primary_conn = secondary.connect()
new_primary = secondary
old_primary = primary
new_primary_conn = new_primary.connect()
new_primary_cur = new_primary_conn.cursor()
new_primary_cur.execute("INSERT INTO t (payload) SELECT generate_series(101, 200)")
new_primary_cur.execute("select count(*) from t")
assert new_primary_cur.fetchone() == (200,)
new_primary_cur.execute("select pg_current_wal_flush_lsn()")
lsn = new_primary_cur.fetchall()[0][0]
log.info(f"New primary flush LSN={lsn}")
secondary.stop(mode="immediate")
new_primary.stop(mode="immediate")
new_primary.hot_standby = False
new_primary.start()
primary.start()
with new_primary.connect() as new_primary_conn:
new_primary_cur = new_primary_conn.cursor()
new_primary_cur.execute("select count(*) from t")
assert new_primary_cur.fetchone() == (200,)
with primary.connect() as primary_conn:
primary_cur = primary_conn.cursor()
primary_cur.execute("select count(*) from t")
assert primary_cur.fetchone() == (200,)
new_primary.stop()
old_primary.start()
with old_primary.connect() as old_primary_conn:
old_primary_cur = old_primary_conn.cursor()
old_primary_cur.execute("select count(*) from t")
assert old_primary_cur.fetchone() == (200,)