aliehsaeedii commented on code in PR #24253:
URL: https://github.com/apache/kafka/pull/24253#discussion_r4588399696
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/KeyValueToTimestampedKeyValueByteStoreAdapter.java:
##########
@@ -254,4 +256,56 @@ public KeyValue<Bytes, byte[]> next() {
return KeyValue.pair(next.key,
convertToTimestampedFormat(next.value));
}
}
-}
\ No newline at end of file
+
+ @Override
+ public ReadOnlyKeyValueStore<Bytes, byte[]> readOnly(final IsolationLevel
isolationLevel) {
Review Comment:
The in-memory branch of the same builders has this gap too:
`InMemoryTimestampedKeyValueStoreMarker` (and the other four `InMemory*Marker`
classes in the timestamped/headers builders) don't override `readOnly`, but
`InMemoryKeyValueStore`/`InMemoryWindowStore`/`InMemorySessionStore` do honour
the isolation level. So a DSL store backed by
`Stores.inMemoryKeyValueStore(...)` still returns `this` and READ_COMMITTED
sees staged writes. Can you fix the markers here too?
##########
streams/src/test/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapterTest.java:
##########
@@ -359,4 +362,15 @@ public void shouldReportRetentionPeriodOfUnderlyingStore()
{
assertInstanceOf(WithRetentionPeriod.class, store);
assertEquals(RETENTION_PERIOD, ((WithRetentionPeriod)
store).retentionPeriod());
}
+
+ @Test
+ public void shouldPropagateReadOnlyToInnerStoreWithFormatConversion() {
+ underlyingStore.put(KEY, PLAIN_VALUE, 1000L);
Review Comment:
This store isn't transactional (`enable.transactional.statestores` is off),
so READ_COMMITTED and READ_UNCOMMITTED read the same data and the value check
passes even without the fix; only `assertNotSame` fails. Can you turn the
config on, put without committing, and assert READ_COMMITTED doesn't see the
write while READ_UNCOMMITTED does? That's the bug this PR fixes (same for
`TimestampedToHeadersWindowStoreAdapterTest`).
##########
streams/src/main/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapter.java:
##########
@@ -32,6 +33,7 @@
import org.apache.kafka.streams.state.KeyValueIterator;
import org.apache.kafka.streams.state.TimestampedBytesStore;
import org.apache.kafka.streams.state.TimestampedWindowStoreWithHeaders;
+import org.apache.kafka.streams.state.ReadOnlyWindowStore;
Review Comment:
`spotlessCheck` fails on this PR (import order here, in
`TimestampedToHeadersWindowStoreAdapter`, and in five of the test files).
Please run `./gradlew spotlessApply`.
##########
streams/src/test/java/org/apache/kafka/streams/state/internals/PlainToHeadersWindowStoreAdapterTest.java:
##########
@@ -359,4 +362,15 @@ public void shouldReportRetentionPeriodOfUnderlyingStore()
{
assertInstanceOf(WithRetentionPeriod.class, store);
assertEquals(RETENTION_PERIOD, ((WithRetentionPeriod)
store).retentionPeriod());
}
+
+ @Test
+ public void shouldPropagateReadOnlyToInnerStoreWithFormatConversion() {
+ underlyingStore.put(KEY, PLAIN_VALUE, 1000L);
+
+ final ReadOnlyWindowStore<Bytes, byte[]> view =
adapter.readOnly(IsolationLevel.READ_COMMITTED);
+
+ assertNotSame(adapter, view);
+ assertArrayEquals(convertFromPlainToHeaderFormat(PLAIN_VALUE),
view.fetch(KEY, 1000L));
Review Comment:
Each new test only checks the single-key read on the view
(`get`/`fetch`/`fetchSession`); none of the iterator methods are tested, so a
wrong wrapper (e.g. `plainToHeaders` vs `plainToHeadersWindow`) wouldn't be
caught. Could you add a parameterized test over the view's methods, like
`shouldConvertValue` does for the adapter?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]