Skip to content

KAFKA-20158: Fix header-based key deserialization in MeteredSessionStoreWithHeaders iterator methods#21734

Merged
bbejeck merged 2 commits intoapache:trunkfrom
bbejeck:KAFKA-20158_fix_header_based_key_deserialization_in_metered_session_store
Mar 14, 2026
Merged

KAFKA-20158: Fix header-based key deserialization in MeteredSessionStoreWithHeaders iterator methods#21734
bbejeck merged 2 commits intoapache:trunkfrom
bbejeck:KAFKA-20158_fix_header_based_key_deserialization_in_metered_session_store

Conversation

@bbejeck
Copy link
Member

@bbejeck bbejeck commented Mar 12, 2026

Fixes a bug where MeteredSessionStoreWithHeaders iterator methods fail
when key deserializers require headers.

The class inherits iterator-returning methods from
MeteredSessionStore: - fetch(K) / backwardFetch(K) - fetch(K, K) /
backwardFetch(K, K) - findSessions(K, long, long) /
backwardFindSessions(K, long, long) - findSessions(K, K, long, long)
/ backwardFindSessions(K, K, long, long) - findSessions(long, long)

These methods use serdes.keyFrom(bytes, new RecordHeaders()) which
provides empty headers, causing deserialization failures when headers
are required.

The fix overrides each method in MeteredSessionStoreWithHeaders with a
custom iterator that deserializes the value first to extract headers
from AggregationWithHeaders, then uses those headers to deserialize the
key.

This is the session store equivalent of #21705 which fixed the same
issue for MeteredTimestampedWindowStoreWithHeaders.

Reviewers: Matthias Sax mjsax@apache.org

Copy link
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Some minor suggestions. Feel free to merge after addressed.

@bbejeck bbejeck merged commit 9f15f26 into apache:trunk Mar 14, 2026
14 checks passed
@bbejeck bbejeck deleted the KAFKA-20158_fix_header_based_key_deserialization_in_metered_session_store branch March 14, 2026 16:14
@bbejeck
Copy link
Member Author

bbejeck commented Mar 14, 2026

Merged #21734 into trunk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kip Requires or implements a KIP streams

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants