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(mysql): catch PyMySQL OperationalError exception #7919

Merged
merged 1 commit into from
Jan 8, 2024

Conversation

maxibor
Copy link
Contributor

@maxibor maxibor commented Jan 5, 2024

Description of changes

When trying to connect to a mySQL backend, the following error can appear:

OperationalError: (pymysql.err.OperationalError) (1298, "Unknown or incorrect time zone: 'UTC'")
(Background on this error at: https://sqlalche.me/e/20/e3q8)

This is due to an exception generated by PyMySQL.
The exception, formerly generated by SQLAlchemy was already caught by Ibis since #6010, this PR adds a catching of the PyMySQL exception.

Issues closed

Resolves #7918

Copy link
Contributor

github-actions bot commented Jan 5, 2024

ACTION NEEDED

Ibis follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message.

Please update your PR title and description to match the specification.

@maxibor maxibor changed the title Catch pymysql operational error fix: catch PyMySQL OperationalError exception Jan 5, 2024
@cpcloud cpcloud changed the title fix: catch PyMySQL OperationalError exception fix(mysql): catch PyMySQL OperationalError exception Jan 5, 2024
@cpcloud
Copy link
Member

cpcloud commented Jan 5, 2024

@maxibor Thanks for the PR!

Why isn't catching sqlalchemy's OperationalError sufficient here?

@cpcloud cpcloud added bug Incorrect behavior inside of ibis mysql The MySQL backend labels Jan 5, 2024
@maxibor
Copy link
Contributor Author

maxibor commented Jan 5, 2024

Seems like these are 2 different exceptions. The pymysql exception was anyway not caught in the current version of Ibis.

@cpcloud
Copy link
Member

cpcloud commented Jan 5, 2024

Makes sense!

It's not clear to me whether we need both exceptions.

Can you describe your MySQL setup?

  • What version of MySQL are using?
  • What distribution (MySQL, MariaDB, something else)

@maxibor
Copy link
Contributor Author

maxibor commented Jan 5, 2024

Just copy pasting from #7918

mySQL 5.5.5
mariaDB 10.3.38
Ibis 7.2.0

@cpcloud
Copy link
Member

cpcloud commented Jan 5, 2024

OperationalError: (pymysql.err.OperationalError) (1298, "Unknown or incorrect time zone: 'UTC'")
(Background on this error at: https://sqlalche.me/e/20/e3q8)

This is a SQLAlchemy exception, and the (pymysql.err.OperationalError) bit indicates that the underlying exception type is coming from pymysql, but that's not the actual exception raised.

Does this PR address the issue for you?

@maxibor
Copy link
Contributor Author

maxibor commented Jan 5, 2024

Yes, that's why I opened it ;)

@cpcloud
Copy link
Member

cpcloud commented Jan 5, 2024

Ah, got it. This probably because of the use of a raw cursor and since we're testing against a system that has this defined, the exception is never raised.

Hm, I wonder if there's a way we can test this.

Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

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

LGTM.

This code path will change once we finish porting backends to the new sqlglot compilers, and we won't need to catch the sqlalchemy exception (just the pymysql one).

That said, this fixes a user-facing issue and isn't easily testable so I'm going to merge it.

@cpcloud cpcloud merged commit f2c2664 into ibis-project:main Jan 8, 2024
83 of 84 checks passed
Copy link

@mysqldba-nandy mysqldba-nandy left a comment

Choose a reason for hiding this comment

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

excuse me, maybe you should use SET @@session.time_zone = '+00:00', MySQL/MariaDB can not recognize UTC by default, only if table mysql.time_zone is not empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis mysql The MySQL backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: Incorrect UTC time zone with mySQL backend triggers OperationalError
3 participants