Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Return ErrBusyBuffer instead of driver.ErrBadConn #611

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

Closed
amenzhinsky wants to merge 1 commit into go-sql-driver:master from amenzhinsky:master
Closed

Return ErrBusyBuffer instead of driver.ErrBadConn #611

amenzhinsky wants to merge 1 commit into go-sql-driver:master from amenzhinsky:master

Conversation

@amenzhinsky
Copy link

@amenzhinsky amenzhinsky commented Jun 8, 2017
edited
Loading

#314

We ran into problem when using the same tx and querying multiple times, the mysql driver returns driver.ErrBadConn sending the busy buffer error to stderr. I believe that in most cases buffer cannot be taken only when previous one hasn't been read out or closed.

See TestUnclosedRows as an example in the changes.

This is more like error message improvement since current behaviour is quite confusing.

Copy link
Member

Interesting, we were always looking for a way to reproduce those errors.

In that case, we should probably return a more descriptive error like e.g. ErrUnreadData or more specific ErrUnreadTxRows. ErrBusyBuffer was just the best name we could come up for an error we couldn't find any explanation for.

@julienschmidt julienschmidt added this to the v1.4 milestone Jun 8, 2017
Copy link
Member

And please don't ignore our pull request template, specifically Added myself / the copyright holder to the AUTHORS file in the checklist 😉

func (b *buffer) takeBuffer(length int) ([]byte, error) {
if b.length > 0 {
return nil
return nil, ErrUnreadTxRows
Copy link
Member

@julienschmidt julienschmidt Jun 8, 2017

Choose a reason for hiding this comment

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

Please do not return the error here. Leave the buffer unchanged.
This specific error should only be returned when we know that it is this specific error.

return driver.ErrBadConn
data, err := mc.buf.takeSmallBuffer(pktLen + 4)
if err != nil {
return err
Copy link
Member

@julienschmidt julienschmidt Jun 8, 2017

Choose a reason for hiding this comment

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

For example here it should be impossible that we're in a transaction with unread rows. Here the driver.ErrBadConn should still be returned as there is this is a brand new connection and there really shouldn't be any unread data in the buffer.

Copy link
Author

@amenzhinsky amenzhinsky Jun 9, 2017
edited
Loading

Choose a reason for hiding this comment

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

Had some time to sort things out, I think that's correct behaviour to return ErrBusyBuffer because when we cannot take it then something must be wrong in the code (multiple functions are using the buffer at the same time) or in this case buffer has some unread data.

And only two functions writePacket and readPacket should return ErrBadConn since they do the io.

So we should return ErrBusyBuffer anyway not ErrBadConn, and probably add additional checks to Query and Exec to return ErrUnreadRows to be more descriptive.

What do you think?

Copy link
Member

@amenzhinsky do you still have problems with the now implemented behavior (see #302)?
If yes, please update this PR or otherwise close it.

Copy link
Member

methane commented Oct 21, 2018

Close this because no reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@julienschmidt julienschmidt julienschmidt requested changes

Assignees

No one assigned

Projects

None yet

Milestone

v1.5.0

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /