-
Notifications
You must be signed in to change notification settings - Fork 258
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
SSCursor can't close while raise Error #428
Comments
Can someone respond to me? |
Can you post a reproducible test case |
you can reproduce this by 2 steps:
async with conn.cursor(SScursor) as cursor:
await cursor.execute("SELECT a large data")
await ret = cursor.fetchall() the conn received a error package with errorno 3024 and msg "Query execution was interrupted, maximum statement execution time exceeded ". |
I fixed the issue for pymysql in the commit |
Hello @ppd0705. SELECT /*+ MAX_EXECUTION_TIME(3000) */ col1, col2 FROM table #some heavy query If aiomysql updates the pymysql version to 0.10.0 or higher, will the problem be solved? If the aiomysql does not update, is there any other alternative? |
this bug can only be fixed in aiomysql and has nothing to do with the version of pymysql. |
Fix to raise an error when query execution timeout in server-side cursor - PyMySQL >=0.10.0,<=0.10.1 (to use MysqlPacket->raise_for_error())
As I'm working on creating test cases for this I don't believe this is resolved yet, not resolved in PyMySQL either. On aiomysql without the patch from #646 the connection gets stuck, which matches the original report of this issue by @ppd0705. With #646 applied I'm seeing the same behavior as in PyMySQL, which I believe is still wrong: The initial query succeeds, even though it should result in a timeout. reproducible test case moved to PyMySQL/PyMySQL#1032 (comment) I wouldn't expect this to fail on |
@Nothing4You |
they actually can, you need to carefully craft the queries though. example (mysql 8.0):
from mysql 8.0 docs about
the key takeaway is that sleep cannot be the only part of the query. see for example https://github.com/Nothing4You/PyMySQL/blob/8c373feb9036b4c19eb338220f47586f26e5afd0/pymysql/tests/test_cursor.py#L137 |
this is also similar to how MySQL implements this in their own tests: https://github.com/mysql/mysql-server/blob/mysql-8.0.28/mysql-test/t/max_statement_time.test |
definitely fun to test, in some cases I can even get PyMySQL to raise a ProgrammingError from |
continuing in PyMySQL/PyMySQL#1032 |
tests for PyMySQL have been built, see PyMySQL/PyMySQL#1033 |
(failing) tests can be seen in https://github.com/Nothing4You/aiomysql/actions/runs/1801465357 test cases are added in #728 |
fixes #428 (#646) Co-authored-by: Richard Schwab <[email protected]>
reopening for the missing test case for #428 (comment) |
as described in PyMySQL/PyMySQL#1032 (comment) onwards I don't think it's realistic to write a test case for this specific issue due to lack of determinism. I believe porting PyMySQL/PyMySQL#1035 should be the final fix needed to resolve this. |
PyMySQL/PyMySQL#1035 isn't ported yet - once I've done that I'll close this. |
if server send a error to SSCurosr, SSCursor try to call self._result._finish_unbuffered_query in close function
but there is not a byte to read after recived a error packge, so the loop is allways waiting in the time, the error could't raise out .
I met the bug after I seted a mysql variable
a SELECT statement will be aborted if it takes more than 3s.
the connection received a error package with erorno 3024, but the loop is waiting packge to finitshed unbuffered_query
The text was updated successfully, but these errors were encountered: