forked from apache/kafka
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KAFKA-15019: Improve handling of broker heartbeat timeouts (apache#13759
) When the active KRaft controller is overloaded, it will not be able to process broker heartbeat requests. Instead, they will be timed out. When using the default configuration, this will happen if the time needed to process a broker heartbeat climbs above a second for a sustained period. This, in turn, could lead to brokers being improperly fenced when they are still alive. With this PR, timed out heartbeats will still update the lastContactNs and metadataOffset of the broker in the BrokerHeartbeatManager. While we don't generate any records, this should still be adequate to prevent spurious fencing. We also log a message at ERROR level so that this condition will be more obvious. Other small changes in this PR: fix grammar issue in log4j of BrokerHeartbeatManager. Add JavaDoc for ClusterControlManager#zkMigrationEnabled field. Add builder for ReplicationControlTestContext to avoid having tons of constructors. Update ClusterControlManager.DEFAULT_SESSION_TIMEOUT_NS to match the default in KafkaConfig. Reviewers: Ismael Juma <ijuma@apache.org>, Ron Dagostino <rdagostino@confluent.io>
- Loading branch information
Showing
9 changed files
with
280 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
metadata/src/main/java/org/apache/kafka/controller/errors/ControllerExceptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.kafka.controller.errors; | ||
|
||
import org.apache.kafka.common.errors.TimeoutException; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
|
||
|
||
public class ControllerExceptions { | ||
/** | ||
* Check if an exception is a normal timeout exception. | ||
* | ||
* @param exception The exception to check. | ||
* @return True if the exception is a timeout exception. | ||
*/ | ||
public static boolean isTimeoutException(Throwable exception) { | ||
if (exception == null) return false; | ||
if (exception instanceof ExecutionException) { | ||
exception = exception.getCause(); | ||
if (exception == null) return false; | ||
} | ||
if (!(exception instanceof TimeoutException)) return false; | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.