Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1271,9 +1271,19 @@ private CompletedFetch initializeCompletedFetch(CompletedFetch nextCompletedFetc
} else if (error == Errors.UNKNOWN_LEADER_EPOCH) {
log.debug("Received unknown leader epoch error in fetch for partition {}", tp);
} else if (error == Errors.UNKNOWN_SERVER_ERROR) {
log.warn("Unknown error fetching data for topic-partition {}", tp);
log.warn("Unknown server error while fetching offset {} for topic-partition {}",
fetchOffset, tp);
} else if (error == Errors.CORRUPT_MESSAGE) {
throw new KafkaException("Encountered corrupt message when fetching offset "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it, could we add the fetch offset to the IllegalStateException message below and the UNKNOWN_SERVER_ERROR log message above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

+ fetchOffset
+ " for topic-partition "
+ tp);
} else {
throw new IllegalStateException("Unexpected error code " + error.code() + " while fetching from partition " + tp);
throw new IllegalStateException("Unexpected error code "
+ error.code()
+ " while fetching at offset "
+ fetchOffset
+ " from topic-partition " + tp);
}
} finally {
if (completedFetch == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3835,6 +3835,30 @@ public void testFetchCompletedBeforeHandlerAdded() {
assertEquals(1, fetcher.sendFetches());
}

@Test
public void testCorruptMessageError() {
buildFetcher();
assignFromUser(singleton(tp0));
subscriptions.seek(tp0, 0);

assertEquals(1, fetcher.sendFetches());
assertFalse(fetcher.hasCompletedFetches());

// Prepare a response with the CORRUPT_MESSAGE error.
client.prepareResponse(fullFetchResponse(
tp0,
buildRecords(1L, 1, 1),
Errors.CORRUPT_MESSAGE,
100L, 0));
consumerClient.poll(time.timer(0));
assertTrue(fetcher.hasCompletedFetches());

// Trigger the exception.
assertThrows(KafkaException.class, () -> {
fetchedRecords();
});
}

private MockClient.RequestMatcher listOffsetRequestMatcher(final long timestamp) {
// matches any list offset request with the provided timestamp
return new MockClient.RequestMatcher() {
Expand Down