Class WalPositionLocator

java.lang.Object
io.debezium.connector.postgresql.connection.WalPositionLocator

public class WalPositionLocator extends Object
This class is responsible for finding out a LSN from which Debezium should resume streaming after connector restarts. The LSNs are not guaranteed to be ordered in the WAL. LSN of commits are ordered and LSNs inside a transaction are ordered. It is thus necessary to find out the beginning of the unprocessed transaction and the LSN from which the streaming should start.
Author:
Jiri Pechanec
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • lastCommitStoredLsn

      private final Lsn lastCommitStoredLsn
    • lastEventStoredLsn

      private final Lsn lastEventStoredLsn
    • lastProcessedMessageType

      private final ReplicationMessage.Operation lastProcessedMessageType
    • txStartLsn

      private Lsn txStartLsn
    • lsnAfterLastEventStoredLsn

      private Lsn lsnAfterLastEventStoredLsn
    • firstLsnReceived

      private Lsn firstLsnReceived
    • passMessages

      private boolean passMessages
    • startStreamingLsn

      private Lsn startStreamingLsn
    • storeLsnAfterLastEventStoredLsn

      private boolean storeLsnAfterLastEventStoredLsn
    • lsnSeen

      private Set<Lsn> lsnSeen
  • Constructor Details

    • WalPositionLocator

      public WalPositionLocator(Lsn lastCommitStoredLsn, Lsn lastEventStoredLsn, ReplicationMessage.Operation lastProcessedMessageType)
    • WalPositionLocator

      public WalPositionLocator()
  • Method Details

    • resumeFromLsn

      public Optional<Lsn> resumeFromLsn(Lsn currentLsn, ReplicationMessage message)
      Returns:
      the first LSN from which processing should be started or empty if the position has not been found yet
    • skipMessage

      public boolean skipMessage(Lsn lsn)
      Decides whether the message with given LSN should be removed or not based on previously located LSN point.
      Parameters:
      lsn -
      Returns:
      true if the message should be skipped, false otherwise
    • enableFiltering

      public void enableFiltering()
      Enables filtering of message LSNs based on calculated position.
    • searchingEnabled

      public boolean searchingEnabled()
      Returns:
      true if searching of WAL position should be executed
    • getLastEventStoredLsn

      public Lsn getLastEventStoredLsn()
    • getLastCommitStoredLsn

      public Lsn getLastCommitStoredLsn()
    • toString

      public String toString()
      Overrides:
      toString in class Object