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

[fix][admin][branch-2.10] getMessageIdByTimestamp cannot redirect #23658

Open
wants to merge 2 commits into
base: branch-2.10
Choose a base branch
from
Open
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 @@ -1767,8 +1767,8 @@ public void getMessageIdByTimestamp(
if (isNot307And404Exception(ex)) {
log.error("[{}] Failed to get message ID by timestamp {} from {}",
clientAppId(), timestamp, topicName, ex);
resumeAsyncResponseExceptionally(asyncResponse, ex);
}
resumeAsyncResponseExceptionally(asyncResponse, ex);
return null;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import lombok.Cleanup;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.pulsar.broker.MultiBrokerBaseTest;
import org.apache.pulsar.broker.PulsarService;
import org.apache.pulsar.broker.loadbalance.LeaderBroker;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.common.naming.TopicDomain;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.common.policies.data.AutoTopicCreationOverride;
Expand Down Expand Up @@ -122,4 +125,32 @@ public void testTopicLookup(TopicDomain topicDomain, boolean isPartition) throws
Assert.assertEquals(lookupResultSet.size(), 1);
}

@Test(timeOut = 30 * 1000)
public void testTopicGetMessageIdByTimestamp() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

this test don't verify this fix

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,where is it not covered?

Copy link
Contributor

@congbobo184 congbobo184 Nov 29, 2024

Choose a reason for hiding this comment

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

you should check the 307And404Exception also can return the response exception right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the requested admin address is not the Broker to which the Topic belong, will the result be successful.
however, there is no 404 verification.

PulsarAdmin admin0 = getAllAdmins().get(0);
String topic = "public/default/t1";
admin0.topics().createPartitionedTopic(topic, 1);
pulsarClient = newPulsarClient(lookupUrl.toString(), 0);
@Cleanup
Producer<byte[]> producer = pulsarClient.newProducer().topic(topic).create();
for (int i = 0; i < 20; i++) {
producer.send("msg".getBytes());
}
String brokerUrl = admin0.lookups().lookupTopic(topic + "-partition-0");
PulsarAdmin admin = null;
for (PulsarService additionalBroker : additionalBrokers) {
if (!brokerUrl.endsWith(String.valueOf(additionalBroker.getBrokerListenPort().get()))) {
admin = additionalBroker.getAdminClient();
}
}
Assert.assertNotNull(admin);
MessageId msgId =
admin.topics().getMessageIdByTimestamp(topic + "-partition-0", System.currentTimeMillis());
Assert.assertNotNull(msgId);
try {
admin.topics().getMessageIdByTimestamp(topic + "-partition-1", System.currentTimeMillis());
} catch (Exception e) {
Assert.assertEquals(e.getClass(), PulsarAdminException.NotFoundException.class);
}
}
}
Loading