Add replicaPromote flag to walproposer config

This commit is contained in:
Konstantin Knizhnik
2025-05-28 08:57:59 +03:00
parent e084c12ef6
commit 5ef5bc6c2b
3 changed files with 13 additions and 3 deletions

View File

@@ -1379,7 +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->config->syncSafekeepers)
if (!wp->config->syncSafekeepers && !wp->config->replicaPromote)
{
/*
* Basebackup LSN always points to the beginning of the record (not
@@ -1406,8 +1406,8 @@ ProcessPropStartPos(WalProposer *wp)
* However, don't dump core as this is kinda expected
* scenario.
*/
//disable_core_dump();
wp_log(LOG,
disable_core_dump();
wp_log(PANIC,
"collected propTermStartLsn %X/%X, but basebackup LSN %X/%X",
LSN_FORMAT_ARGS(wp->propTermStartLsn),
LSN_FORMAT_ARGS(wp->api.get_redo_start_lsn(wp)));

View File

@@ -739,6 +739,11 @@ typedef struct WalProposerConfig
*/
bool syncSafekeepers;
/*
* Replica is promoted to primary
*/
bool replicaPromote;
/* Will be passed to safekeepers in greet request. */
uint64 systemId;

View File

@@ -73,6 +73,7 @@ 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;
@@ -123,6 +124,7 @@ 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
@@ -307,6 +309,9 @@ assign_neon_safekeepers(const char *newval, void *extra)
char *newval_copy;
char *oldval;
if (newval && *newval == '\0')
start_as_replica = true;
if (!am_walproposer)
return;