Move replica_promote flag to WalproposerShmemState

This commit is contained in:
Konstantin Knizhnik
2025-05-29 10:08:14 +03:00
committed by Mikhail Kot
parent 2fdcf3e49a
commit 355c4568cf
5 changed files with 6 additions and 14 deletions

View File

@@ -439,6 +439,7 @@ pub fn empty_shmem() -> crate::bindings::WalproposerShmemState {
currentClusterSize: crate::bindings::pg_atomic_uint64 { value: 0 },
shard_ps_feedback: [empty_feedback; 128],
num_shards: 0,
replica_promote: false,
min_ps_feedback: empty_feedback,
}
}

View File

@@ -220,7 +220,6 @@ impl Wrapper {
safekeeper_connection_timeout: config.safekeeper_connection_timeout,
wal_segment_size: WAL_SEGMENT_SIZE as i32, // default 16MB
syncSafekeepers: config.sync_safekeepers,
replicaPromote: false,
systemId: 0,
pgTimeline: 1,
proto_version: 3,

View File

@@ -1380,7 +1380,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->config->syncSafekeepers && !wp->config->replicaPromote)
if (!wp->config->syncSafekeepers && !walprop_shared->replica_promote)
{
/*
* Basebackup LSN always points to the beginning of the record (not

View File

@@ -391,6 +391,7 @@ typedef struct WalproposerShmemState
/* last feedback from each shard */
PageserverFeedback shard_ps_feedback[MAX_SHARDS];
int num_shards;
bool replica_promote;
/* aggregated feedback with min LSNs across shards */
PageserverFeedback min_ps_feedback;
@@ -742,11 +743,6 @@ typedef struct WalProposerConfig
*/
bool syncSafekeepers;
/*
* Replica is promoted to primary
*/
bool replicaPromote;
/* Will be passed to safekeepers in greet request. */
uint64 systemId;

View File

@@ -74,7 +74,6 @@ static XLogRecPtr sentPtr = InvalidXLogRecPtr;
static const walproposer_api walprop_pg;
static volatile sig_atomic_t got_SIGUSR2 = false;
static bool reported_sigusr2 = false;
static bool start_as_replica = false;
static XLogRecPtr standby_flush_lsn = InvalidXLogRecPtr;
static XLogRecPtr standby_apply_lsn = InvalidXLogRecPtr;
@@ -126,7 +125,6 @@ init_walprop_config(bool syncSafekeepers)
walprop_config.safekeeper_connection_timeout = wal_acceptor_connection_timeout;
walprop_config.wal_segment_size = wal_segment_size;
walprop_config.syncSafekeepers = syncSafekeepers;
walprop_config.replicaPromote = start_as_replica;
if (!syncSafekeepers)
walprop_config.systemId = GetSystemIdentifier();
else
@@ -153,8 +151,6 @@ WalProposerSync(int argc, char *argv[])
WalProposerStart(wp);
}
#define GUC_POLL_DELAY 100000L // 0.1 sec
/*
* WAL proposer bgworker entry point.
*/
@@ -322,8 +318,8 @@ assign_neon_safekeepers(const char *newval, void *extra)
char *newval_copy;
char *oldval;
if (newval && *newval == '\0')
start_as_replica = true;
if (newval && *newval != '\0' && walprop_shared && RecoveryInProgress())
walprop_shared->replica_promote = true;
if (!am_walproposer)
return;
@@ -531,6 +527,7 @@ walprop_register_bgworker(void)
bgw.bgw_restart_time = 1;
bgw.bgw_notify_pid = 0;
bgw.bgw_main_arg = (Datum) 0;
RegisterBackgroundWorker(&bgw);
}
@@ -2025,7 +2022,6 @@ walprop_pg_get_redo_start_lsn(WalProposer *wp)
return GetRedoStartLsn();
}
static bool
walprop_pg_strong_random(WalProposer *wp, void *buf, size_t len)
{