我有一个Kafka Streams应用程序,它使用并生成具有3个代理并且复制因子为3的Kafka集群。除了消费者偏移主题(50个分区)之外,所有其他主题每个只有一个分区。
当代理尝试首选副本选举时,Streams应用程序(运行在与代理完全不同的实例上)失败并显示错误:
Caused by: org.apache.kafka.streams.errors.StreamsException: task [0_0] exception caught when producing
at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.checkForException(RecordCollectorImpl.java:119)
...
at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:197)
Caused by: org.apache.kafka.common.errors.NotLeaderForPartitionException: This server is not the leader for that topic-partition.
Streams应用尝试成为分区的领导者是正常的,因为它在不属于Kafka集群的服务器上运行吗?
我可以通过以下方式重现此行为:
bin/kafka-preferred-replica-election.sh --zookeeper localhost
我的问题似乎与此reported failure类似,所以我想知道这是否是一个新的Kafka Streams错误。我的完整堆栈跟踪与报告的失败(here)中链接的要点完全相同。
另一个可能有趣的细节是,在领导者选举期间,我在经纪人的controller.log
收到这些消息:
[2017-04-12 11:07:50,940] WARN [Controller-3-to-broker-3-send-thread], Controller 3's connection to broker BROKER-3-HOSTNAME:9092 (id: 3 rack: null) was unsuccessful (kafka.controller.RequestSendThread)
java.io.IOException: Connection to BROKER-3-HOSTNAME:9092 (id: 3 rack: null) failed
at kafka.utils.NetworkClientBlockingOps$.awaitReady$1(NetworkClientBlockingOps.scala:84)
at kafka.utils.NetworkClientBlockingOps$.blockingReady$extension(NetworkClientBlockingOps.scala:94)
at kafka.controller.RequestSendThread.brokerReady(ControllerChannelManager.scala:232)
at kafka.controller.RequestSendThread.liftedTree1$1(ControllerChannelManager.scala:185)
at kafka.controller.RequestSendThread.doWork(ControllerChannelManager.scala:184)
at kafka.utils.ShutdownableThread.run(ShutdownableThread.scala:63)
我最初认为这个连接错误是罪魁祸首,但是在领导者选举崩溃Streams应用程序之后,如果我重新启动Streams应用程序,它会正常工作直到下一次选举,而我根本没有触及经纪人。
所有服务器(3个Kafka代理和Streams应用程序)都在EC2实例上运行。
答案 0 :(得分:9)
现在已在0.10.2.1中修复。如果你不能选择它,请确保在stream config中设置如下两个参数:
var hallApp = angular.module("hallApp",['ngRoute']);
hallApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/home', {
templateUrl: 'home.html',
controller: 'homeCtrl'
}).when('/income', {
templateUrl: '../../views/income.html',
controller: 'incomeCtrl',
css: '../../css/income.css'
}).when('/expense', {
templateUrl: '../../views/expense.html',
controller: 'expenseCtrl',
css: '../../css/expense.css'
}).when('/profitandloss', {
templateUrl: '../../views/profitandloss.html',
controller: 'profitandlossCtrl',
css: '../../css/profitandloss.css'
}).otherwise({
redirectTo: '/home'
});
}]);
hallApp.controller('homeCtrl', ['$scope', function($scope) {
$scope.greeting = 'Home!';
}]);