diff --git a/pgxn/neon/walproposer.c b/pgxn/neon/walproposer.c index 4bcbe9078a..4a8b684eb9 100644 --- a/pgxn/neon/walproposer.c +++ b/pgxn/neon/walproposer.c @@ -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) + if (!wp->config->syncSafekeepers && !wp->config->replicaPromote) { /* * Basebackup LSN always points to the beginning of the record (not @@ -1407,8 +1407,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))); diff --git a/pgxn/neon/walproposer.h b/pgxn/neon/walproposer.h index cca20e746b..82e491abad 100644 --- a/pgxn/neon/walproposer.h +++ b/pgxn/neon/walproposer.h @@ -742,6 +742,11 @@ typedef struct WalProposerConfig */ bool syncSafekeepers; + /* + * Replica is promoted to primary + */ + bool replicaPromote; + /* Will be passed to safekeepers in greet request. */ uint64 systemId; diff --git a/pgxn/neon/walproposer_pg.c b/pgxn/neon/walproposer_pg.c index daacf9f035..e983753021 100644 --- a/pgxn/neon/walproposer_pg.c +++ b/pgxn/neon/walproposer_pg.c @@ -74,6 +74,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; @@ -125,6 +126,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 @@ -319,6 +321,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;