@Override
    protected void onTruncatePrefix(final long startIndex, final long firstIndexKept) throws RocksDBException,
                                                                                     IOException {
        List<SegmentFile> destroyedFiles = null;
        this.writeLock.lock();
        try {
            int fromIndex = binarySearchFileIndexByLogIndex(startIndex);
            int toIndex = binarySearchFileIndexByLogIndex(firstIndexKept);

            if (fromIndex < 0) {
                fromIndex = 0;
            }
            if (toIndex < 0) {
                // When all the segments contain logs that index is smaller than firstIndexKept,
                // truncate all segments.
                do {
                    if (!this.segments.isEmpty()) {
                        if (getLastSegmentWithoutLock().getLastLogIndex() < firstIndexKept) {
                            toIndex = this.segments.size();
                            break;
                        }
                    }
                    LOG.warn("Segment file not found by logIndex={} to be truncate_prefix, current segments:\n{}.",
                        firstIndexKept, descSegments());
                    return;
                } while (false);
            }

            final List<SegmentFile> removedFiles = this.segments.subList(fromIndex, toIndex);
            destroyedFiles = new ArrayList<>(removedFiles);
            removedFiles.clear();
            doCheckpoint();
        } finally {
            this.writeLock.unlock();
            if (destroyedFiles != null) {
                for (final SegmentFile segmentFile : destroyedFiles) {
                    segmentFile.destroy();
                }
            }
        }
    }
It's wrote position is from start(HEADER_SIZE) but it's not the last file, SHOULD not happen.
jraft-core/src/main/java/com/alipay/sofa/jraft/storage/log/RocksDBSegmentLogStorage.java