Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit de46a7f

Browse files
committed
Set proper restartLSN foll all neighbors before recovery
1 parent 2426ca9 commit de46a7f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

pglogical_receiver.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@ pglogical_receiver_main(Datum main_arg)
330330
timeline = Mtm->nodes[nodeId-1].timeline;
331331
count = Mtm->recoveryCount;
332332

333+
334+
/* Set proper restartLSN for filtering */
335+
for (i = 0; i < Mtm->nAllNodes; i++)
336+
{
337+
if (i == MtmNodeId - 1)
338+
continue;
339+
Mtm->nodes[i].restartLSN = replorigin_get_progress(Mtm->nodes[i].originId, false);
340+
MTM_LOG1("Node %d restartLSN -> %llx", i + 1, Mtm->nodes[i].restartLSN);
341+
}
342+
333343
/* Establish connection to remote server */
334344
conn = PQconnectdb_safe(connString, 0);
335345
status = PQstatus(conn);
@@ -343,7 +353,7 @@ pglogical_receiver_main(Datum main_arg)
343353
query = createPQExpBuffer();
344354

345355
/* Start logical replication at specified position */
346-
originStartPos = replorigin_get_progress(Mtm->nodes[nodeId-1].originId, false);
356+
originStartPos = Mtm->nodes[nodeId-1].restartLSN;
347357
if (originStartPos == INVALID_LSN || Mtm->nodes[nodeId-1].manualRecovery) {
348358
/*
349359
* We are just creating new replication slot.
@@ -367,12 +377,6 @@ pglogical_receiver_main(Datum main_arg)
367377
PQclear(res);
368378
resetPQExpBuffer(query);
369379
Mtm->nodes[nodeId-1].manualRecovery = false;
370-
} else {
371-
if (Mtm->nodes[nodeId-1].restartLSN < originStartPos) {
372-
MTM_LOG1("Advance restartLSN for node %d: from %llx to %llx (pglogical_receiver_main)", nodeId, Mtm->nodes[nodeId-1].restartLSN, originStartPos);
373-
Mtm->nodes[nodeId-1].restartLSN = originStartPos;
374-
}
375-
MTM_LOG1("Restart logical receiver at position %llx from node %d", originStartPos, nodeId);
376380
}
377381

378382
MTM_LOG1("Start replication on slot %s from node %d at position %llx, mode %s, recovered lsn %llx",

0 commit comments

Comments
 (0)