Refactor follow verification to reduce need for CHECKPOINT

A CHECKPOINT is not always required; hopefully we can narrow it down
to one corner case where we need to determine the minium recovery
location.

Also get local timeline ID via IDENTIFY_SYSTEM, as fetching it from
pg_control risks returning the prior timeline ID if the timeline
switch has just taken place and no restart point has yet occurred.
This commit is contained in:
Ian Barwick
2018-12-04 15:26:05 +09:00
parent 10d46f7e85
commit 313aa3c5d7
2 changed files with 136 additions and 44 deletions

View File

@@ -1624,7 +1624,7 @@ get_timeline_history(PGconn *repl_conn, TimeLineID tli)
termPQExpBuffer(&query);
if (PQnfields(res) != 2 || PQntuples(res) != 1)
if (PQntuples(res) != 1 || PQnfields(res) != 2)
{
log_error(_("unexpected response to TIMELINE_HISTORY command"));
log_detail(_("got %i rows and %i fields, expected %i rows and %i fields"),
@@ -1645,12 +1645,13 @@ get_timeline_history(PGconn *repl_conn, TimeLineID tli)
return NULL;
}
PQclear(res);
history = (TimeLineHistoryEntry *) palloc(sizeof(TimeLineHistoryEntry));
history->tli = file_tli;
history->begin = InvalidXLogRecPtr; /* we don't care about this */
history->end = ((uint64) (switchpoint_hi)) << 32 | (uint64) switchpoint_lo;
PQclear(res);
return history;
}