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

Sync upstream 1.8.0 #14

Merged
merged 34 commits into from
Dec 6, 2024
Merged

Sync upstream 1.8.0 #14

merged 34 commits into from
Dec 6, 2024

Conversation

thalesmg
Copy link

@thalesmg thalesmg commented Dec 5, 2024

No description provided.

juhlig and others added 30 commits October 12, 2020 10:43
* Possibility to send numbers as decimals using {decimal, Value}.
* New option {float_as_decimal, boolean() | non_neg_integer()} to
  do this automatically for floats, optionally rounded to a given
  number of decimals.
…tp#190)

If query/N or execute/N is called on a connection which is
currently in a transaction owned by another process, `{error,
busy}` is returned.

If transaction/N is called is called on a connection which is
currently in a transaction owned by another process, `{aborted,
busy}` is returned.

The other process and its transaction are unaffected.
MySQL < 5.7.0 and MariaDB < 10.1.0 only support tlsv1. In all other cases
we use all TLS versions available in the running Erlang/OTP ssl application.

This fixes problems such as this:

> ssl:connect(Port, [{versions,[tlsv1]},{verify,verify_none},{active,false}], 5000)
{error,{tls_alert,{bad_record_mac,"TLS client: In state hello at tls_record.erl:571 generated CLIENT ALERT: Fatal - Bad Record MAC\n {unsupported_version,{0,0}}"}}}
If a socket error occurs when fetching a response, the mysql connection exits with the socket error as the exit reason instead of a crash.

Fixes mysql-otp#196.
* Fix undetected closing of connection
* Non-normal exit when connection closed by server

Co-authored-by: Maria Scott <maria-12648430@hnc-agency.org>
Co-authored-by: Viktor Söderqvist <viktor.soderqvist@est.tech>
…ql-otp#194)

The new option `{decode_decimal, auto | number | float | binary}` controls how a
DECIMAL value is translated to an Erlang term. The default 'auto' is the legacy behaviour which returns an integer or a float when no precision loss can happen for the column and a binary otherwise. The options 'number' and 'float' may return a float even if it can result in precision loss, while 'binary' always returns the textual representation of the number.
This is to avoid creating atoms when making use of prepared statements.

---------

Co-authored-by: Stefan Strigler <stefan@strigler.de>
Build and run tests in GitHub Actions.
Docker is used to for starting MySQL or MariaDB.

Additional changes:

* Changed 0.0 matches to +0.0 to make it compile on OTP 27.
* Fix test case to work with MySQL running remote (not localhost).
* Update minimal Erlang/OTP version to 19.
* Ensure database dropped before testing create.
* Simplify test prep instructions in README and refer to scripts.
* Add instructions how to run tests against MySQL or MariaDB in localhost.
* Delete backported code for OTP < 18
* Delete .travis.yml
Since we are now targeting OTP >= 21, we can remove the exception
handling switch macros, as `Class:Reason:Stacktrace` is supported since
OTP 21.
…/1,2` depending on OTP release (mysql-otp#212)

We use the `gen_server:format_status/2` callback in order to hide
sensitive data from logs.

In OTP/25, another callback `format_status/1` was introduced which
should replace `format_status/2`. In OTP/27, `format_status/2` was
deprecated, and raises a compiler warning.

This PR adds the `format_status/1` callback, and a conditional that adds
the `format_status/2` callback for OTP<25, where `format_status/1` is
absent.

I also changed the behavior such that it _always_ hides the sensitive
data, ie not only in case of crashes, because BSTS ;) If a user _needs_
the unobfuscated state, he can always use `sys:get_state`.
`mysql_protocol` uses `public_key:encrypt_public`, which was deprecated
in OTP 27.0 for securtity reasons. This function was undeprecated again
in OTP 27.1 because only `rsa_pkcs1_padding` (used in MySQL < 8.0.5) is
unsafe, while `rsa_pkcs1_oaep_padding` (used in MySQL >= 8.0.5) is still
safe.

This commit works around the deprecation warning in OTP 27.0 and at the
same time logs a warning when `rsa_pkcs1_padding` is used.
When a transaction caller process exits, `mysql_conn` will close the
socket and stop itself.
Prior to this fix, the socket close function call disregards the
transport implementation module (`sockmod`), always calls
`gen_tcp:close` and matches it against `ok`. This PR changes to `ok =
SockMod:close(...),`.

Additionally, the `flush` option is added to the `demonitor` call, when
a transaction monitor is demonitored.

Co-authored-by: Jan Uhlig <juhlig@hnc-agency.org>
`make docs` was failing because of these edoc syntax errors.
The socket backend that `mysql_tests/socket_backend_test` tests is only
supported in OTP 23+, and still very unstable in 23. Therefore, the
change in this PR skips the test on OTP =< 23.

Also changed the level of logs emitted from the test suite from `info`
to `notice`, because `info` is below the logging threshold in the
default configuration, ie the minimum level is `notice`.
This PR includes OTP 27 in the CI, and makes some small cosmetic
(naming) changes.
Replace all usages of `dict` with maps. Also streamlined `mysql_cache` a
bit while I was at it.
Updates our 7 years old version of `erlang.mk`. The core module
`core/beam-cache` is now also needed to run tests.
@thalesmg thalesmg force-pushed the sync-upstream branch 3 times, most recently from a15c655 to a9d1049 Compare December 5, 2024 20:25
@thalesmg thalesmg marked this pull request as ready for review December 5, 2024 20:30
@thalesmg thalesmg requested a review from terry-xiaoyu December 5, 2024 20:31
@thalesmg thalesmg merged commit 0fc059f into emqx:master Dec 6, 2024
20 checks passed
@thalesmg thalesmg deleted the sync-upstream branch December 6, 2024 12:15
thalesmg added a commit to thalesmg/emqx that referenced this pull request Dec 9, 2024
- mysql-otp : emqx/mysql-otp#14

Brings several fixes from upstream, in particular a case clause error:

```
Generic server <0.23937.0> terminating. Reason: {{case_clause,{error,closed}},[{mysql_protocol,fetch_response,7,[{file,\"mysql_protocol.erl\"},{line,569}]},{mysql_conn,query,4,[{file,\"mysql_conn.erl\"},{line,648}]},{mysql_conn,handle_call,3,[{file,\"mysql_conn.erl\"},{line,316}]},{gen_server,try_handle_call,4,[{file,\"gen_server.erl\"},{line,1131}]},{gen_server,handle_msg,6,[{file,\"gen_server.erl\"},{line,1160}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,241}]}]}.
```

- ecpool : emqx/ecpool#57

Fixes that were missed from 0.5.12, to avoid crashing ecpool workers in a tight loop and
reach maximum restart intensity.
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

Successfully merging this pull request may close these issues.

9 participants