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
CONJ-426 Allow executeBatch to be interrupted #99
Conversation
…ultiple data structures for concurrent access
|
Hi @kevinconaway, Great addition, Similar to other open source projects, the MariaDB Foundation needs to have shared ownership of all code that is included in the MariaDB distribution. The easiest way to achieve this is by submitting your code under the BSD-new license. (The other alternative is to sign the code contribution agreement which can be found here: https://mariadb.com/kb/en/mariadb/mca/) Please indicate in a comment below that you are contributing your new code of the whole pull request, including one or several files that are either new files or modified ones, under the BSD-new license or that you have filled out the contribution agreement and sent it. Thanks, |
…rewritten and normal batch statements to be interrupted. Increase batch size for test because rewritten batch statements run faster.
Please consider all commits and comments on this work submitted under the BSD-new license.
Do I need a username on on Launchpad / askmonty.org in order to sign this? |
|
I've also submitted a copy of the MCA |
|
I've modified my test case to only run when |
|
The build failures linked here https://travis-ci.org/MariaDB/mariadb-connector-j/builds/199340719 seem to be due to ssl / connectivity issues when pulling maven dependencies, not my changes. |
|
@kevinconaway, yes, maven/connection on travis did have some random issue yesterday. |
|
closing, since merge in 1.5.8 (722f717) |
@rusher this PR attempts to address the issue identified in https://jira.mariadb.org/browse/CONJ-426
I believe that the cause of this that AbstractMultiSend#executeBatchStandard swallows the
InterruptedExceptionand does not reset the threads interrupted status. Thus the caller thread has no idea whether its been interrupted or not.The
executeBatchcall returns early due to the interrupt but the query is actually running the background. Thus there is a race condition when querying the state of thecmdInformationin `MariaDbServerPreparedStatement#executeBatch. This manifests as the NPE that I linked in the ticket.My fix in this PR addresses all of this by modifying
AsyncMultiSendto properly catch theInterruptedException, reset the thread interrupt state and rethrow the exception as aQueryException. I also modified this class to cancel the ongoingAsyncMultiReadtask which is also now interruptible.I've also modified the data structures in
CmdInformationMultipleto be thread safe since there is still a tiny chance that theAsyncMultiReadtask will attempt to write a result while the caller thread inMariaDbServerPreparedStatementwill attempt to query them.