Pranav Chintareddy created KAFKA-20597:
------------------------------------------
Summary: prefixScan fails for prefixes with no upper bound in
in-memory state stores
Key: KAFKA-20597
URL: https://issues.apache.org/jira/browse/KAFKA-20597
Project: Kafka
Issue Type: Bug
Components: streams
Affects Versions: 4.1.2
Environment: macOS
Java 17
Gradle 9.4.1
Reporter: Pranav Chintareddy
prefixScan currently behaves inconsistently across state store implementations
when the prefix has no lexicographically larger upper bound.
Example keys:
- FF
- FF 00
- FF 10
- FE
Calling prefixScan(FF) should return:
- FF
- FF 00
- FF 10
RocksDBStore handles this case correctly by treating the upper bound as
unbounded when incrementing the prefix overflows.
However, InMemoryKeyValueStore, MemoryNavigableLRUCache, and
CachingKeyValueStore directly call ByteUtils.increment(...), which throws
IndexOutOfBoundsException for prefixes such as 0xFF.
This causes prefixScan to fail before iteration begins.
The fix centralizes overflow-safe increment handling in
ByteUtils.incrementWithoutOverflow(...) and updates the in-memory/cache store
implementations to correctly handle unbounded upper ranges.
A regression test has been added reproducing the failure with prefix 0xFF.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)