SouquieresAdam opened a new pull request, #22590:
URL: https://github.com/apache/kafka/pull/22590

   ## Summary
   
   [KAFKA-20699](https://issues.apache.org/jira/browse/KAFKA-20699). A 
regression introduced by KAFKA-19638 (#20403): 
`TopologyTestDriver#getStateStore` now sets a dummy `ProcessorRecordContext` 
(`null` topic, `-1` offset/partition, timestamp `0`) **unconditionally** and 
never restores it. Before KAFKA-19638 the dummy context was set once at task 
construction and `getStateStore` was read-only.
   
   As a result, a store lookup mutates the task's live record context as a side 
effect. When a store handle is fetched while a record's context is active — an 
interactive query interleaved with processing, or a test seam that resolves a 
store handle through TTD from production code — the in-flight record's 
`RecordMetadata` is wiped: `recordMetadata().topic()` returns `null` and 
offset/partition become `-1`. Code building provenance from 
`recordMetadata().topic()` then fails, and direct store writes capture 
timestamp `0`.
   
   The normal `process()` path masks this because `doProcess` rebuilds the 
context per record, so it surfaces on direct store writes after a lookup and on 
any context read not preceded by a fresh `process()`.
   
   ## Fix
   
   Only materialize the dummy context when none exists yet (before any record 
has been processed); never overwrite a live one. Direct store access still 
works, while an in-flight record's context is left intact.
   
   ## Testing
   
   Added `shouldNotResetRecordContextWhenAccessingStateStore` to 
`TopologyTestDriverTest` (runs under both at-least-once and EOS). It processes 
a record at stream-time 5000, then grabs the store handle and writes directly 
to it; the write must be logged to the changelog at 5000. Fails before the fix 
(`expected: <5000> but was: <0>`), passes after. Full 
`:streams:test-utils:test` + checkstyle + spotbugs pass.


-- 
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]

Reply via email to