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 for 7403 - a race condition bug. #7404

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

swojtasiak
Copy link

Fix for the bug described here: #7403

  • Do only one thing
  • Non breaking API changes
  • Tested

The fix removes the global call to "rows.Err()" from the generic Scan method, as it's something that should be done by the caller when the caller knows that the method can be called in a safe way (the rows instance is explicitly or implicitly closed).
By calling the method after making sure that the rows instance is closed, the code protects the call against the race condition described in the issue.

The fixed Scan() method is also called internally, so I also made sure that potential errors won't be missed there, by calling the Err() method after making sure that the rows instance is closed. It's 100% safe, because the Next() method called there ensures that the instance is closed and releases the potential read lock which may be left by Scan() method.

I didn't add a dedicated test case, because the bug causes a race condition which is not easy to reproduce. If there was a way to mock the whole rows instance then it could be probably checked. All existing test cases passed.

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.

1 participant