Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove failed stale producer from the connection #4741

Merged
merged 1 commit into from
Jul 18, 2019
Merged
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 @@ -668,7 +668,7 @@ protected void handleSubscribe(final CommandSubscribe subscribe) {
error = ServerError.ServiceNotReady;
}else {
error = getErrorCode(existingConsumerFuture);
consumers.remove(consumerId, consumerFuture);
consumers.remove(consumerId);
}
ctx.writeAndFlush(Commands.newError(requestId, error,
"Consumer is already present on the connection"));
Expand Down Expand Up @@ -863,7 +863,8 @@ protected void handleProducer(final CommandProducer cmdProducer) {
error = ServerError.ServiceNotReady;
}else {
error = getErrorCode(existingProducerFuture);
producers.remove(producerId, producerFuture);
// remove producer with producerId as it's already completed with exception
producers.remove(producerId);
}
log.warn("[{}][{}] Producer with id {} is already present on the connection", remoteAddress,
producerId, topicName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,6 @@ public void testSubscribeTimeout() throws Exception {
successSubName, 1 /* consumer id */, 1 /* request id */, SubType.Exclusive, 0, "test" /* consumer name */);
channel.writeInbound(subscribe1);

ByteBuf closeConsumer = Commands.newCloseConsumer(1 /* consumer id */, 2 /* request id */ );
channel.writeInbound(closeConsumer);

ByteBuf subscribe2 = Commands.newSubscribe(successTopicName, //
successSubName, 1 /* consumer id */, 3 /* request id */, SubType.Exclusive, 0, "test" /* consumer name */);
channel.writeInbound(subscribe2);
Expand All @@ -996,10 +993,6 @@ public void testSubscribeTimeout() throws Exception {
Object response;

synchronized (this) {
// Close succeeds
response = getResponse();
assertEquals(response.getClass(), CommandSuccess.class);
assertEquals(((CommandSuccess) response).getRequestId(), 2);

// All other subscribe should fail
response = getResponse();
Expand All @@ -1014,9 +1007,12 @@ public void testSubscribeTimeout() throws Exception {
assertEquals(response.getClass(), CommandError.class);
assertEquals(((CommandError) response).getRequestId(), 5);

// We should not receive response for 1st producer, since it was cancelled by the close
assertTrue(channel.outboundMessages().isEmpty());
// We should receive response for 1st producer, since it was not cancelled by the close
assertTrue(!channel.outboundMessages().isEmpty());
assertTrue(channel.isActive());
response = getResponse();
assertEquals(response.getClass(), CommandSuccess.class);
assertEquals(((CommandSuccess) response).getRequestId(), 1);
}

channel.finish();
Expand Down