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

Add DSN options to enable SQL queries on follower nodes #136

Merged
merged 6 commits into from
Dec 14, 2018

Conversation

ggicci
Copy link
Contributor

@ggicci ggicci commented Dec 13, 2018

No description provided.

@ggicci ggicci changed the title Feature/use follower peers Add DSN options to use follower nodes to run SQL queries Dec 13, 2018
@ggicci ggicci changed the title Add DSN options to use follower nodes to run SQL queries Add DSN options to enable SQL queries on follower nodes Dec 13, 2018
client/conn.go Outdated
// choose a random follower node
if cfg.UseFollower && len(peers.Servers) > 1 {
for {
rand.Seed(time.Now().UnixNano())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's inappropriate for client SDK to modify the golang runtime global random source seed.
I thought using client package global randSource is better, already initialized with rand.New(rand.NewSource(time.Now().UnixNano())).

client/conn.go Outdated
if cfg.UseFollower && len(peers.Servers) > 1 {
for {
rand.Seed(time.Now().UnixNano())
node := peers.Servers[rand.Intn(len(peers.Servers))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, this rand.Intn can be replaced with randSource.Intn

client/conn.go Outdated

func (c *conn) stopAckWorkers() {
if c.leader != nil {
close(c.leader.ackCh)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be replaced with c.leader.stopAckWorkers()

client/conn.go Outdated
close(c.leader.ackCh)
}
if c.follower != nil {
close(c.follower.ackCh)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, c.follower.stopAckWorkers()

client/conn.go Outdated
rand.Seed(time.Now().UnixNano())
node := peers.Servers[rand.Intn(len(peers.Servers))]
if node != peers.Leader {
c.pFollowerCaller = rpc.NewPersistentCaller(node)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing CloseStream for c.pFollowerCaller

Copy link
Contributor

@xq262144 xq262144 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@leventeliu leventeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, approve.

@leventeliu leventeliu merged commit a7b7a7d into develop Dec 14, 2018
@leventeliu leventeliu deleted the feature/useFollowerPeers branch December 14, 2018 01:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants