KAFKA-20597: Fix prefixScan overflow handling in in-memory state stores#22310
KAFKA-20597: Fix prefixScan overflow handling in in-memory state stores#22310pchintar wants to merge 1 commit into
Conversation
622a262 to
a0acb77
Compare
UladzislauBlok
left a comment
There was a problem hiding this comment.
Left minor comment
LGTM overall
| /** | ||
| * Returns the incremented {@link Bytes} value, or {@code null} if incrementing would overflow. | ||
| */ |
There was a problem hiding this comment.
please keep documentation in same format as for increment method
There was a problem hiding this comment.
Hi @UladzislauBlok thnx for the feedback, I have just updated the comments as you suggested
There was a problem hiding this comment.
I hope my new comments resolved this? thnx
There was a problem hiding this comment.
Hi @UladzislauBlok just a small reminder, could you kindly pls approve and merge my PR if what I've done is adequate enough for approval? thnx.
There was a problem hiding this comment.
Hey
I don't have a write access (I'm not committee yet)
@mjsax
Hello Matthias, sorry for ping this PR was waiting for some time. Can you take a look please. Imo looks good
There was a problem hiding this comment.
@mjsax and @chia7712 and @sjhajharia it's been several days, could you kindly pls respond to this PR? thnx
There was a problem hiding this comment.
@UladzislauBlok they haven't responded yet, I'm new to Kafka community, so what do I do now?
There was a problem hiding this comment.
Hello
We're close to KIP freeze for kafka 4.4, so I think Matthias is busy rn
I suggest to just be patient, and I'm sure PR will be approved.
For example my PR is also already waiting for a week
a0acb77 to
8345245
Compare
| @Test | ||
| public void shouldPrefixScanPrefixWithNoUpperBound() { |
There was a problem hiding this comment.
Should we add similar regression tests for CachingKeyValueStore and MemoryNavigableLRUCache? The fix touches both but their existing prefixScan tests at e.g. https://github.com/apache/kafka/blob/trunk/streams/src/test/java/org/apache/kafka/streams/state/internals/CachingInMemoryKeyValueStoreTest.java#L416 use ASCII prefixes, so the overflow path isn't hit.
There was a problem hiding this comment.
Thanks @Phixsura for the feedback, I've now added focused tests for CachingKeyValueStore and MemoryNavigableLRUCache as well.
The PR now includes overflow-prefix tests for all 3:
InMemoryKeyValueStoreCachingKeyValueStoreMemoryNavigableLRUCache
|
Thanks for the fix. One thought on the test coverage below, no blocker. |
8345245 to
f08806e
Compare
|
@Phixsura I've updated my code by adding test cases to separately check all the 3 ( |
|
Hi @smjn could you kindly, if possible, pls check and approve my PR which has already been peer-reviewed and passes all the CI checks as well? My PR has been hanging out there for a while unf, so I really hope you or someone with access to PR approval can check this out? thnx |
prefixScan currently behaves inconsistently across state store
implementations when the prefix has no lexicographically larger upper
bound.
For example, given the following keys:
Calling
prefixScan(FF)should return:RocksDBStorealready handles this case correctly by treating the upperbound as unbounded when incrementing the prefix overflows.
However,
InMemoryKeyValueStore,MemoryNavigableLRUCache, andCachingKeyValueStoredirectly callByteUtils.increment(...), whichthrows
IndexOutOfBoundsExceptionfor prefixes such as0xFF.This causes
prefixScanto fail before iteration begins for in-memorystate store implementations.
This PR centralizes overflow-safe increment handling in
ByteUtils.incrementWithoutOverflow(...)and updates the affected statestores to use the shared implementation when handling prefixes without
an upper bound.
Regression tests named
shouldPrefixScanPrefixWithNoUpperBoundhavebeen added for each of
InMemoryKeyValueStore,CachingKeyValueStore,and
MemoryNavigableLRUCacheto reproduce the failure for the prefix0xFF.Testing
Before the fix, my regression test failed with
IndexOutOfBoundsException. After the fix, the test passessuccessfully.
Reviewers: Sanskar
Jhajhariasjhajharia@confluent.io,
Chia-Ping Tsai chia7712@gmail.com