Skip to content

Commit

Permalink
[broker] Increase timeout for loading topics (apache#6750)
Browse files Browse the repository at this point in the history
In apache#6489, a timeout was introduced to make sure calls into the
BrokerService finish or error out. However, this timeout is too low by
default when loading topics that have many replicated clusters.

Loading replicated topics is quite an expensive operation, involve
global ZK lookups and the start of many sub-processes. While we would
hope it finishes in 60 seconds we want to safe.

Long term, it may make sense to break out this operation into more
steps where each step can have it's own timeout

Co-authored-by: Addison Higham <[email protected]>
  • Loading branch information
addisonj and Addison Higham authored May 7, 2020
1 parent f59a370 commit 6854b00
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ public class ServiceConfiguration implements PulsarConfiguration {
doc = "Flag to skip broker shutdown when broker handles Out of memory error"
)
private boolean skipBrokerShutdownOnOOM = false;
@FieldContext(
category = CATEGORY_SERVER,
doc = "Amount of seconds to timeout when loading a topic. In situations with many geo-replicated clusters, this may need raised."
)
private long topicLoadTimeoutSeconds = 60;

@FieldContext(
category = CATEGORY_POLICIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ public PulsarAdmin getClusterPulsarAdmin(String cluster) {
protected CompletableFuture<Optional<Topic>> loadOrCreatePersistentTopic(final String topic,
boolean createIfMissing) throws RuntimeException {
checkTopicNsOwnership(topic);
final CompletableFuture<Optional<Topic>> topicFuture = futureWithDeadline();
final CompletableFuture<Optional<Topic>> topicFuture = futureWithDeadline(pulsar.getConfiguration().getTopicLoadTimeoutSeconds(),
TimeUnit.SECONDS, new TimeoutException("Failed to load topic within timeout"));
if (!pulsar.getConfiguration().isEnablePersistentTopics()) {
if (log.isDebugEnabled()) {
log.debug("Broker is unable to load persistent topic {}", topic);
Expand Down

0 comments on commit 6854b00

Please sign in to comment.