Use GetXLogReplayRecPtr only for replicas

This commit is contained in:
Konstantin Knizhnik
2024-01-23 14:26:22 +02:00
parent 9d984edf54
commit a5e06a3ea7
2 changed files with 7 additions and 9 deletions

View File

@@ -113,9 +113,9 @@ static bool (*old_redo_read_buffer_filter) (XLogReaderState *record, uint8 block
#define MAX_LSN ((XLogRecPtr)~0)
static XLogRecPtr
neon_get_horizon(bool latest)
neon_get_horizon(XLogRecPtr lsn, bool latest)
{
return latest ? MAX_LSN : GetXLogReplayRecPtr(NULL);
return latest ? MAX_LSN : RecoveryInProgress() ? GetXLogReplayRecPtr(NULL) : lsn;
}
/*
@@ -735,7 +735,7 @@ prefetch_do_request(PrefetchRequest *slot, bool *force_latest, XLogRecPtr *force
prefetch_lsn = Max(prefetch_lsn, lsn);
slot->effective_request_lsn = prefetch_lsn;
}
request.req.horizon = neon_get_horizon(latest);
request.req.horizon = neon_get_horizon(request.req.lsn, latest);
Assert(slot->response == NULL);
Assert(slot->my_ring_index == MyPState->ring_unused);
@@ -1664,7 +1664,7 @@ neon_exists(SMgrRelation reln, ForkNumber forkNum)
{
NeonExistsRequest request = {
.req.tag = T_NeonExistsRequest,
.req.horizon = neon_get_horizon(latest),
.req.horizon = neon_get_horizon(request_lsn, latest),
.req.lsn = request_lsn,
.rinfo = InfoFromSMgrRel(reln),
.forknum = forkNum};
@@ -2473,7 +2473,7 @@ neon_nblocks(SMgrRelation reln, ForkNumber forknum)
{
NeonNblocksRequest request = {
.req.tag = T_NeonNblocksRequest,
.req.horizon = neon_get_horizon(latest),
.req.horizon = neon_get_horizon(request_lsn, latest),
.req.lsn = request_lsn,
.rinfo = InfoFromSMgrRel(reln),
.forknum = forknum,
@@ -2530,7 +2530,7 @@ neon_dbsize(Oid dbNode)
{
NeonDbSizeRequest request = {
.req.tag = T_NeonDbSizeRequest,
.req.horizon = neon_get_horizon(latest),
.req.horizon = neon_get_horizon(request_lsn, latest),
.req.lsn = request_lsn,
.dbNode = dbNode,
};
@@ -2979,7 +2979,7 @@ neon_extend_rel_size(NRelFileInfo rinfo, ForkNumber forknum, BlockNumber blkno,
NeonNblocksRequest request = {
.req = (NeonRequest) {
.lsn = end_recptr,
.horizon = neon_get_horizon(false),
.horizon = neon_get_horizon(end_recptr, false),
.tag = T_NeonNblocksRequest,
},
.rinfo = rinfo,

View File

@@ -1,5 +1,4 @@
import threading
import time
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnv, PgBin
@@ -34,7 +33,6 @@ def test_replication_lag(neon_simple_env: NeonEnv, pg_bin: PgBin):
t.start()
with env.endpoints.new_replica_start(origin=primary, endpoint_id="secondary") as secondary:
time.sleep(10)
for _ in range(1, n_iterations):
primary_lsn = primary.safe_psql_scalar(
"SELECT pg_current_wal_flush_lsn()::text", log_query=False