-
Notifications
You must be signed in to change notification settings - Fork 28
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
proxy: refine sqlserver.SQLServer #27
Conversation
1. rename to proxy.SQLServer 2. pass logger to SQLServer and ClientConnection 3. handle cleanup of connection smoothly 4. replace siddontong/go-mysql to one from go-mysql-org Signed-off-by: xhe <xw897002528@gmail.com>
default: | ||
conn, err := s.listener.Accept() | ||
if err != nil { | ||
if errors.Is(err, net.ErrClosed) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use if opErr, ok := err.(*net.OpError)
as TiDB does?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the new style. Also, if errors are wrapped, type cast would not work. ButIs()
always works without thinking much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing is that there are many *net.OpError
. But I think we should only return nil on ErrClosed
. That is also the description of the original implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if errors are wrapped, type cast would not work.
I think we should keep the code the same with TiDB when you can not thoroughly test it, because TiDB has been running for a long time.
That is also the description of the original implementation.
Which description? The one of TiDB or golang?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean weir. The logging message is on closed connection
and return nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the code the same with TiDB when you can not thoroughly test it, because TiDB has been running for a long time.
I think it is fine. Mysql protocol did not define anything about the behavior of accept
. And returnn nil if clients disconnects on its own is normal among other apps. But we should report errors if it is not ErrClosed
(BTW, ErrClosed
is also the only one exposed error in net
package).
Signed-off-by: xhe <xw897002528@gmail.com>
Signed-off-by: xhe <xw897002528@gmail.com>
What problem does this PR solve?
Issue Number: ref #15
Problem Summary: As title
What is changed and how it works:
errors.Collect
Check List
Tests
Notable changes
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.