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

An atomic approach for HostClient.MaxConns #531

Merged
merged 2 commits into from
Feb 7, 2019

Conversation

xaionaro
Copy link
Contributor

@xaionaro xaionaro commented Feb 5, 2019

We need to dynamically change a MaxConns value. So this patch is about safe atomic reading from MaxConns.

Copy link
Collaborator

@erikdubbelboer erikdubbelboer left a comment

Choose a reason for hiding this comment

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

Can you please add some documentation that MaxConns can be changed using atomic.StoreUint64.

@erikdubbelboer erikdubbelboer merged commit fa7a110 into valyala:master Feb 7, 2019
@erikdubbelboer
Copy link
Collaborator

Thanks.

@xaionaro
Copy link
Contributor Author

xaionaro commented Feb 8, 2019

Thank you!

@xaionaro
Copy link
Contributor Author

xaionaro commented Feb 11, 2019

is this maybe uint32 better for it can run on i386 system not support x64?

Sounds reasonable to me. I doubt that somebody can reach limit of 4M connections. nf_conntrack will hang much earlier :)

@erikdubbelboer
Should I prepare the (micro-)fix?

@erikdubbelboer
Copy link
Collaborator

@xuecai yes for atomic operations it should definitely be a uint32. See: https://golang.org/pkg/sync/atomic/#pkg-note-BUG

@erikdubbelboer
Copy link
Collaborator

@xaionaro I'm sorry I made a mistake merging this pull request (looks like I wasn't thinking).
I have fixed it in: e722d81

One problem was that we can't just change HostClient.MaxConns from an int to a uint64. This breaks everyone's code that sets it using something else than a constant.
Another problem was indeed the atomic operations on an uint64.

@xaionaro
Copy link
Contributor Author

@erikdubbelboer I see. It's quite bad for us. How can we safely change the MaxConns then?

@erikdubbelboer
Copy link
Collaborator

@xaionaro that's why I introduced the HostClient.SetMaxConns(newMaxConns) function.

@xaionaro
Copy link
Contributor Author

@xaionaro that's why I introduced the HostClient.SetMaxConns(newMaxConns) function.

Ah. Did not notice. OK. Thanks. Sorry if I caused any problems :(

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.

2 participants