@Override
    public void remove(long offset) {
        synchronized (this) {
            if (null != activeSegment && offset == activeSegment.baseOffset()) {
                activeSegment = super.lastSegment().orElse(null);
            }
            super.remove(offset);
        }
    }
Its [[LogSegment.baseOffset]] will always be the largest one among all segments.
core/src/main/scala/kafka/log/streamaspect/CachedLogSegments.java