Skip to content

Remove mysql-connector-python #30487

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

Merged
merged 3 commits into from
Apr 13, 2023

Conversation

moiseenkov
Copy link
Contributor

@moiseenkov moiseenkov commented Apr 5, 2023

Turn the package mysql-connector-python optional to exclude it from dependencies due to conflicts with the newer protobuf versions coming with Google SDK upgrade #30067

Copy link
Contributor

@eladkal eladkal left a comment

Choose a reason for hiding this comment

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

Wait.

In https://lists.apache.org/thread/j98bgw9jo7xr4fvjh27d6bfoyxr1omcm we agreed to exclude providers that block us. We did not agree to remove capabilities completely.

There are users who use this functionality and possibly users of Mysql that dont care about Google provider.
It's one thing to hold releases for MySql it's another thing to remove capabilities all together.

Mysql provider changes are not that frequent. Why can't we suspend the provider and see if the proto dependency is resolved given more time? I don't think we are in the step where we need to choose between dropping capabilities vs adding new feature to the provider.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Agree with @eladkal - this is far too much. We should either suspend the provider or (better) turn mysql-connector-python into optional feature.

@moiseenkov
Copy link
Contributor Author

Thank you all, I misunderstood the point.

I will leave the code that uses mysql-connector-python, but is it true that we have to exclude this package from dependencies anyway? If I get it right, leaving mysql-connector-python here will cause dependency conflicts.

My suggestion is removing the mysql-connector-python from the dependencies, and throwing an exception with a readable message whenever the package is used. Those users, who will face this issue, are always able to install this package manually and resolve possible conflicts on their own, or transition to the recommended library. @eladkal , @potiuk WDYT?

@potiuk
Copy link
Member

potiuk commented Apr 6, 2023

Thank you all, I misunderstood the point.

I will leave the code that uses mysql-connector-python, but is it true that we have to exclude this package from dependencies anyway? If I get it right, leaving mysql-connector-python here will cause dependency conflicts.

My suggestion is removing the mysql-connector-python from the dependencies, and throwing an exception with a readable message whenever the package is used. Those users, who will face this issue, are always able to install this package manually and resolve possible conflicts on their own, or transition to the recommended library. @eladkal , @potiuk WDYT?

You can add optional dependencies (like mysql-connector-python in this case) via provider.yaml. We already have several examples of it. For example google provider has extra "[leveldb]" which brings in plyvel dependency.

https://github.com/apache/airflow/blob/main/airflow/providers/google/provider.yaml#L1121

And you should move mysql-connector-python there from main dependencies - following the same pattern.

