[
https://issues.apache.org/jira/browse/KAFKA-21505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146001#comment-18146001
]
eatmoreduck commented on KAFKA-21505:
-------------------------------------
Hi, I'd like to work on this issue. I've posted a PR that propagates
{{readOnly(IsolationLevel)}} through all seven format-converting adapters (the
five headers-aware ones named in the description, plus the two older
timestamped adapters mentioned under "Related"):
https://github.com/apache/kafka/pull/24253
Each adapter now delegates to the inner store's read-only view and applies its
format conversion on top, so a READ_COMMITTED read through an adapter no longer
goes through the inner store's transaction buffer and cannot see uncommitted
writes. Tests cover each adapter.
One note: the CompletenessTest SPECIAL cleanups suggested in the description
are not included, since KAFKA-20328 (PR #22992) is not merged into trunk yet —
those tests don't exist on trunk today.
Happy to adjust if reviewers prefer a different direction.
> Headers-aware store adapters don't propagate readOnly(IsolationLevel), so
> READ_COMMITTED reads see uncommitted writes
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-21505
> URL: https://issues.apache.org/jira/browse/KAFKA-21505
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Affects Versions: 4.4.0
> Reporter: Alieh Saeedi
> Priority: Minor
>
> When a headers-aware store is built on top of a store in the old
> (non-headers) format, the builder inserts a format-converting adapter between
> the outer layers and the inner store:
> - PlainToHeadersStoreAdapter, TimestampedToHeadersStoreAdapter
> (TimestampedKeyValueStoreBuilderWithHeaders)
> - PlainToHeadersWindowStoreAdapter, TimestampedToHeadersWindowStoreAdapter
> (TimestampedWindowStoreWithHeadersBuilder)
> - SessionToHeadersStoreAdapter (SessionStoreWithHeadersBuilder)
> None of these adapters override readOnly(IsolationLevel), so they inherit the
> interface default, which returns `this`.
> With enable.transactional.statestores=true, the outer layers (metered,
> change-logging, caching) pass readOnly(level) down to their inner store, and
> the RocksDB stores (RocksDBStore, RocksDBWindowStore, RocksDBSessionStore)
> override it so that READ_COMMITTED skips the transaction buffer. The chain
> stops at the adapter: it returns itself, and reads keep going through the
> inner store's transaction buffer. A READ_COMMITTED read therefore sees writes
> that have not been committed yet.
> Cause: the adapters (KAFKA-20134, KAFKA-20158) were added before
> readOnly(IsolationLevel) was introduced for these store types (KAFKA-20496,
> KAFKA-20768), and they were not updated when it was.
> Affected only when all of these hold:
> - enable.transactional.statestores=true
> - a headers-aware store is backed by a store in the old format (adapter path)
> - the store is read with READ_COMMITTED
> Proposed fix: override readOnly(IsolationLevel) in each adapter to call
> inner.readOnly(level) and wrap the result in the same format conversion the
> adapter applies to normal reads. Then remove readOnly from SPECIAL in
> TimestampedToHeadersWindowStoreAdapterCompletenessTest and
> SessionToHeadersStoreAdapterCompletenessTest (added in KAFKA-20328,
> https://github.com/apache/kafka/pull/22992), and add a test that a
> READ_COMMITTED view through each adapter does not see staged writes.
> Related: the older timestamped adapters
> (KeyValueToTimestampedKeyValueByteStoreAdapter,
> WindowToTimestampedWindowByteStoreAdapter) do not override readOnly either
> and may have the same gap.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)