public DbRepairStatus waitDbRepairFinish(boolean forCurrentStateOnly) throws Exception {
    for (int lastProgress = -1; ; Thread.sleep(1000)) {
      DbRepairStatus status = getLastRepairStatus(forCurrentStateOnly);
      if (status == null) {
        log.info(
            "No db repair found(forCurrentStateOnly={})", forCurrentStateOnly ? "true" : "false");
        return null;
      }

      if (status.getStatus() != DbRepairStatus.Status.IN_PROGRESS) {
        log.info(
            "Db repair(forCurrentStateOnly={}) finished with state: {}",
            forCurrentStateOnly ? "true" : "false",
            status.toString());
        return status;
      }

      int newProgress = status.getProgress();
      if (newProgress != lastProgress) {
        log.info("Db repair started at {} is in progress {}%", status.getStartTime(), newProgress);
        lastProgress = newProgress;
      }
    }
  }