public void checkAndUpdateSearchIndex() {
    long currentSearchIndex = searchIndex.get();
    long safelyDeletedSearchIndex = getMinFlushedSyncIndex();
    if (currentSearchIndex < safelyDeletedSearchIndex) {
      logger.warn(
          "The searchIndex for this region({}) is smaller than the safelyDeletedSearchIndex when "
              + "the node is restarted, which means that the data of the current region is not flushed "
              + "by the wal, but has been synchronized to other nodes. At this point, "
              + "different replicas have been inconsistent and cannot be automatically recovered. "
              + "To prevent subsequent logs from marking smaller searchIndex and exacerbating the "
              + "inconsistency, we manually set the searchIndex({}) to safelyDeletedSearchIndex({}) "
              + "here to reduce the impact of this problem in the future",
          consensusGroupId,
          currentSearchIndex,
          safelyDeletedSearchIndex);
      searchIndex.set(safelyDeletedSearchIndex);
    }
  }
If there is only one replica, set it to Long.MAX_VALUE. If there are multiple replicas, get the
latest SafelyDeletedSearchIndex again. This enables wal to be deleted in a timely manner.
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/IoTConsensusServerImpl.java