This page is meant as a template for writing a KIP. To create a KIP choose Tools->Copy on this page and modify with your content and replace the heading with the next KIP number and a description of your issue. Replace anything in italics with your own description.
Current state: Under Discussion
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
The log.segment.bytes broker config (and its topic-level synonym segment.bytes) is currently defined as ConfigDef.Type.INT, capping the maximum segment size at Integer.MAX_VALUE (2,147,483,647 bytes, ~2 GB). Additionally, the .index file format stores physical file positions as 4-byte signed integers, which also cannot address beyond ~2 GB.
With modern storage hardware (multi-TB NVMe drives) and high-throughput workloads, the 2 GB cap is increasingly a problem:
.log, .index, .timeindex, .txnindex). A 10 TB partition with 2 GB segments means ~20,000 open files.Allowing segments of 4 GB, 8 GB, or larger would significantly reduce these overheads for high-throughput, large-retention workloads.
Briefly list any new interfaces that will be introduced as part of this proposal or any existing interfaces that will be removed or changed. The purpose of this section is to concisely call out the public contract that will come along with this feature.
A public interface is any change to the following:
Binary log format
The network protocol and api behavior
Any class in the public packages under clientsConfiguration, especially client configuration
org/apache/kafka/common/serialization
org/apache/kafka/common
org/apache/kafka/common/errors
org/apache/kafka/clients/producer
org/apache/kafka/clients/consumer (eventually, once stable)
Monitoring
Command line tools and arguments
Describe the new thing you want to do in appropriate detail. This may be fairly extensive and have large subsections of its own. Or it may be a few sentences. Use judgement based on the scope of the change.
Change log.segment.bytes / segment.bytes from ConfigDef.Type.INT to ConfigDef.Type.LONG. The expanded range (> Integer.MAX_VALUE) is gated by MetadataVersion. Before finalization, the effective range remains [1 MB, Integer.MAX_VALUE]. After IBP_4_4_IV1 is finalized, the range becomes [1 MB, Long.MAX_VALUE].
Widen the internal storage layer types from int to long for segment sizes and physical file positions:
AtomicInteger -> AtomicLong for size tracking. New sizeInBytesLong(), sliceLong(), truncateToLong() methods for callers that need long precision. The existing BaseRecords.sizeInBytes() interface remains int to avoid cascading changes across 449 call sites.sizeInBytesLong() alongside existing size(). recover(), append(), shouldRoll(), read(), truncateTo() all widened to use long for positions and sizes.position field widened from int to long.relativePositionInSegment widened from int to long.maxSegmentBytes widened from int to long.The OffsetIndex supports two entry formats, controlled by a useLargeFormat constructor parameter:
| Format | Entry size | Layout | When used |
|---|---|---|---|
| Legacy (default) | 8 bytes | [4-byte relative offset] [4-byte physical position] | Before IBP_4_4_IV1 finalization |
| Large | 12 bytes | [4-byte relative offset] [8-byte physical position] | After IBP_4_4_IV1 finalization |
The default is legacy format (useLargeFormat=false). All production code paths (via LazyIndex, RemoteIndexCache, DumpLogSegments) create OffsetIndex instances in legacy format. The large format is only used when explicitly opted in via the 5-arg constructor after MetadataVersion verification.
The AbstractIndex base class is enhanced with an effectiveEntrySize() pattern that safely resolves the entry size at construction time without calling overridable methods from the constructor.
A new MetadataVersion entry gates the format change:
IBP_4_4_IV1(32, "4.4", "IV1", true) // didMetadataChange=true
isLargeIndexFormatSupported() helper method returns true when the cluster's MetadataVersion >= IBP_4_4_IV1.didMetadataChange=true ensures downgrade is blocked after finalization, consistent with existing KRaft downgrade rules.New default methods added to the RemoteStorageManager interface with long position parameters:
default InputStream fetchLogSegment(RemoteLogSegmentMetadata metadata, long startPosition)
default InputStream fetchLogSegment(RemoteLogSegmentMetadata metadata, long startPosition, long endPosition)
These delegate to the existing int methods with bounds checking. Existing RemoteStorageManager implementations continue to work unchanged. The old int methods are marked @Deprecated.
| Config | Current type | New type | Current range | New range |
|---|---|---|---|---|
log.segment.bytes (broker) | INT | LONG | [1 MB, 2,147,483,647] | [1 MB, Long.MAX_VALUE] (after MetadataVersion finalization) |
segment.bytes (topic) | INT | LONG | [1 MB, 2,147,483,647] | [1 MB, Long.MAX_VALUE] (after MetadataVersion finalization) |
Offset index (.index) file format -- new 12-byte entry format (gated by MetadataVersion):
| Field | Legacy (8 bytes) | Large (12 bytes) |
|---|---|---|
| Relative offset | 4-byte int | 4-byte int |
| Physical position | 4-byte int (max ~2 GB) | 8-byte long (unlimited) |
Time index (.timeindex) -- no format change. Entry size is already 12 bytes (8-byte timestamp + 4-byte relative offset).
Transaction index (.txnindex) -- no format change.
| Class | Member | Before | After |
|---|---|---|---|
LogConfig | DEFAULT_SEGMENT_BYTES | int | long |
LogConfig | segmentSize() | returns int | returns long |
LogConfig | initFileSize() | returns int | returns long |
AbstractKafkaConfig | logSegmentBytes() | returns Integer via getInt() | returns Long via getLong() |
RollParams | maxSegmentBytes | int | long |
OffsetIndex | append(long offset, ...) | int position | long position |
OffsetPosition | position field | int | long |
FileRecords | internal size field | AtomicInteger | AtomicLong |
LogSegment | sizeInBytesLong() | N/A (new) | returns long |
LogSegment | recover() | returns int | returns long |
LogSegment | truncateTo() | returns int | returns long |
LogOffsetMetadata | relativePositionInSegment | int | long |
SegmentPosition (raft) | relativePosition | int | long |
RemoteStorageManager | fetchLogSegment(metadata, int) | only overload | @Deprecated; new default method with long |
BaseRecords.sizeInBytes() remains int (449 callers across 89 files -- too large to cascade).RecordBatch.sizeInBytes() remains int (bounded by max.message.bytes).MemoryRecords.sizeInBytes() remains int (bounded by ByteBuffer capacity).transaction.state.log.segment.bytes, offsets.topic.segment.bytes) remain INT.kafka-features.sh upgrade --release-version 4.4.LogSegment.recover()), it is written in the new format.segment.bytes config upper bound is lifted.IBP_4_4_IV1 has didMetadataChange=true), consistent with existing KRaft downgrade rules.INT values stored as strings (e.g., "1073741824") parse correctly as LONG.int methods. The new long default methods delegate to the old int methods with bounds checking.| Scenario | Result |
|---|---|
| Old broker -> New broker (same data) | All produce/consume works. Indexes unchanged (legacy format). |
| New broker -> Old broker (same data) | All produce/consume works. Old broker reads legacy-format data written by new broker. |
| Dynamic config 1GB -> 4GB -> 1GB | Segments roll at correct sizes. Consumer reads across mixed segment sizes. |
| 300 MB/s produce with 4GB segments | 4GB segments created successfully. Data integrity verified. |
Describe in few sentences how the KIP will be tested. We are mostly interested in system tests (since unit-tests are specific to implementation details). How will we know that the implementation works as expected? How will we know nothing broke?
If there are alternative ways of accomplishing the same thing, what were they? The purpose of this section is to motivate why the design is the way it is and not some other way.
Rejected. The 2 GB limit is an artificial constraint from a type choice made when storage was smaller. Modern deployments routinely manage multi-TB partitions where 2 GB segments create excessive overhead.
log.segment.bytes.long configRejected. Maintaining two configs for the same purpose adds confusion. A single config with a type change is cleaner and follows the precedent set by KIP-1161 (STRING to LIST type reclassification).
Rejected. The relative offset (4 bytes) is sufficient -- it represents the delta from the segment base offset, not an absolute offset. Only the physical position needs widening to 8 bytes.
Rejected. Java does not natively support unsigned integers, making the code error-prone. Widening to long is the clean solution and future-proofs the format.
Rejected as the complete approach. While Phase 1 (config type change with INT range cap) is useful as a stepping stone, it doesn't deliver the actual user-facing value of larger segments. A single KIP covering the full scope ensures the community reviews the complete design.
Rejected. An earlier prototype used a .index_version marker file in each partition directory to track whether indexes had been rebuilt in the new format. This approach was rejected because:
Rejected. Adding a version byte at the start of each index file would allow self-describing format detection, but:
sanityCheck catches it.