private void doSwapOutSegments(final boolean force) {
        if (force) {
            this.readLock.lock();
        } else if (!this.readLock.tryLock()) {
            return;
        }
        try {
            if (this.segments.size() <= this.keepInMemorySegmentCount) {
                return;
            }
            int segmentsInMemeCount = 0;
            int swappedOutCount = 0;
            final long beginTime = Utils.monotonicMs();
            final int lastIndex = this.segments.size() - 1;
            for (int i = lastIndex; i >= 0; i--) {
                SegmentFile segFile = this.segments.get(i);
                if (!segFile.isSwappedOut()) {
                    segmentsInMemeCount++;
                    if (segmentsInMemeCount >= this.keepInMemorySegmentCount && i != lastIndex) {
                        segFile.hintUnload();
                        segFile.swapOut();
                        swappedOutCount++;
                    }
                }
            }
            LOG.info("Swapped out {} segment files, cost {} ms.", swappedOutCount, Utils.monotonicMs() - beginTime);
        } catch (final Exception e) {
            LOG.error("Fail to swap out segments.", e);
        } finally {
            this.readLock.unlock();
        }
    }
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