Skip to content

Fix error around breaking of multistatements#6808

Merged
deepthi merged 5 commits intovitessio:masterfrom
planetscale:conn-error-handling
Oct 2, 2020
Merged

Fix error around breaking of multistatements#6808
deepthi merged 5 commits intovitessio:masterfrom
planetscale:conn-error-handling

Conversation

@systay
Copy link
Copy Markdown
Collaborator

@systay systay commented Oct 1, 2020

When a multi-statement query is received, any errors should abort the execution of the remaining queries.

The execQuery and handleNextCommand were returning an error, but not actually using the error value - just checking if it was nil or not.

We need to be able to know on the outside of execQuery if an error occured and if it was an error we need to close the connection for or if it was a simple execution error.

Fixes #6747

When a multistatement query is received, any errors should
abort the execution of the remaining queries.

The `execQuery` and `handleNextCommand` were returning an error,
but not actually using the error value - just checking if it was nil or not.

We need to be able to know on the outside of `execQuery` if an error occured and if it was an error we need to close the connection for or if it was a simple execution error.

Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay systay requested a review from sougou as a code owner October 1, 2020 08:38
@systay
Copy link
Copy Markdown
Collaborator Author

systay commented Oct 1, 2020

I extracted the actual bug fixing into it's own PR. I'm thinking we might want to back-port it.

Signed-off-by: Andres Taylor <andres@planetscale.com>
go/mysql/conn.go Outdated
}

func (c *Conn) execQuery(query string, handler Handler, more bool) error {
type execResult byte
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style nit -- I'd move this type declaration up to the top of the file since execSuccess and connErr are referred to above.

Copy link
Copy Markdown
Collaborator

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

The fix looks fine. Do you plan to resolve the TODOs before this is merged?

@deepthi
Copy link
Copy Markdown
Collaborator

deepthi commented Oct 2, 2020

unit test failed again (on retry). You might want to fix mysql/server_test to reset the stats/counts to resolve the failure.

2020-10-02T00:49:00.3064679Z ##[error]    server_test.go:638: Expected Timing count delta All should be >= 2, got 1
2020-10-02T00:49:00.3065971Z ##[error]    server_test.go:638: Expected Timing count delta Query should be >= 1, got 0

systay added 2 commits October 2, 2020 11:45
Signed-off-by: Andres Taylor <andres@planetscale.com>
Both when preparing and when executing prepared statements, Vitess
was dropping the connection on most errors. This change makes it
so Vitess instead returns an error packet but keeps the connection open.

Signed-off-by: Andres Taylor <andres@planetscale.com>
@systay
Copy link
Copy Markdown
Collaborator Author

systay commented Oct 2, 2020

The fix looks fine. Do you plan to resolve the TODOs before this is merged?

Done ✔️

Signed-off-by: Andres Taylor <andres@planetscale.com>
Copy link
Copy Markdown
Collaborator

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

LGTM

@deepthi deepthi merged commit 48d6cf0 into vitessio:master Oct 2, 2020
@deepthi deepthi deleted the conn-error-handling branch October 2, 2020 20:10
@deepthi
Copy link
Copy Markdown
Collaborator

deepthi commented Oct 2, 2020

All the failing tests on the last commit are known to be flaky. Opened #6812 to disable the failing TER test.

@askdba askdba added this to the v8.0 milestone Oct 6, 2020
systay added a commit to planetscale/vitess that referenced this pull request Oct 6, 2020
When a multistatement query is received, any errors should
abort the execution of the remaining queries.

The `execQuery` and `handleNextCommand` were returning an error,
but not actually using the error value - just checking if it was nil or not.

We need to be able to know on the outside of `execQuery` if an error occured and if it was an error we need to close the connection for or if it was a simple execution error.

This is a squashed backport of vitessio#6808

Signed-off-by: Andres Taylor <andres@planetscale.com>
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.

Errors in multi-statement queries not fatal to statement sequence

4 participants