private void maybePerformaPartialRecovery(LogSegment logSegmentToRecover,
      MessageStoreRecovery.RecoveryResult recoveryResult) throws StoreException, IOException {
    // There is no exception, then partial recovery is not necessary
    if (recoveryResult.recoveryException == null) {
      return;
    }
    if (!config.storeEnablePartialLogSegmentRecovery || logSegmentToRecover != log.getLastSegment()) {
      // Partial log segment recovery is not enabled, or the log segment is not the last one
      throw recoveryResult.recoveryException;
    }
    // If we are here, then this is the last log segment.
    long startOffsetForBrokenMessage = recoveryResult.currentStartOffset;
    long endOffset = logSegmentToRecover.sizeInBytes();
    long remainingDataSize = endOffset - startOffsetForBrokenMessage;
    if (remainingDataSize > config.storePartialLogSegmentRecoveryRemainingDataSizeThreshold) {
      throw recoveryResult.recoveryException;
    }
    logger.info("Index: {} Partial LogSegment recovery, log segment {} has valid message until {}, the file size is {}",
        dataDir, logSegmentToRecover.getName(), startOffsetForBrokenMessage, endOffset);
    recoveryFromPartialLogSegmentCounter.incrementAndGet();
    // Since we use fallocate --keep-size to preallocate log segment file, we can truncate log segment file here
    // It will only change the logical file size, not the preallocated disk space.
    logSegmentToRecover.truncateTo(startOffsetForBrokenMessage);
    hasPartialRecovery = true;
  }
Maybe try to recover from partial log segment. Calling this method to see if we should continue recovering messages
from the given {@link com.github.ambry.store.MessageStoreRecovery.RecoveryResult}.
If there is no exception in the result, then continue.
If partial recovery is not enable, or the log segment is not the last log segment, don't continue;
If there are too many bytes in the remainiikng file, don't continue;
@param logSegmentToRecover
@param recoveryResult
@throws StoreException
@throws IOException
ambry-store/src/main/java/com/github/ambry/store/PersistentIndex.java