-
Notifications
You must be signed in to change notification settings - Fork 1k
feat: removing short cicuit in client use db #1067
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
Conversation
|
I think it's better that we reset the inuse DB when DROP DATABASE, or we remove the short circuit. Because even if this PR adds a new function, other developers don't know it and still meet the problem. Can you use tcpdump/wireshark to learn the behaviour of official MySQL client? Does it also have short circuit? If not, the easier way is we also remove the short circuit. |
|
based in the implementation of mariadb client. It seems they cross-check with server using I agree that we can just remove the short circuit altogether with a little cost of extra network traffic. This PR was created at first to maintain the current behaviour and avoid breaking changes So how do you say @lance6716 . Are we accepting changes in behaviour? |
LGTM. PTAL @dveeden @atercattus |
lance6716
left a comment
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.
PTAL @dveeden
|
can we merge this @lance6716 @dveeden ? |
|
I'll check this today. |
dveeden
left a comment
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've tested this and this seems correct to me.
The only issue I can see with this is that there is no comment or test added, which might mean we could accidentally break this in the future.
|
Hi @vanhtuan0409 can you add a test in client/conn_test.go? You can find examples in that file that executes SQL and call methods on |
|
let's me add some test 1st. It can help to verify both the short circuit and the client session tracking |
|
Note that for this PR you can basically ignore the session tracking. The session tracking probably should be a separate PR. |
|
@vanhtuan0409 If you have some difficulty in adding unit test, I think we can merge this PR and let me add unit test later. Or you can ask us for help. |
That would be great. I've been busy recently with all the development |
Signed-off-by: lance6716 <[email protected]>
|
@dveeden I have pushed a commit to add test for "use db" feature. Let's leave "session tracking" for another issue. |



During implementation of a SQL proxy. I encountered a rare bug due to a short circuit condition in
client/conn.UseDBThe proxy implementation is quite simple
I tested with SQL script as follow
during the drop database command, upstream MySQL automatically resets the connection selected db back to
nonebut
SQLProxy.connstill track the old deleted db. Duringuse proxiercommand,p.conn.UseDBgot short circuit because the selected db is not changedI propose to add a new function as
ForceUseDBto bypass the short circuit check