Open kalymero opened 5 years ago
I'm also experiencing this same issue. Downgrading to Erlang 21.1.4 worked.
After running a git bisect
on OTP, it seems that this is related to a change in the SSL implementation:
6168cf2f5f8b5839b1a56ce870658d76faf3c22f is the first bad commit
commit 6168cf2f5f8b5839b1a56ce870658d76faf3c22f
Author: Ingela Anderton Andin <ingela@erlang.org>
Date: Mon Nov 19 13:50:35 2018 +0100
ssl: Internaly use {active, N}
Make next_record an internal help function to next_event and avoid
duplicate calls to tls_socket:setopts for setting the active option.
I have been able to restore original behaviour with the following change to mariaex:
diff --git a/lib/mariaex/protocol.ex b/lib/mariaex/protocol.ex
index 7b24c62..ecdfca9 100644
--- a/lib/mariaex/protocol.ex
+++ b/lib/mariaex/protocol.ex
@@ -311,7 +311,7 @@ defmodule Mariaex.Protocol do
DBConnection callback
"""
def checkout(%{buffer: :active_once, sock: {sock_mod, sock}} = s) do
- case setopts(s, [active: :false], :active_once) do
+ case setopts(s, [active: 0], :active_once) do
:ok -> sock_mod.recv_active(sock, 0, "") |> handle_recv_buffer(s)
{:disconnect, _, _} = dis -> dis
end
However, I am only passingly familiar with Elixir and even more unfamiliar with Erlang. As such, I do not know what implications this change may have. From what I can make of the code, it seems that this works for similar reasons as described in the line 814 up the upstream change: https://github.com/erlang/otp/commit/6168cf2f5f8b5839b1a56ce870658d76faf3c22f?diff=unified#diff-f053ce3c6b9ffc18f497e4bcbc9661f2R814.
Can any maintainers validate this would be a safe change? I'd be happy to turn it into a pull request.
Setting active, 0
seems to have worked by coincidence, and I have proposed a change in #253 that seems to "more-correctly" address the actual underlying issue. However, I am not sure that the proposed change retains the exact same semantics as the original code and a thorough review should be done before using or merging.
Environment
Description
Starting from
OTP-21.2.0
, when trying to connect to a mysql instance with TLS enabled from an Elixir/Ecto application the:ssl.recv()
call fails due a timeout with the following stacktrace:For the test we used Percona and Mysql 5.7 official docker images.
Please note that it works fine with older OTP versions (for instance
OTP-21.1.4
)Also the Erlang layer looks good, it's possible to connect and query the db in pure Erlang
An educated guess is that in the new OTP versions some lib changed behaviour and it breaks the Mariaex flow
How to reproduce
127.0.0.1:3306
socket withtlsv1.2
to thetest_db
database.(you can also use
mysql:5.7
image andtlsv1.1
)The easiest way is to create a new ecto project
configure Ecto
run it