whatyouhide/xandra

No case clause matching `:error` in `Xandra.Cluster.with_conn`

harunzengin opened this issue · 3 comments

I haven't really understood how, but we're getting the following error in our tests:

     ** (exit) exited in: :sys.get_state(#PID<0.872.0>)
         ** (EXIT) an exception was raised:
             ** (CaseClauseError) no case clause matching: :error
                 (xandra 0.18.1) lib/xandra/cluster.ex:544: Xandra.Cluster.with_conn/2

I tried to debug and put an :error in the case clause, which actually matches and I can see the message printed. It is unclear to me where that :error comes from.

  defp with_conn(cluster, fun) do
    case Pool.checkout(cluster) do
      {:ok, [{pool, _host} | _connected_hosts]} ->
        fun.(pool)

      {:error, :empty} ->
        action = "checkout from cluster #{inspect(cluster)}"
        {:error, ConnectionError.new(action, {:cluster, :not_connected})}

      :error ->
        IO.inspect("HEREEE")
    end
  end

Mh, that's interesting. I took a deeper look at Xandra.Cluster.Pool and I cannot see how Pool.checkout/1 would return an error. You're using :sys.get_state/1 and touching the internals, I think, so maybe it's an issue with the tests somewhere? Do you have a way for me to reproduce this?

I wasn't able to reproduce this again, maybe I somehow messed up with my local _deps folder, it didn't make sense the first time either, closing.