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

   `StreamTask#punctuate` sets a dummy `ProcessorRecordContext` (null topic, -1 
partition and -1 offset), so records forwarded from a punctuator keep the 
punctuation timestamp. `ProcessorContext#recordMetadata` therefore returns a 
present-but-dummy Òtptional` rather than an empty one.
   
   When a punctuator mutates the materialized store backing the left side of a 
foreign-key join and caching is enabled, the cache captures that dummy context 
and replays it when the change is flushed downstream. 
`SubscriptionSendProcessorSupplier` reads partition -1 into 
`SubscriptionWrapper#primaryPartition`, which was serialized to the 
subscription registration topic and later handed to the response sink 
partitioner, failing with ÌllegalArgumentException: Invalid partition: -1`.
   
   This change uses null for `primaryPartition` when no valid source partition 
is available. `null` already means "unknown partition, use default 
partitioning": the deserializer sets it for pre-`VERSION_1` wrappers, which is 
how FK joins routed responses before the field existed.
   
   Since the V1 field is a fixed-width int with no way to express absence, null 
is encoded as -1 on the wire and mapped back on read. The byte layout is 
unchanged. So, it's like we encode null as a NULL_PRIMARY_PARTITION (-1), we 
decode this constant as null. So, this only assigns meaning to a previously 
impossible value (-1 was never a valid partition).
   
   ### Testing
   - `SubscriptionSendProcessorSupplierTest`: two unit tests covering dummy 
record metadata (partition -1) and absent record metadata.
   - `SubscriptionWrapperSerdeTest`: round-trip of a V1 wrapper with a null 
`primaryPartition`.
   - 
`KTableKTableForeignKeyJoinScenarioTest#shouldNotFailWhenPunctuatorDeletesFromLeftTableStore`
 end-to-end testing using `TopologyTestDriver. It asserts both that no 
exception is thrown and that the leftJoin emits the expected tombstone. The 
test also fails without the production change, with the same stack trace 
reported in the Jira ticket.
   - `shouldThrowExceptionOnNullPrimaryPartitionV1Test` is removed. It asserted 
an auto-unboxing `NPE`from `buf.putInt(data.primaryPartition())` rather than a 
deliberate validation: `SubscriptionWrapper`s constructor guards other fields 
but not `primaryPartition` and null is already the meaningful V0 for that field.
   


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