Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -30,6 +30,7 @@
import org.apache.kafka.common.errors.MemberIdRequiredException;
import org.apache.kafka.common.errors.RebalanceInProgressException;
import org.apache.kafka.common.errors.RetriableException;
import org.apache.kafka.common.errors.TimeoutException;
import org.apache.kafka.common.errors.UnknownMemberIdException;
import org.apache.kafka.common.message.FindCoordinatorRequestData;
import org.apache.kafka.common.message.HeartbeatRequestData;
Expand Down Expand Up @@ -887,8 +888,8 @@ public void onFailure(RuntimeException e, RequestFuture<Void> future) {

if (e instanceof NoBatchedFindCoordinatorsException) {
batchFindCoordinator = false;
clearFindCoordinatorFuture();
lookupCoordinator();
// make a fast failure to send next request without batching
super.onFailure(new TimeoutException(e), future);
return;
}
if (!(e instanceof RetriableException)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.apache.kafka.clients.GroupRebalanceConfig;
import org.apache.kafka.clients.MockClient;
import org.apache.kafka.clients.NodeApiVersions;
import org.apache.kafka.clients.consumer.OffsetResetStrategy;
import org.apache.kafka.common.Node;
import org.apache.kafka.common.errors.AuthenticationException;
Expand All @@ -35,6 +36,7 @@
import org.apache.kafka.common.message.SyncGroupResponseData;
import org.apache.kafka.common.metrics.KafkaMetric;
import org.apache.kafka.common.metrics.Metrics;
import org.apache.kafka.common.protocol.ApiKeys;
import org.apache.kafka.common.protocol.Errors;
import org.apache.kafka.common.requests.AbstractRequest;
import org.apache.kafka.common.requests.FindCoordinatorResponse;
Expand All @@ -55,6 +57,7 @@
import org.apache.kafka.test.TestUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import java.nio.ByteBuffer;
import java.util.Arrays;
Expand Down Expand Up @@ -1028,6 +1031,22 @@ public void testLookupCoordinator() {
assertNotSame(future, coordinator.lookupCoordinator(), "New request not sent after previous completed");
}

@Timeout(10)
@Test
public void pollShouldBeDoneByNoBatchedFindCoordinatorsException() throws InterruptedException {
setupCoordinator();
mockClient.setNodeApiVersions(NodeApiVersions.create(ApiKeys.FIND_COORDINATOR.id, (short) 3, (short) 3));
RequestFuture<Void> future = coordinator.lookupCoordinator();
assertFalse(future.isDone());
// first response is replaced by UnsupportedVersionException
mockClient.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
// second response is what mock client pass to network client
mockClient.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
coordinator.ensureCoordinatorReady(mockTime.timer(10));
assertTrue(future.isDone());
assertTrue(future.failed());
}

@Test
public void testWakeupAfterJoinGroupSent() throws Exception {
setupCoordinator();
Expand Down