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

ping_handle does not handle errors #217

Closed
kpanic opened this issue Feb 19, 2018 · 1 comment
Closed

ping_handle does not handle errors #217

kpanic opened this issue Feb 19, 2018 · 1 comment

Comments

@kpanic
Copy link
Contributor

kpanic commented Feb 19, 2018

Hi, I discovered this behaviour in mariaex. I used in a test repo version 0.8.4

This issue https://github.com/elixir-ecto/postgrex/pull/258/files seems to be similar.
Was mentioned by @fishcakez on IRC

# Start with db down
iex(1)> {:ok, p} = Mariaex.start_link(username: "beatpanic", database: "ecto_simple", password: "supersecret")
{:ok, #PID<0.180.0>}
iex(2)> 
21:16:35.429 [error] Mariaex.Protocol (#PID<0.180.0>) failed to connect: ** (Mariaex.Error) tcp connect: econnrefused
 
21:16:36.499 [error] Mariaex.Protocol (#PID<0.180.0>) failed to connect: ** (Mariaex.Error) tcp connect: econnrefused
 
21:16:39.048 [error] Mariaex.Protocol (#PID<0.180.0>) failed to connect: ** (Mariaex.Error) tcp connect: econnrefused
21:16:42.791 [error] Mariaex.Protocol (#PID<0.180.0>) failed to connect: ** (Mariaex.Error) tcp connect: econnrefused
iex(3)> Mariaex.query(p, "select 1")                                                                       
** (DBConnection.ConnectionError) connection not available because of disconnection
    (db_connection) lib/db_connection.ex:934: DBConnection.checkout/2
    (db_connection) lib/db_connection.ex:750: DBConnection.run/3
    (db_connection) lib/db_connection.ex:1141: DBConnection.run_meter/3
    (db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
    (mariaex) lib/mariaex.ex:419: Mariaex.prepare_execute/4
# I start the db now
iex(3)> Mariaex.query(p, "select 1")
{:ok,
 %Mariaex.Result{
   columns: ["1"],
   connection_id: #PID<0.180.0>,
   last_insert_id: nil,
   num_rows: 1,
   rows: [[1]]
 }}
iex(4)> # I stop it now  
nil
** (EXIT from #PID<0.178.0>) shell process exited with reason: an exception was raised:
    ** (FunctionClauseError) no function clause matching in Mariaex.Protocol.ping_handle/3
        (mariaex) lib/mariaex/protocol.ex:1139: Mariaex.Protocol.ping_handle({:packet, 30, 0, {:error_resp, 255, 1927, "#", "70100", "Connection was killed"}, <<255, 135, 7, 35, 55, 48, 49, 48, 48, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 119, 97, 115, 32, 107, 105, 108, 108, 101, 100>>}, :ping, %Mariaex.Protocol{binary_as: :field_type_var_string, buffer: "", cache: #Reference<0.2383522203.2188771331.72263>, catch_eof: false, connection_id: #PID<0.180.0>, cursors: %{}, deprecated_eof: true, json_library: Poison, lru_cache: {100, #Reference<0.2383522203.2188771331.72267>}, opts: [socket_options: [], sock_type: :tcp, cache_size: 100, timeout: 5000, port: 3306, hostname: "localhost", username: "beatpanic", database: "ecto_simple", password: "supersecret"], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.5433>}, ssl_conn_state: :not_used, state: :running, state_data: nil, timeout: 5000})
        (db_connection) lib/db_connection/connection.ex:373: DBConnection.Connection.handle_info/2
        (connection) lib/connection.ex:810: Connection.handle_async/3
        (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
        (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
        
Interactive Elixir (1.6.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(5)> 
21:17:06.515 [error] GenServer #PID<0.180.0> terminating
** (FunctionClauseError) no function clause matching in Mariaex.Protocol.ping_handle/3
    (mariaex) lib/mariaex/protocol.ex:1139: Mariaex.Protocol.ping_handle({:packet, 30, 0, {:error_resp, 255, 1927, "#", "70100", "Connection was killed"}, <<255, 135, 7, 35, 55, 48, 49, 48, 48, 67, 111, 110, 110, 101, 99, 116, 105, 111, 110, 32, 119, 97, 115, 32, 107, 105, 108, 108, 101, 100>>}, :ping, %Mariaex.Protocol{binary_as: :field_type_var_string, buffer: "", cache: #Reference<0.2383522203.2188771331.72263>, catch_eof: false, connection_id: #PID<0.180.0>, cursors: %{}, deprecated_eof: true, json_library: Poison, lru_cache: {100, #Reference<0.2383522203.2188771331.72267>}, opts: [socket_options: [], sock_type: :tcp, cache_size: 100, timeout: 5000, port: 3306, hostname: "localhost", username: "beatpanic", database: "ecto_simple", password: "supersecret"], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.5433>}, ssl_conn_state: :not_used, state: :running, state_data: nil, timeout: 5000})
    (db_connection) lib/db_connection/connection.ex:373: DBConnection.Connection.handle_info/2
    (connection) lib/connection.ex:810: Connection.handle_async/3
    (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: :timeout
State: {Mariaex.Protocol, %Mariaex.Protocol{binary_as: :field_type_var_string, buffer: "", cache: #Reference<0.2383522203.2188771331.72263>, catch_eof: false, connection_id: #PID<0.180.0>, cursors: %{}, deprecated_eof: true, json_library: Poison, lru_cache: {100, #Reference<0.2383522203.2188771331.72267>}, opts: [socket_options: [], sock_type: :tcp, cache_size: 100, timeout: 5000, port: 3306, hostname: "localhost", username: "beatpanic", database: "ecto_simple", password: "supersecret"], seqnum: 0, sock: {Mariaex.Connection.Tcp, #Port<0.5433>}, ssl_conn_state: :not_used, state: :running, state_data: nil, timeout: 5000}}
@kpanic
Copy link
Contributor Author

kpanic commented Aug 28, 2018

Closing the issue since the related PR was merged

@kpanic kpanic closed this as completed Aug 28, 2018
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

1 participant