Class GtidUtils


  • public class GtidUtils
    extends Object
    Utils for handling GTIDs.
    • Constructor Summary

      Constructors 
      Constructor Description
      GtidUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static io.debezium.connector.mysql.GtidSet computeLatestModeGtidSet​(io.debezium.connector.mysql.GtidSet availableServerGtidSet, io.debezium.connector.mysql.GtidSet purgedServerGtid, io.debezium.connector.mysql.GtidSet checkpointGtidSet, java.util.function.Predicate<String> gtidSourceFilter)
      Computes the merged GTID set for the LATEST new-channel-position mode.
      static io.debezium.connector.mysql.GtidSet fixOldChannelsGtidSet​(io.debezium.connector.mysql.GtidSet availableServerGtidSet, io.debezium.connector.mysql.GtidSet purgedServerGtid, io.debezium.connector.mysql.GtidSet checkpointGtidSet)
      Fixes old channels' GTID ranges by filling prefix gaps using server GTID intervals.
      static io.debezium.connector.mysql.GtidSet fixRestoredGtidSet​(io.debezium.connector.mysql.GtidSet serverGtidSet, io.debezium.connector.mysql.GtidSet restoredGtidSet)
      This method corrects the GTID set that has been restored from a state or checkpoint using the GTID set fetched from the server via SHOW MASTER STATUS.
      static io.debezium.connector.mysql.GtidSet mergeGtidSetInto​(io.debezium.connector.mysql.GtidSet base, io.debezium.connector.mysql.GtidSet toMerge)
      This method merges one GTID set (toMerge) into another (base), without overwriting the existing elements in the base GTID set.
    • Constructor Detail

      • GtidUtils

        public GtidUtils()
    • Method Detail

      • fixOldChannelsGtidSet

        public static io.debezium.connector.mysql.GtidSet fixOldChannelsGtidSet​(io.debezium.connector.mysql.GtidSet availableServerGtidSet,
                                                                                io.debezium.connector.mysql.GtidSet purgedServerGtid,
                                                                                io.debezium.connector.mysql.GtidSet checkpointGtidSet)
        Fixes old channels' GTID ranges by filling prefix gaps using server GTID intervals.

        This is the shared logic between EARLIEST and LATEST modes. For UUIDs present in the checkpoint, non-contiguous GTID ranges are corrected via fixRestoredGtidSet(io.debezium.connector.mysql.GtidSet, io.debezium.connector.mysql.GtidSet) to avoid MySQL replaying pre-checkpoint transactions.

        Parameters:
        availableServerGtidSet - the relevant (filtered) server GTID set
        purgedServerGtid - the GTID set already purged from the MySQL server
        checkpointGtidSet - the GTID set restored from checkpoint
        Returns:
        the fixed GTID set for old channels
      • computeLatestModeGtidSet

        public static io.debezium.connector.mysql.GtidSet computeLatestModeGtidSet​(io.debezium.connector.mysql.GtidSet availableServerGtidSet,
                                                                                   io.debezium.connector.mysql.GtidSet purgedServerGtid,
                                                                                   io.debezium.connector.mysql.GtidSet checkpointGtidSet,
                                                                                   java.util.function.Predicate<String> gtidSourceFilter)
        Computes the merged GTID set for the LATEST new-channel-position mode.

        For old channels (UUIDs present in checkpoint), non-contiguous GTID ranges are fixed via fixOldChannelsGtidSet(io.debezium.connector.mysql.GtidSet, io.debezium.connector.mysql.GtidSet, io.debezium.connector.mysql.GtidSet). For new channels (UUIDs not in checkpoint), the server's full GTID is used to skip all history.

        Parameters:
        availableServerGtidSet - the GTID set currently available on the MySQL server
        purgedServerGtid - the GTID set already purged from the MySQL server
        checkpointGtidSet - the GTID set restored from checkpoint (after source filter applied)
        gtidSourceFilter - optional predicate to filter GTID source UUIDs; may be null
        Returns:
        the merged GTID set suitable for binlog subscription
      • fixRestoredGtidSet

        public static io.debezium.connector.mysql.GtidSet fixRestoredGtidSet​(io.debezium.connector.mysql.GtidSet serverGtidSet,
                                                                             io.debezium.connector.mysql.GtidSet restoredGtidSet)
        This method corrects the GTID set that has been restored from a state or checkpoint using the GTID set fetched from the server via SHOW MASTER STATUS. During the correction process, the restored GTID set is adjusted according to the server's GTID set to ensure it does not exceed the latter. For each UUID in the restored GTID set, if it exists in the server's GTID set, then it will be adjusted according to the server's GTID set; if it does not exist in the server's GTID set, it will be directly added to the new GTID set.
      • mergeGtidSetInto

        public static io.debezium.connector.mysql.GtidSet mergeGtidSetInto​(io.debezium.connector.mysql.GtidSet base,
                                                                           io.debezium.connector.mysql.GtidSet toMerge)
        This method merges one GTID set (toMerge) into another (base), without overwriting the existing elements in the base GTID set.