There are a few more changes that will need to be added:

  • The tests that are using mysql-connector-python will start failing, and that's fine - we need to separate them to a separate module and run `pytest.importorskip("mysql.connector") for that file - this will skip them on our CI, but if you manually add "mysql-connector-python" and run them, we could potentially have a separate job to run it on CI separately (and I will likely add it later) but for now skipping it is fine.

  • In the original operator you should raise "AirflowOptionalProviderFeatureException" when import of mysql.connector fails (with some description that you need mysql-connector-python to be installed.

That should remove mysql-connector-python from installed dependencies and turn it's usage into, effectively optional feature.

@moiseenkov moiseenkov force-pushed the remove-mysql-connector-python branch from 49a7298 to d02a7e1 Compare April 6, 2023 13:42
@moiseenkov
Copy link
Contributor Author

Thanks for the explanation. I updated the PR, please re-review.

@moiseenkov moiseenkov force-pushed the remove-mysql-connector-python branch 2 times, most recently from 32f5943 to de3ce87 Compare April 7, 2023 07:40
@moiseenkov moiseenkov requested a review from ashb as a code owner April 7, 2023 07:40
@moiseenkov moiseenkov requested review from potiuk and eladkal April 7, 2023 09:05
@potiuk
Copy link
Member

potiuk commented Apr 7, 2023

This looks cool and has the desired effect, mysql-connector-python is removed from the image:

https://github.com/apache/airflow/actions/runs/4636423980/jobs/8204304593?pr=30487#step:5:18767

2c2
< # This constraints file was automatically generated on 2023-04-06T12:47:16Z
---
> # This constraints file was automatically generated on 2023-04-07T07:51:23Z
77c77
< aws-sam-translator==1.63.0
---
> aws-sam-translator==1.64.0
81c81
< azure-core==1.26.3
---
> azure-core==1.26.4
88c88
< azure-mgmt-core==1.3.2
---
> azure-mgmt-core==1.4.0
141c141
< coverage==7.2.2
---
> coverage==7.2.3
175c175
< filelock==3.10.7
---
> filelock==3.11.0
321c321
< mypy-boto3-rds==1.26.102
---
> mypy-boto3-rds==1.26.108
325d324
< mysql-connector-python==8.0.32
473c472
< slack-sdk==3.20.2
---
> slack-sdk==3.21.0

However the side-effect is that some new warnings are generated while importing requests (See the failing testts - it contains explanation what to do to mark the warnings as "known" - those do not seem as harmful ones.

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

LGTM. Pending fixing the new warnings generated during import.

@moiseenkov moiseenkov force-pushed the remove-mysql-connector-python branch 3 times, most recently from cdd0703 to 3884cb0 Compare April 7, 2023 13:07
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

Nice! @eladkal ?

Copy link
Contributor

@eladkal eladkal left a comment

Choose a reason for hiding this comment

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

This is a breaking change for mysql provider. We should update provider yaml version + add entry in change log explaining to users who relay on this lib how they should migrate (install the extra)

@eladkal
Copy link
Contributor

eladkal commented Apr 7, 2023

Also please update PR title + description so users won't get the wrong impression

@potiuk
Copy link
Member

potiuk commented Apr 7, 2023

I am not 100% sure if it is breaking to be honest. We already agreed that dependency changes are non-breaking and assuming somoene already has installed mysql-connector-python, it will continue to work after the upgrade.

Breaking means - if somoene upgrades the provider, things will break. Which is not necessarily true - if someone upgrade from past provider, things will continue to work (because the user will have mysql-connector-python already installed). The user might be prevented from installing the newer provider (because of protobuf for example) but this also does not mean that it's a "breaking change".

I think, technically speaking, it's not "strongly" breaking - the usual "breaking" pattern when things break when you upgrade does not "technically" apply.

There are other scenarios where things might break - for example when you upgrade airflow image and you expect mysql operators to continue to work. But also technically it is not breaking, because images are "convenience" binaries, and while people might use them in charts, they are not even versioned with breakin/non-breaking (because they contain combination of airflow + possibly breaking providers).

So I am not really sure if we should classify that change as breaking.

@potiuk
Copy link
Member

potiuk commented Apr 7, 2023

We might still of course "classify" it as breaking (nothing prevents us from doing so, we can announce any release breaking if we think doing so will prevent some common problems from our users).

But I personally don't think it is strong enough case to classify it as such.

@eladkal
Copy link
Contributor

eladkal commented Apr 7, 2023

I am not 100% sure if it is breaking to be honest. We already agreed that dependency changes are non-breaking and assuming somoene already has installed mysql-connector-python, it will continue to work after the upgrade.

I'm ok with not listing it as breaking as long as we have a change log entry that explains what is changed. 2-3 lines in enough

@moiseenkov moiseenkov force-pushed the remove-mysql-connector-python branch from 3884cb0 to e46e70b Compare April 11, 2023 09:21
@moiseenkov moiseenkov requested a review from eladkal April 11, 2023 09:24
@moiseenkov moiseenkov force-pushed the remove-mysql-connector-python branch from e46e70b to 4d51ace Compare April 11, 2023 10:53
@moiseenkov
Copy link
Contributor Author

@potiuk , hi, can we merge it please?

@potiuk potiuk force-pushed the remove-mysql-connector-python branch from a6f4c10 to 72fa689 Compare April 13, 2023 12:10
@potiuk
Copy link
Member

potiuk commented Apr 13, 2023

I saw that for some reasons checks were not running. I rebased to rebuild it.

@potiuk potiuk force-pushed the remove-mysql-connector-python branch from 72fa689 to 93ac98f Compare April 13, 2023 14:22
@potiuk
Copy link
Member

potiuk commented Apr 13, 2023

Rebased once more after merging the #30625

@potiuk potiuk merged commit 312f7e8 into apache:main Apr 13, 2023
@ephraimbuddy ephraimbuddy added type:misc/internal Changelog: Misc changes that should appear in change log and removed type:misc/internal Changelog: Misc changes that should appear in change log labels Apr 14, 2023
potiuk added a commit to potiuk/airflow that referenced this pull request Apr 16, 2023
Yandex provider brings protobuf dependency down to <4 and we are gearing
up to updating it everywhere else. Protobuf3 support ends in Q2 2023
for Python https://protobuf.dev/support/version-support/#python

Yandex is the last provider that we do not closely collaborate with on fixing
* Gogle provider dependencies are actively upgraded to latest version
  by Google led team: apache#30067 (some of the libraries are already updated)
  with target to update all dependencies by mid-May
* Apache-Beam has already merged protobuf4 support
  apache/beam#25874 with the target of
  releasing it in 2.47.0 mid-May
* The mysql-connector-python in MySQL provider is already turned into
  optional dependency: apache#30487

The only remaining dependency limiting us to protobuf 3 (<3.21) is
yandexcloud. We've opened an issue to yandexcloud
yandex-cloud/python-sdk#71 3 weeks ago
and while there was an initial interest, there is no progress on
the issue, therefore - in order to prepare for running all
the tests and final migration to protobuf4 we need to suspend
Yandex provider - following the suspension process we agreed
and got a LAZY CONSENSUS on in
the https://lists.apache.org/thread/g8b3k028qhzgw6c3yz4jvmlc67kcr9hj
mailing list discussion.

The yandex provider can be removed from suspension by a PR reverting
this change once yandexcloud dependency removes the protobuf limitation
in their release and PR reverting this change (and fixing all tests
and static check that will be needed) is the way it can be done.
wookiist pushed a commit to wookiist/airflow that referenced this pull request Apr 19, 2023
* Turn the package 'mysql-connector-python' as an optional feature

* Update airflow/providers/mysql/provider.yaml

* Update airflow/providers/mysql/CHANGELOG.rst

---------

Co-authored-by: eladkal <[email protected]>
potiuk added a commit that referenced this pull request Apr 19, 2023
Yandex provider brings protobuf dependency down to <4 and we are gearing
up to updating it everywhere else. Protobuf3 support ends in Q2 2023
for Python https://protobuf.dev/support/version-support/#python

Yandex is the last provider that we do not closely collaborate with on fixing
* Gogle provider dependencies are actively upgraded to latest version
  by Google led team: #30067 (some of the libraries are already updated)
  with target to update all dependencies by mid-May
* Apache-Beam has already merged protobuf4 support
  apache/beam#25874 with the target of
  releasing it in 2.47.0 mid-May
* The mysql-connector-python in MySQL provider is already turned into
  optional dependency: #30487

The only remaining dependency limiting us to protobuf 3 (<3.21) is
yandexcloud. We've opened an issue to yandexcloud
yandex-cloud/python-sdk#71 3 weeks ago
and while there was an initial interest, there is no progress on
the issue, therefore - in order to prepare for running all
the tests and final migration to protobuf4 we need to suspend
Yandex provider - following the suspension process we agreed
and got a LAZY CONSENSUS on in
the https://lists.apache.org/thread/g8b3k028qhzgw6c3yz4jvmlc67kcr9hj
mailing list discussion.

The yandex provider can be removed from suspension by a PR reverting
this change once yandexcloud dependency removes the protobuf limitation
in their release and PR reverting this change (and fixing all tests
and static check that will be needed) is the way it can be done.
@potiuk
Copy link
Member

potiuk commented Apr 20, 2023

FYI. MySQL does not really collaboarate. They released a new version of mysql-connector-python 8.0.33` two days ago, but it still has < 3.20 limit on protobuf. Also, I got this - completely useless and apparently automatically generated -response today to my issue:

Here are the general steps to upgrade to a newer version of protobuf:

Check compatibility: Before upgrading to a newer version of protobuf, check if the new version is compatible with your current codebase and other dependencies. Review the release notes and documentation to see if there are any changes or deprecations that could affect your code.

Update protobuf files: If you have any custom protobuf files, update them to the latest version. You can use the protoc compiler to generate updated code from the new protobuf files.

Update dependencies: If you are using a language-specific implementation of protobuf (such as the Python protobuf package or the Java protobuf library), update your dependencies to the latest version.

Update code: Update your code to use the new version of protobuf. This may involve updating method signatures, changing import statements, and updating serialization/deserialization code.

Test thoroughly: After making the updates, test your code thoroughly to ensure that everything works as expected. Test both positive and negative cases to ensure that there are no regressions or new issues introduced by the upgrade.

Roll back if necessary: If you encounter any issues or compatibility problems, be prepared to roll back to the previous version of protobuf until the issues can be resolved.

By following these steps, you should be able to successfully upgrade to a newer version of protobuf while minimizing the risk of compatibility issues and regressions.

I answered appropriately : https://forums.mysql.com/read.php?50,708413,708803#msg-708803

@notatallshaw-gts
Copy link
Contributor

notatallshaw-gts commented Apr 20, 2023 via email

@potiuk
Copy link
Member

potiuk commented Apr 20, 2023

So at least that answer contains information.

Let's see. Yes it's interesting that they respond differently to different issues. But - it is not an issue for us any more. It's issue for them after we merged this PR.

@nmariz
Copy link

nmariz commented Apr 21, 2023

(Disclaimer: I'm the lead developer of Connector/Python)
Like mentioned by @notatallshaw-gts, MySQL Connector/Python has a blocker (see protocolbuffers/protobuf#12373) for upgrading to Protobuf 4.22.x.
We are trying our best to find workarounds. However, in our case, it only affects us with Protobuf +4.22.0. So, in case Protobuf bug is not fixed on time, we are adding support until Protobuf 4.21.12 in the upcoming release.

@potiuk I'm sorry very about the late reply on the forum. This indeed is the same issue.

@potiuk
Copy link
Member

potiuk commented Apr 21, 2023

Cool. Great to know it! @nmariz . Thanks for letting us know - looking forward to getting it fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants