aliehsaeedii commented on code in PR #22155:
URL: https://github.com/apache/kafka/pull/22155#discussion_r4585931754
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStateUpdateTask.java:
##########
@@ -118,7 +121,10 @@ public void update(final ConsumerRecord<byte[], byte[]>
record) {
deserialized.offset(),
deserialized.partition(),
deserialized.topic(),
- deserialized.headers());
+ deserialized.headers(),
+ null,
Review Comment:
Now that this uses the full constructor, should the raw key/value be
`record.key()`/`record.value()` too? `GlobalStateManagerImpl#reprocessState`
passes them, so a global processor error sees the raw headers but null raw
key/value here, and the raw bytes during reprocessing.
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/ProcessorContextImpl.java:
##########
@@ -262,7 +262,8 @@ public <K, V> void forward(final Record<K, V> record, final
String childName) {
recordContext.topic(),
record.headers(),
recordContext.sourceRawKey(),
- recordContext.sourceRawValue()
+ recordContext.sourceRawValue(),
+ recordContext.sourceRawHeaders()
Review Comment:
The getter falls back to the old `headers` when there's no snapshot, so this
copies those in as the snapshot. If a punctuator forwards a record with its own
headers, a downstream handler now gets the punctuation's empty headers. Before
this PR it got the forwarded ones. Could we copy the raw field here instead
(e.g. via a package-private accessor), and the same in the cache puts and
`InMemoryTimeOrderedKeyValueChangeBuffer#withHeaders`? A punctuator test would
pin it.
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/RecordQueue.java:
##########
@@ -212,8 +214,9 @@ private void updateHead() {
while (headRecord == null && !fifoQueue.isEmpty()) {
final ConsumerRecord<byte[], byte[]> raw = fifoQueue.pollFirst();
+ final Headers sourceRawHeaders = new RecordHeaders(raw.headers());
Review Comment:
This copies the headers for every record, even when no handler ever runs. Is
that extra allocation OK on the hot path?
##########
streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/ProcessingExceptionHandlerIntegrationTest.java:
##########
@@ -582,6 +660,71 @@ public void configure(final Map<String, ?> configs) {
}
}
+ public static class AssertSourceRawHeadersProcessingExceptionHandler
implements ProcessingExceptionHandler {
Review Comment:
If this handler never runs, the default handler still throws
`StreamsException` and both new tests pass. Could you set a flag in the
handlers and assert it after `assertThrows`, like `isExecuted` above?
--
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]