@Override
    public void snapshotState(FunctionSnapshotContext functionSnapshotContext) throws Exception {
        if (handover.hasError()) {
            LOG.debug("snapshotState() called on closed source");
            throw new FlinkRuntimeException(
                    "Call snapshotState() on closed source, checkpoint failed.");
        } else {
            snapshotOffsetState(functionSnapshotContext.getCheckpointId());
            snapshotHistoryRecordsState();
            if (sourceMetricData != null && metricStateListState != null) {
                MetricStateUtils.snapshotMetricStateForSourceMetricData(metricStateListState, sourceMetricData,
                        getRuntimeContext().getIndexOfThisSubtask());
            }
        }
    }
Buffer the events from the source and record the errors from the debezium.
inlong-sort/sort-flink/sort-flink-v1.13/sort-connectors/postgres-cdc/src/main/java/org/apache/inlong/sort/cdc/postgres/DebeziumSourceFunction.java