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

client.Replicas always return sorted list #995

Closed
wakeful opened this issue Dec 4, 2017 · 5 comments
Closed

client.Replicas always return sorted list #995

wakeful opened this issue Dec 4, 2017 · 5 comments

Comments

@wakeful
Copy link

wakeful commented Dec 4, 2017

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:

[1 2 3] <nil>

however some of my topic have replicas configured as

Replicas: 3,2,1 Isr: 1,2,3
Replicas: 2,1,3 Isr: 2,1,3
Replicas: 1,3,2 Isr: 2,1,3
@eapache
Copy link
Contributor

eapache commented Dec 4, 2017

Hmm, can you please double check that you are using the version you think you are? The exact issue was fixed already in #930 cc @git-hulk.

@wakeful
Copy link
Author

wakeful commented Dec 4, 2017

hi,

Yes I check the version and it is 240fd14
bellow a small script that I wrote to check the behaviour

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

@eapache
Copy link
Contributor

eapache commented Dec 8, 2017

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.

@eapache
Copy link
Contributor

eapache commented Dec 22, 2017

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.

@eapache
Copy link
Contributor

eapache commented Jan 22, 2018

Please reopen if you can provide more information.

@eapache eapache closed this as completed Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants