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

MySQL 8.0.34 and 8.1.0 deprecates MYSQL_OPT_RECONNECT #1322

Open
yahonda opened this issue Jul 18, 2023 · 13 comments
Open

MySQL 8.0.34 and 8.1.0 deprecates MYSQL_OPT_RECONNECT #1322

yahonda opened this issue Jul 18, 2023 · 13 comments

Comments

@yahonda
Copy link
Contributor

yahonda commented Jul 18, 2023

MySQL 8.0.34 and 8.1.0 deprecates MYSQL_OPT_RECONNECT

Since MySQL 8.0.34 and 8.1.0 deprecates MYSQL_OPT_RECONNECT, mysql2 gem is also affected.

https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-34.html#mysqld-8-0-34-deprecation-removal
https://dev.mysql.com/doc/relnotes/mysql/8.1/en/news-8-1-0.html#mysqld-8-1-0-deprecation-removal

The MySQL client library currently supports performing an automatic reconnection to the server if it finds that the connection is down and an application attempts to send a statement to the server to be executed. Now, this feature is deprecated and subject to removal in a future release of MySQL.

The related MYSQL_OPT_RECONNECT option is still available but it is also deprecated. C API functions mysql_get_option() and mysql_options() now write a deprecation warning to the standard error output when an application specifies MYSQL_OPT_RECONNECT. (WL #15766)

Here are two specs that raise WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.

$ bundle exec rspec spec/mysql2/client_spec.rb -e "should send init_command after reconnect"
<internal:gc>:251: warning: double_heap is deprecated, please use expand_heap instead
Run options: include {:full_description=>/should\ send\ init_command\ after\ reconnect/}

Randomized with seed 13185

Mysql2::Client
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
  should send init_command after reconnect

Finished in 0.01231 seconds (files took 0.11187 seconds to load)
1 example, 0 failures

Randomized with seed 13185

$
$ bundle exec rspec spec/mysql2/client_spec.rb -e "should not try to query closed mysql connection"
<internal:gc>:251: warning: double_heap is deprecated, please use expand_heap instead
Run options: include {:full_description=>/should\ not\ try\ to\ query\ closed\ mysql\ connection/}

Randomized with seed 29247

Mysql2::Client
WARNING: MYSQL_OPT_RECONNECT is deprecated and will be removed in a future version.
  should not try to query closed mysql connection

Finished in 0.00981 seconds (files took 0.11158 seconds to load)
1 example, 0 failures

Randomized with seed 29247

$
  • Ruby and MySQL version
$ ruby -v
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-linux]
$ mysql -uroot -e 'select version()'
+-----------+
| version() |
+-----------+
| 8.1.0     |
+-----------+
$

  • Installed packages
$ sudo apt list --installed |grep mysql
... snip ...
libmysqlclient-dev/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
libmysqlclient22/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-apt-config/now 0.8.24-1 all [installed,local]
mysql-client/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-common/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-community-client-core/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-community-client-plugins/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-community-client/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-community-server-core/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-community-server/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
mysql-server/now 8.1.0-1ubuntu23.04 amd64 [installed,local]
$
@sodabrew
Copy link
Collaborator

It's pretty exciting to see the news on MySQL 8.x Innovation releases breathing some life into it.

If a user wants to put in a deprecated option they may do so. I wouldn't remove the flag bindings yet, but would certainly want to gracefully handle the missing definition in future versions of the mysql2 gem.

@jamgregory
Copy link

Just wanted to add to this: passing in reconnect as a config option, regardless of whether it is true or false (or even nil) will cause this error to be displayed (just spotted this in our Rails app as it has reconnect: false configured in database.yml)

I guess ideally it should not even set this if reconnect: false as that's the default (according to https://dev.mysql.com/doc/c-api/8.0/en/c-api-auto-reconnect.html, anyway) but it would be good if a clearer deprecation message could be displayed by the gem 👍

@pioz
Copy link

pioz commented Aug 28, 2023

Same warning here with MySQL 8.1 and mysql2 0.5.5.

@alvincrespo
Copy link

Does anyone know why MYSQL_OPT_RECONNECT is being deprecated? I tried looking for the related work log item, 15766, but couldn't find it here.

@ahmetabdi
Copy link

Any updates on this? will this not break mysql2 once MYSQL_OPT_RECONNECT is removed?

@sodabrew
Copy link
Collaborator

It will break when removed, yes. Need to get in a conditional definition with an in-Ruby warning that says the feature was removed.

@ram-gudapati
Copy link

@sodabrew
our c++ application uses mysql_options with MYSQL_OPT_RECONNECT.
what are alternatives so we get the same behavior without changing our application code to get same behavior as RECONNECT.
if changing the application is only option what is the best way with minimal impact, so the reconnect works as before.

@breisig
Copy link

breisig commented Feb 12, 2024

It would be nice to get rid of this MYSQL_OPT_RECONNECT warning message.

@joshuapinter
Copy link

@breisig FYI, we moved to Trilogy. Would highly recommend it as well, if it's possible for you. Modern and well-maintained going forward. Some tweaks needed but mostly a drop-in replacement.

@breisig
Copy link

breisig commented Feb 22, 2024

@joshuapinter Trilogy doesn't have basic caching_sha2_password support which is required in newer MySQL 8.x so that's out.

@gdubicki
Copy link

@joshuapinter Trilogy doesn't have basic caching_sha2_password support which is required in newer MySQL 8.x so that's out.

The support for that has been added recently - see https://github.com/trilogy-libraries/trilogy/releases/tag/v2.8.0, @breisig. I haven't yet used Trilogy myself, but github.com stands behind it, so it looks solid.

@tmcabee
Copy link

tmcabee commented Aug 30, 2024

@breisig FYI, we moved to Trilogy. Would highly recommend it as well, if it's possible for you. Modern and well-maintained going forward. Some tweaks needed but mostly a drop-in replacement.

@joshuapinter Curious what tweaks you had to make?

@joshuapinter
Copy link

@tmcabee Honestly, almost nothing in our main Rails app. Mostly around manual connections using the Trilogy adapter for imports and conversions.

If you're not using stuff like Mysql2::Client.new then you don't have to worry about it. If you are, there are slight changes to how this works in Trilogy.

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

No branches or pull requests