Skip to content

KAFKA-20497: Add readOnly(IsolationLevel) to CachingWindowStore#22314

Merged
bbejeck merged 1 commit into
apache:trunkfrom
nicktelford:KIP-892/iq-isolation-caching-window
Jun 2, 2026
Merged

KAFKA-20497: Add readOnly(IsolationLevel) to CachingWindowStore#22314
bbejeck merged 1 commit into
apache:trunkfrom
nicktelford:KIP-892/iq-isolation-caching-window

Conversation

@nicktelford

@nicktelford nicktelford commented May 18, 2026

Copy link
Copy Markdown
Contributor

The cache holds uncommitted writes that must not be visible under
READ_COMMITTED, so that isolation level bypasses the cache entirely and
delegates straight to the inner store's readOnly view. READ_UNCOMMITTED
requires a merged view of both cache and store through a ReadOnlyView.
The ReadOnlyView converts Instant arguments to epoch-milliseconds before
calling the shared fetchInternal/fetchKeyRangeInternal/fetchAllInternal
helpers rather than converting at the merge boundary; the cache key
schema operates in longs throughout, so converting early avoids repeated
Instant-to-long conversions in iterator hot paths.

KAFKA-20497

Reviewers: Bill Bejeck bbejeck@apache.org

@nicktelford

Copy link
Copy Markdown
Contributor Author

@bbejeck

@github-actions github-actions Bot added triage PRs from the community streams labels May 18, 2026
@github-actions

Copy link
Copy Markdown

A label of 'needs-attention' was automatically added to this PR in order to raise the
attention of the committers. Once this issue has been triaged, the triage label
should be removed to prevent this automation from happening again.

@nicktelford nicktelford force-pushed the KIP-892/iq-isolation-caching-window branch from bbbc1ba to 7569338 Compare June 1, 2026 18:08

@bbejeck bbejeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @nicktelford overall looks good. I have a question about the moving the synchronized method modfier.

Also the org.apache.kafka.streams.state.internals.CachingPersistentWindowStoreTest#shouldNotThrowInvalidBackwardRangeExceptionWithNegativeFromKey is failing

@github-actions github-actions Bot removed needs-attention triage PRs from the community labels Jun 2, 2026
@nicktelford nicktelford force-pushed the KIP-892/iq-isolation-caching-window branch 2 times, most recently from a547da6 to 0fecb55 Compare June 2, 2026 11:48
@nicktelford

Copy link
Copy Markdown
Contributor Author

Thanks for the PR @nicktelford overall looks good. I have a question about the moving the synchronized method modfier.

Also the org.apache.kafka.streams.state.internals.CachingPersistentWindowStoreTest#shouldNotThrowInvalidBackwardRangeExceptionWithNegativeFromKey is failing

@bbejeck Fixed the synchronisation, as requested, and rebased on trunk, which should fix the tests.

CachingWindowStore had no isolation-level awareness, so callers could
not bypass the cache to read only committed data, nor could they obtain
a merged (cache + store) view via a typed ReadOnly interface.

This adds readOnly(IsolationLevel) to CachingWindowStore. For
READ_COMMITTED, the call is forwarded directly to the wrapped store,
which excludes anything still in the cache. For READ_UNCOMMITTED, a
private ReadOnlyView is returned; it delegates fetches to the underlying
READ_UNCOMMITTED view of the wrapped store but threads the results
through the existing internal merge helpers (fetchInternal,
fetchKeyRangeInternal, fetchAllInternal, allInternal), so cache entries
are merged with stored entries in the same way as the public API.

As a prerequisite, the duplicated fetch/backwardFetch/all/backwardAll
bodies are consolidated into those shared private helpers, reducing the
surface for future divergence and making the ReadOnlyView delegation
straightforward.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nicktelford nicktelford force-pushed the KIP-892/iq-isolation-caching-window branch from 0fecb55 to a15e31f Compare June 2, 2026 16:24

@bbejeck bbejeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update @nicktelford LGTM

@bbejeck bbejeck merged commit 1d9c3ab into apache:trunk Jun 2, 2026
23 checks passed
@bbejeck

bbejeck commented Jun 2, 2026

Copy link
Copy Markdown
Member

merged #22314 into trunk

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants