Skip to content

Conversation

crystall-bitquill
Copy link
Contributor

Summary

Statement cancel not working with MySQL driver

Description

The Statement.cancel method currently does not function with the MySQL community driver due to locking the ConnectionPluginManager. The MySQL driver also synchronizes on the Statement.getConnection method, which blocks any Statement.cancel executions. This PR moves the lock location and skips executing Statement.getConnection when running Statement.cancel.

Additional Reviewers

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@crystall-bitquill crystall-bitquill force-pushed the fix-cancel-statement branch 3 times, most recently from e475195 to 452c28e Compare January 30, 2024 01:20
@crystall-bitquill crystall-bitquill force-pushed the fix-cancel-statement branch 2 times, most recently from 893145b to bc9b8ee Compare February 6, 2024 20:43
@crystall-bitquill crystall-bitquill force-pushed the fix-cancel-statement branch 2 times, most recently from fc910bc to c3b4ff2 Compare February 7, 2024 19:45
@@ -251,7 +260,9 @@ public static <T, E extends Exception> T executeWithPlugins(
}

} finally {
pluginManager.unlock();
if (lock.isHeldByCurrentThread()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if the unlock should happen after calling closeContext. Can you check with @sergiyvamz


public class AsynchronousMethodsHelper {
public static final List<String> ASYNCHRONOUS_METHODS = Collections.singletonList(
"Statement.cancel"
Copy link
Contributor

Choose a reason for hiding this comment

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

What about other variations of statement.cancel? e.g. PreparedStatement.cancel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, it's been added to the list

@karenc-bq karenc-bq merged commit 1245bf3 into aws:main Feb 8, 2024
@karenc-bq karenc-bq deleted the fix-cancel-statement branch February 8, 2024 01:38
jasonli-improving pushed a commit to Bit-Quill/aws-advanced-jdbc-wrapper that referenced this pull request Feb 9, 2024
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.

3 participants