KAFKA-16684: Remove cache in responseData#16532
Conversation
| } | ||
|
|
||
| @Test | ||
| public void testFetcherDontCacheAnyData() { |
There was a problem hiding this comment.
This part is good but it's gone too far. Maybe we can create a FetchResponse and then test the method responseData?
There was a problem hiding this comment.
Yes, I will simplify this test
|
@chia7712, Thanks for your comments, PTAL |
| FetchResponse fetchResponse = fetchResponse(tidp0, records, Errors.NONE, 100L, -1L, 0L, 0); | ||
| fetchResponse.responseData(topicNames, version) | ||
| .forEach((topicPartition, partitionData) -> assertEquals(records, partitionData.records())); | ||
| fetchResponse.responseData(new HashMap<>(), version) |
|
@chia7712, Thanks for your comments, PTAL |
| public void testFetcherDontCacheAnyData() { | ||
| short version = 17; | ||
| FetchResponse fetchResponse = fetchResponse(tidp0, records, Errors.NONE, 100L, -1L, 0L, 0); | ||
| fetchResponse.responseData(topicNames, version) |
There was a problem hiding this comment.
Could you please verify the size first?
|
@chia7712, Thanks for your comments, add assert for size() |
|
@apoorvmittal10 you had reviewed on #15966, so could you please take a look at this PR? thanks! |
apoorvmittal10
left a comment
There was a problem hiding this comment.
Thanks for the PR. LGTM! Just a query.
|
|
||
| @Test | ||
| public void testFetcherDontCacheAnyData() { | ||
| short version = 17; |
There was a problem hiding this comment.
Do we have any existing test where version < 13? If not then can we please add one.
There was a problem hiding this comment.
@apoorvmittal10, Thanks for your comments, In testFetchWithNoTopicId have been test for version 12, Should I add a test only for FetchResponse#responseData this method to test version 12? WDYT
There was a problem hiding this comment.
Confirmed, org.apache.kafka.clients.consumer.internals.FetcherTest#testFetchWithNoTopicId is testing org.apache.kafka.common.requests.FetchResponse#responseData with version = 12, so I don't think we need a new test.
There was a problem hiding this comment.
Thansk for looking into, if there already exists a test then we can skip new one.
soarez
left a comment
There was a problem hiding this comment.
Thanks for this patch.
I could not find a good reason to keep the reponseData cached.
Test failures are unrelated.
LGTM
The response data should change accordingly to the input, however with the current design, it will not change even if the input changes. We remove this cache logic to avoid returning wrong data. Reviewers: Chia-Ping Tsai <chia7712@gmail.com>, Apoorv Mittal <apoorvmittal10@gmail.com>, Igor Soarez <soarez@apple.com>
| responseData.forEach((topicPartition, partitionData) -> assertEquals(records, partitionData.records())); | ||
| LinkedHashMap<TopicPartition, FetchResponseData.PartitionData> nonResponseData = fetchResponse.responseData(emptyMap(), version); | ||
| assertEquals(emptyMap().size(), nonResponseData.size()); | ||
| nonResponseData.forEach((topicPartition, partitionData) -> assertEquals(MemoryRecords.EMPTY, partitionData.records())); |
There was a problem hiding this comment.
This line is never executed. We can remove this assertion.
There was a problem hiding this comment.
we can also replace emptyMap().size() with 0.
There was a problem hiding this comment.
I've opened a minor PR #19376 to remove it.
Thanks @FrankYang0529 for pointing it out!
…19357) Jira: https://issues.apache.org/jira/browse/KAFKA-19074 Similar fix #16532 2b8aff5 make it accept input to return "partial" data. The content of output is based on the input but we cache the output ... It will return same output even though we pass different input. That is a potential bug. Reviewers: PoAn Yang <payang@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
This is from [#16532's comment](https://github.com/apache/kafka/pull/16532/files#r2028985028): The forEach loop in the assertion will never execute because `nonResponseData` is empty. This happens because the above assertion `emptyMap()` has a size of 0, so there are no elements to iterate over. Reviewers: PoAn Yang <payang@apache.org>, Ken Huang <s7133700@gmail.com>, TaiJuWu <tjwu1217@gmail.com>, TengYao Chi <kitingiao@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
The response data should change accordingly to the input, however with the current design, it will not change even if the input changes. We should remove this cache logic to avoid returning wrong data.
Jira: https://issues.apache.org/jira/browse/KAFKA-16684
Committer Checklist (excluded from commit message)