Skip to content

Commit c4c05a7

Browse files
author
Ibrar Ahmed
committed
Fix InvalidTransactionId handling in failover slot XID comparisons.
1 parent 4060397 commit c4c05a7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/spock_failover_slots.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,9 @@ wait_for_primary_slot_catchup(ReplicationSlot *slot, RemoteSlot *remote_slot)
581581
new_slot->confirmed_lsn = receivePtr;
582582

583583
if (new_slot->restart_lsn >= slot->data.restart_lsn &&
584-
TransactionIdFollowsOrEquals(new_slot->catalog_xmin,
585-
MyReplicationSlot->data.catalog_xmin))
584+
(!TransactionIdIsValid(new_slot->catalog_xmin) ||
585+
TransactionIdFollowsOrEquals(new_slot->catalog_xmin,
586+
MyReplicationSlot->data.catalog_xmin)))
586587
{
587588
remote_slot->restart_lsn = new_slot->restart_lsn;
588589
remote_slot->confirmed_lsn = new_slot->confirmed_lsn;
@@ -699,8 +700,9 @@ synchronize_one_slot(RemoteSlot *remote_slot)
699700
* with our physical replication slot on the master.
700701
*/
701702
if (remote_slot->restart_lsn < MyReplicationSlot->data.restart_lsn ||
702-
TransactionIdPrecedes(remote_slot->catalog_xmin,
703-
MyReplicationSlot->data.catalog_xmin))
703+
(TransactionIdIsValid(remote_slot->catalog_xmin) &&
704+
TransactionIdPrecedes(remote_slot->catalog_xmin,
705+
MyReplicationSlot->data.catalog_xmin)))
704706
{
705707
elog(
706708
WARNING,
@@ -790,8 +792,9 @@ synchronize_one_slot(RemoteSlot *remote_slot)
790792
* synchronized as they will always be behind the physical slot.
791793
*/
792794
if (remote_slot->restart_lsn < MyReplicationSlot->data.restart_lsn ||
793-
TransactionIdPrecedes(remote_slot->catalog_xmin,
794-
MyReplicationSlot->data.catalog_xmin))
795+
(TransactionIdIsValid(remote_slot->catalog_xmin) &&
796+
TransactionIdPrecedes(remote_slot->catalog_xmin,
797+
MyReplicationSlot->data.catalog_xmin)))
795798
{
796799
if (!wait_for_primary_slot_catchup(MyReplicationSlot, remote_slot))
797800
{

0 commit comments

Comments
 (0)