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

[pull] master from brianmario:master #2

Open
wants to merge 57 commits into
base: master
Choose a base branch
from

Conversation

pull[bot]
Copy link

@pull pull bot commented Dec 17, 2022

See Commits and Changes for more details.


Created by pull[bot]

Can you help keep this open source service alive? 💖 Please sponsor : )

byroot and others added 4 commits November 22, 2022 08:54
Applications using fiber are able to do concurrent queries
from the same thread.
Lock on the current Fiber rather than current Thread
This commit fixes the SSL related failures in the CI container Fedora cases.

The MariaDB 10.5.18 mysqld failed to start in the CI, container "fedora:rawhide" (Fedora 38)
and "fedora:latest" (Fedora 37) cases with the SSL error below.
So, we set the SSL configurations manually as well as MacOSX case.

```
 + /usr/libexec/mysqld --user=root --log-error=/build/mysql.log --ssl
2022-12-16 17:49:58 0 [Note] /usr/libexec/mysqld (mysqld 10.5.18-MariaDB) starting as process 724 ...
+ cat /build/mysql.log
2022-12-16 17:49:58 0 [Note] InnoDB: Uses event mutexes
2022-12-16 17:49:58 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
2022-12-16 17:49:58 0 [Note] InnoDB: Number of pools: 1
2022-12-16 17:49:58 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2022-12-16 17:49:58 0 [Note] mysqld: O_TMPFILE is not supported on /var/tmp (disabling future attempts)
2022-12-16 17:49:58 0 [Note] InnoDB: Using Linux native AIO
2022-12-16 17:49:58 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2022-12-16 17:49:58 0 [Note] InnoDB: Completed initialization of buffer pool
2022-12-16 17:49:58 0 [Note] InnoDB: 128 rollback segments are active.
2022-12-16 17:49:58 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-12-16 17:49:58 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-12-16 17:49:58 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-12-16 17:49:58 0 [Note] InnoDB: 10.5.18 started; log sequence number 45079; transaction id 20
2022-12-16 17:49:58 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-12-16 17:49:58 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2022-12-16 17:49:58 0 [Note] InnoDB: Buffer pool(s) load completed at 221216 17:49:58
SSL error: Private key does not match the certificate public key
Error: -16 17:49:58 0 [ERROR] Failed to setup SSL
Error: -16 17:49:58 0 [ERROR] SSL error: Private key does not match the certificate public key
Error: -16 17:49:58 0 [ERROR] Aborting
```

After fixing the issue, we also saw the following failing tests with the error
below. So, we recreated the db user.

```
expected no Exception, got #<Mysql2::Error: Access denied for user 'root'@'localhost'> with backtrace:
```

Note this issue didn't happened on the container CentOS case. But as we applied
the fix to all the container cases to simplify the logic.
@pull pull bot added the ⤵️ pull label Dec 17, 2022
junaruga and others added 25 commits December 22, 2022 16:23
The rubocop 1.41.1 complained with the message below. This commit suppresses the
message, and makes the CI pass.

https://github.com/brianmario/mysql2/actions/runs/3758719510/jobs/6387395566#step:4:12
```
 lib/mysql2/result.rb:2:3: C: Style/Documentation: Missing top-level documentation comment for class Mysql2::Result.
  class Result
  ^^^^^^^^^^^^
```
As we fixed some of the issues, we can drop the allow-failure option in some
cases. #1165 was resolved by mysql2 0.5.4, while #1194 needs attention.
Ruby 2.7+ introduced GC compaction via GC.compact.
Starting a few MacOS majors ago, OpenSSL was no longer included in a way that
applications could link against. Even the system Ruby at /usr/bin/ruby was
modified to use a MacOS internal SSL implementation.

The most common workaround is to use Homebrew to install OpenSSL. Using GitHub
Actions as the project's CI tool, we found that both [email protected] and openssl@3
were installed in the default image, and that openssl@3 was returned by default
but this mismatched the version the MySQL client libraries were compiled against.

While the quick workaround might be to look for [email protected] instead of openssl,
a more general improvement is to provide an option for users to specify where
OpenSSL is installed. Indeed this issue has been the cause of many postings on
GH issues and Stack Overflow over the years. Hopefully this PR improves the
situation for a broad swath of users!

Unlike the existing option `--with-opt-dir`, the new option `--with-openssl-dir`
will fail if the argument is not a valid path rather than producing unexpected
results at runtime.

This is the default behavior on MacOS:

    --with-openssl-dir=$(brew --prefix openssl)

If you have both [email protected] and openssl@3 installed, be explicit:

    --with-openssl-dir=$(brew --prefix [email protected])

The option is available on all platforms and may be helpful for non-default
OpenSSL installations on Linux or FreeBSD as well.

