-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
client.Replicas always return sorted list #995
Comments
hi, Yes I check the version and it is 240fd14 package main
import (
"fmt"
"log"
"github.com/Shopify/sarama"
)
func main() {
topic := "test-topic"
config := sarama.NewConfig()
config.Net.SASL.Enable = true
config.Net.SASL.User = "kafka"
config.Net.SASL.Password = "MYPASSWD"
urls := []string{"kaf-01.local:9092", "kaf-02.local:9092", "kaf-03.local:9092"}
client, err := sarama.NewClient(urls, config)
if err != nil {
log.Fatalln(err)
}
fmt.Println(client.Replicas(topic, 0))
fmt.Println(client.Replicas(topic, 1))
fmt.Println(client.Replicas(topic, 2))
} $ GOPATH=~/golang go run main.go
[1 2 3] <nil>
[1 2 3] <nil>
[1 2 3] <nil> # /usr/bin/kafka-topics --zookeeper localhost:2181 --desc --topic test-topic
Topic:test-topic PartitionCount:3 ReplicationFactor:3
Topic: test-topic Partition: 0 Leader: 1 Replicas: 1,2,3 Isr: 2,1,3
Topic: test-topic Partition: 1 Leader: 2 Replicas: 2,3,1 Isr: 2,1,3
Topic: test-topic Partition: 2 Leader: 3 Replicas: 3,1,2 Isr: 1,2,3
|
I cannot reproduce this bug. I've run your script against my cluster and it is printing the replicas in the right order for me. |
I can't reproduce, and the code looks correct. Without more information of some sort I'm afraid I won't be able to help you. I would suggest adding some log statements to a local copy of Sarama, or something like that, to debug it further and figure out where the sorting is happening. |
Please reopen if you can provide more information. |
Versions
Sarama Version: 240fd14
Kafka Version: 0.10.2.1-2
Go Version: go1.9.1 linux/amd64
Configuration
default
Problem Description
I'm trying to use your library to detect if the leader for certain partition is the preferred leader.
So I have 3 kafka nodes cluster with multiple topic, calling e.client.Replicas("test-topic", 0)) will always return a sorted list:
however some of my topic have replicas configured as
The text was updated successfully, but these errors were encountered: