protected long recoverFiles(final int startRecoverIndex, final List<AbstractFile> files, long processOffset) {
        AbstractFile preFile = null;
        boolean needTruncate = false;
        for (int index = 0; index < files.size(); index++) {
            final AbstractFile file = files.get(index);
            final boolean isLastFile = index == files.size() - 1;

            if (index < startRecoverIndex) {
                // Update files' s position when don't need to recover
                file.updateAllPosition(getDBFileSize());
            } else {
                final RecoverResult result = file.recover();
                if (result.recoverSuccess()) {
                    if (result.recoverTotal()) {
                        processOffset += isLastFile ? result.getLastOffset() : getDBFileSize();
                    } else {
                        processOffset += result.getLastOffset();
                        needTruncate = true;
                    }
                } else {
                    needTruncate = true;
                }
            }

            if (preFile != null) {
                preFile.setLastLogIndex(file.getFirstLogIndex() - 1);
            }
            preFile = file;

            if (needTruncate) {
                // Error on recover files , truncate to processOffset
                LOG.warn("Try to truncate files to processOffset:{} when recover files", processOffset);
                this.fileManager.truncateSuffixByOffset(processOffset);
                break;
            }
        }
        return processOffset;
    }
Recover files
@return last recover offset
jraft-extension/java-log-storage-impl/src/main/java/com/alipay/sofa/jraft/storage/db/AbstractDB.java