8000 MySQL errors default to InternalError · Issue #816 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

MySQL errors default to InternalError #816

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
yoch opened this issue Oct 24, 2019 · 1 comment · Fixed by #823
Closed

MySQL errors default to InternalError #816

yoch opened this issue Oct 24, 2019 · 1 comment · Fixed by #823

Comments

@yoch
Copy link
yoch commented Oct 24, 2019

Is there any reason why MySQL errors are mapped to InternalError by default ?

errorclass = error_map.get(errno, InternalError)

IMHO, most of the errors returned by MySQL are more likely to be related with OperationalError instead of InternalError. For instance, mysqldb use InternalError for codes below 1000 and OperationalError for other.

Also, this choice imply that any new error added in the future by implementors will be treated as InternalError. This already the case at least for MariaDB specific errors, and caused bugs like #607 or sqlalchemy/sqlalchemy#4945

@zzzeek
Copy link
Contributor
zzzeek commented Nov 11, 2019

hi -

in this issue we would like to determine if this stack trace in PyMySQL is a bug:

[Thu Oct 24 13:17:54.100876 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]   File "/usr/local/lib/python3.5/dist-packages/pymysql/connections.py", line 547, in ping
[Thu Oct 24 13:17:54.100890 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]     self._read_ok_packet()
[Thu Oct 24 13:17:54.100903 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]   File "/usr/local/lib/python3.5/dist-packages/pymysql/connections.py", line 394, in _read_ok_packet
[Thu Oct 24 13:17:54.100917 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]     pkt = self._read_packet()
[Thu Oct 24 13:17:54.100958 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]   File "/usr/local/lib/python3.5/dist-packages/pymysql/connections.py", line 684, in _read_packet
[Thu Oct 24 13:17:54.100973 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]     packet.check_error()
[Thu Oct 24 13:17:54.101122 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]   File "/usr/local/lib/python3.5/dist-packages/pymysql/protocol.py", line 220, in check_error
[Thu Oct 24 13:17:54.101152 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]     err.raise_mysql_exception(self._data)
[Thu Oct 24 13:17:54.101167 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]   File "/usr/local/lib/python3.5/dist-packages/pymysql/err.py", line 109, in raise_mysql_exception
[Thu Oct 24 13:17:54.101181 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204]     raise errorclass(errno, errval)
[Thu Oct 24 13:17:54.101194 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204] sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1927, 'Connection was killed')
[Thu Oct 24 13:17:54.101208 2019] [wsgi:error] [pid 29865:tid 140251812648704] [remote 78.250.16.86:58204] (Background on this error at: http://sqlalche.me/e/2j85)

I believe it is an error because "connection was killed" is being emitted by the server and PyMySQL should be anticipating this error and raising an OperationalError; an InternalError means it was not handled.

can we get a yes/no on this? I'm likely going to work around in SQLAlchemy in any case.

sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Nov 11, 2019
Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: PyMySQL/PyMySQL#816
Fixes: #4945
(cherry picked from commit 31a66b5)
sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Nov 11, 2019
Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: PyMySQL/PyMySQL#816
Fixes: #4945
methane added a commit to methane/PyMySQL that referenced this issue Nov 12, 2019
methane added a commit to methane/PyMySQL that referenced this issue Nov 12, 2019
sumau pushed a commit to sumau/sqlalchemy that referenced this issue Dec 29, 2019
Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: PyMySQL/PyMySQL#816
Fixes: sqlalchemy#4945
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0