diff --git a/pgxn/neon/walproposer.c b/pgxn/neon/walproposer.c index dab74fccea..db63b6352f 100644 --- a/pgxn/neon/walproposer.c +++ b/pgxn/neon/walproposer.c @@ -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))); diff --git a/pgxn/neon/walproposer.h b/pgxn/neon/walproposer.h index 83ef72d3d7..69ff5c409f 100644 --- a/pgxn/neon/walproposer.h +++ b/pgxn/neon/walproposer.h @@ -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; diff --git a/pgxn/neon/walproposer_pg.c b/pgxn/neon/walproposer_pg.c index f0f19aea0f..265a5561ad 100644 --- a/pgxn/neon/walproposer_pg.c +++ b/pgxn/neon/walproposer_pg.c @@ -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;