public void truncateSuffixByOffset(final long offset) {
        this.readLock.lock();
        final ArrayList<AbstractFile> willRemoveFiles = new ArrayList<>();
        try {
            for (final AbstractFile file : this.files) {
                final long tailOffset = file.getFileFromOffset() + this.fileSize;
                if (tailOffset > offset) {
                    if (offset >= file.getFileFromOffset()) {
                        final int truncatePosition = (int) (offset % this.fileSize);
                        file.setWrotePosition(truncatePosition);
                        file.setFlushPosition(truncatePosition);
                    } else {
                        willRemoveFiles.add(file);
                    }
                }
            }
        } finally {
            this.readLock.unlock();
            for (final AbstractFile file : willRemoveFiles) {
                if (file != null) {
                    file.shutdown(1000, true);
                }
            }
            deleteFiles(willRemoveFiles);
        }
    }
Truncate files suffix by offset
Only be called when recover
jraft-extension/java-log-storage-impl/src/main/java/com/alipay/sofa/jraft/storage/file/FileManager.java