Co-authored-by: Jun Aruga <[email protected]>
… MariaDB versions (#1306)

Print the client version number in SSL warning.
Add comments to explain the ssl mode setting function.
Add MariaDB Connector/C 3.x to the relevant SSL mode code path.

With thanks to Jun Aruga for identifying this issue and reviewing changes.
…s. (#1187)

Enable the verbose option in the Makefile used to compile the extension to
print the compiling command lines in the log.

Note that we use MAKEFLAGS rather than GNUMAKEFLAGS[1], because the
GNUMAKEFLAGS doesn't work for the make used in CI MacOS cases.

We don't need to set the verbose option to the CI Fedora and CentOS cases
(`.github/workflows/container.yml`). Because the Rubies from the Ruby RPM
package used in Fedora and CentOS cases are already enabling the verbose option.

[1] https://www.gnu.org/software/make/manual/html_node/Options_002fRecursion.html
… test.

In the Fedora project, we are running the mysql2 tests on the build environment
with a user permission, without root permission and without `sudo`.

In this case, we couldn't set up the pem files required to run SSL tests in the
`/etc/mysql`. This custom SSL directory option gives an option to run the SSL
tests executed in the environment.

How to use:

```
$ TEST_RUBY_MYSQL2_SSL_CERT_DIR=/tmp/mysql2 \
  bundle exec rake spec
```
Add an option to set a custom SSL pem files directory in test.
MySQL and MariaDB have long aliased the `utf8` charset to the
underlying `utf8mb3`. They both switched to report the underlying
charset name instead of the alias name, allowing `utf8` to target
`utf8mb4` in the future.

That means we need to explicitly map `utf8mb3` for folks running
newer MySQL/MariaDB with older `utf8` dbs.
10.6 repo URL was moved. 10.11 package name no longer includes version suffix.

Switch both to deb.mariadb.org mirrors and use suffix-less package names.
for mysql 8.3 support

Co-authored-by: Mike Dalessio <[email protected]>
…sl_set

use mysql_options if mysql_ssl_set isn't available (mysql client 8.3 support)
tenderlove and others added 28 commits February 8, 2024 08:53
…erences` (#1365)

This commit uses newly supported `expand_heap` option if Ruby version is 3.2 or higher.

- Warning message fixed by this commit:
```
$ bundle exec rake spec
... snip ...
<internal:gc>:286: warning: double_heap is deprecated, please use expand_heap instead
... snip ...
```

Refer to ruby/ruby@a6dd859
Ruby 3.4 will promote bigdecimal gem to a bundled gem in order to improve maintenancebility.
To migrate to Ruby 3.4 easily, Ruby 3.3 warns a use of bigdecimal without adding it to dependencies.

> /build/lib/mysql2.rb:2: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.

So this patch adds bigdecimal to runtime dependencies.

I know bigdecimal is not always necessary, but I'd like to prevent a lot of users from adding the gem to their Gemfile manually.

Ref. https://bugs.ruby-lang.org/issues/20187
This type was added in MySQL 9.0, so ensure we can parse it here. See
also:

https://dev.mysql.com/doc/dev/mysql-server/latest/field__types_8h.html

Signed-off-by: Dirkjan Bussink <[email protected]>
In particular, the extconf.rb build script. But there's also one test as well.
Since OpenSSL 3.2, setting CA:TRUE seems to be required, otherwise
we will get an error when trying to use CA file without the field.
Example of such error using the openssl verify command:

```
$ openssl verify -CAfile ca-cert.pem client-cert.pem
CN=ca_mysql2gem
error 79 at 1 depth lookup: invalid CA certificate
error client-cert.pem: verification failed
```
* caching_sha2_password requests secure connection if cache is not ready on server-side.
get_server_public_key option enables clients to create secure connection automatically even if connection is not SSL.

* return error if get_server_public_key option is not supported
No longer using this CI service.
Between fetching the result and accessing the affected_rows property, GC
might have been triggered and might have freed some Mysql2::Statement
objects. This calls mysql_stmt_close which resets the connection
affected_rows to -1, which in turn is treated as an error when calling
mysql_affected_rows.

```
client.query("SELECT 1")
client.affected_rows # raises Mysql2::Error
```

Note that the data type of mysql_affected_rows changed from my_ulonglong
to uint64_t starting with MySQL 8.0. Older versions should still work, though.
Fix compilation issues on my system.
Redact password from query_options to avoid leaking
credentials in exceptions via #inspect. Minor refactor
to make RuboCop happy about client.rb complexity.

Closes #1049
While working on Mysql2 prepared statement support in Rails,
I found them very hard to use. Most notably we sometimes need to
close them eagerly, but it's complicated by the fact that you can
only call `close` once, any subsequent call raises an error. There
was also no way to check if a statement was closed or not.

This change noops on repeat calls to `close` and adds `closed?`
* Add bigdecimal dependency, no longer installed by default in Ruby 3.4
* CI: remove Ubuntu 18.04 image because it doesn't exist anymore
* CI: brew install zstd on MacOS

Co-authored-by: Aaron Stone <[email protected]>
mysql2 gem dropped testing for MySQL 5.1 which was released in Dec 2008
and already EOL in Dec 2013 at efa47a9.

If we no longer support MySQL 5.1, utf8 (utf8mb3) is not appropriate
default encoding for MySQL 5.5 or higher, utf8mb4 should be set for
that.

FYI, Rails 6.0 no longer support MySQL 5.1 and set utf8mb4 by default.

rails/rails#33608
rails/rails#33853
CI: Add Ruby 3.4, MySQL 8.4, MariaDB 11.4, Ubuntu 24.04 and other updates
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.