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

raftpicker: do not use picker #1313

Merged
merged 1 commit into from Aug 5, 2016
Merged

raftpicker: do not use picker #1313

merged 1 commit into from Aug 5, 2016

Conversation

LK4D4
Copy link
Contributor

@LK4D4 LK4D4 commented Aug 4, 2016

Just recreate connection on leader change.

ping @aaronlehmann

@codecov-io
Copy link

codecov-io commented Aug 4, 2016

Current coverage is 55.12% (diff: 25.00%)

Merging #1313 into master will decrease coverage by 0.06%

@@             master      #1313   diff @@
==========================================
  Files            80         80          
  Lines         12562      12583    +21   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           6933       6936     +3   
- Misses         4674       4690    +16   
- Partials        955        957     +2   

Sunburst

Powered by Codecov. Last update e021d14...138e9de

@LK4D4 LK4D4 added this to the 1.12.1 milestone Aug 4, 2016
@LK4D4
Copy link
Contributor Author

LK4D4 commented Aug 4, 2016

This is one more fix for problem with wrong rescheduling on leader losing.

}
}
}
}()
Copy link
Collaborator

Choose a reason for hiding this comment

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

To reduce code duplication, could we put this part in a const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@LK4D4 LK4D4 force-pushed the no_raft_picker branch 2 times, most recently from a42a3e8 to 3a69ab3 Compare August 4, 2016 18:12
@LK4D4
Copy link
Contributor Author

LK4D4 commented Aug 4, 2016

@aaronlehmann fixed. Thanks!

@aaronlehmann
Copy link
Collaborator

LGTM if this works well in practice.

func (p *picker) PickAddr() (string, error) {
addr, err := p.raft.LeaderAddr()
// Reset recreates underlying connection.
func (c *ConnSelector) Reset() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to remove the return error from Reset()? I feel like having return error would show if the connection is good or bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's called only in raftproxy and I was reluctant to add logrus import there. Do you think I should just add return and left logging here as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think having return error is better. Logging can be done where it's convenient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay, will do now

@LK4D4 LK4D4 force-pushed the no_raft_picker branch 2 times, most recently from 5a136c8 to 1285516 Compare August 5, 2016 18:14
c.mu.Lock()
defer c.mu.Unlock()
if c.cc != nil {
c.cc.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is double Close() allowed or not? I think there may be paths leading to double close. If it's a problem, it may make sense to set c.cc = nil right after c.cc.Close().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not a problem, but I'll add this guard just for the case.

Just recreate connection on leader change.

Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
@dongluochen
Copy link
Contributor

LGTM

@abronan
Copy link
Contributor

abronan commented Aug 5, 2016

I'm fine with the change but on leader switch now I get:

user@node01:~# docker node ls
Error response from daemon: rpc error: code = 2 desc = grpc: the client connection is closing

And I have to input the command a second time to have the result. Is this the behavior we want?

@LK4D4
Copy link
Contributor Author

LK4D4 commented Aug 5, 2016

@abronan I think it's lesser evil. ping @aaronlehmann

@aaronlehmann
Copy link
Collaborator

Yeah.

@abronan
Copy link
Contributor

abronan commented Aug 5, 2016

LGTM

@abronan abronan merged commit 772dfb4 into moby:master Aug 5, 2016
@LK4D4 LK4D4 deleted the no_raft_picker branch August 5, 2016 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants