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

Fix/gorpc waitgroup panic #5

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

buger
Copy link

@buger buger commented Oct 16, 2024

See explanation here https://chatgpt.com/share/670fa163-0404-8005-ae68-9d7fdb8fda38

But basically if you have more then 1 failure in that loop you can get issue like that.

buger and others added 14 commits September 28, 2018 19:00
Gorpc server use clientID (which by default client IP), to dispatch client messages.
In case of Tyk it was causing issues, since when hybrid traffic goes though the proxy, behind MDCB, original IP gets lost, and all clients looks the same. It was causing issues when clients did not received messages in some cases. We solved it by introducing additional protocol handshake, on which Gateway sends its UUID, which will be used as clientID instead of IP.

We had to implement handshake functionality inside Accept() function, because of Gorpc design. Accept() in networking applications should be non blocking, but in our case we did a few connection reads inside it, which in most cases was fine (since they are fast), but in some cases it was blocking for a long period of time, because of network timeout and etc (for example in case of TCP health-checks).

This change moves clientID logic out of Accept() function to OnConnect() hook, and MDCB does its handshake logic inside it.

Additionally, all connection variables set to type net.Conn.
It was not using UUID, and always falling back to use IP
Requires calling `gob.Register` manually
Updated some of the code of server.go with the latest available in [https://github.com/valyala/gorpc](https://github.com/valyala/gorpc)

Some of the changes are:
- Suppress more 'EOF' log messages when clien disconnects from the server or Server.Stop() has been called
- Do not log 'closed conn'-like error messages on server side after Server.Stop()
- Increase the probability of message batching on both client and server by calling `runtime.Gosched() `after requests/responses channels have been drained. This should reduce the number of write() syscalls (especially on go1.5)
…-waitgroup-for-connections-established

added waitgroup to know when the connections are stablished
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