whatyouhide/xandra

PoolTest is flaky

Closed this issue · 0 comments

I get the occasional error when running locally, looks like a race condition:

[error] module=gen_server  GenServer #PID<0.1043.0> terminating
** (BadMapError) expected a map, got: nil
    (erts 13.2) :erlang.map_get(:status, nil)
    (elixir 1.14.4) lib/map.ex:319: Map.get_and_update!/3
    (elixir 1.14.4) lib/map.ex:924: Map.get_and_update/3
    (elixir 1.14.4) lib/map.ex:966: Map.get_and_update!/3
    (xandra 0.17.0) lib/xandra/cluster/pool.ex:382: Xandra.Cluster.Pool.handle_event/4
    (stdlib 4.3) gen_statem.erl:1428: :gen_statem.loop_state_callback/11
    (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
Last message: {:EXIT, #PID<0.1042.0>, {{:badmap, nil}, [{:erlang, :map_get, [:status, nil], [error_info: %{module: :erl_erts_errors}]}, {Map, :get_and_update!, 3, [file: 'lib/map.ex', line: 319]}, {Map, :get_and_update, 3, [file: 'lib/map.ex', line: 924]}, {Map, :get_and_update!, 3, [file: 'lib/map.ex', line: 966]}, {Xandra.Cluster.Pool, :handle_event, 4, [file: 'lib/xandra/cluster/pool.ex', line: 382]}, {:gen_statem, :loop_state_callback, 11, [file: 'gen_statem.erl', line: 1428]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}


  1) test handling change events multiple :discovered_hosts where hosts are removed (Xandra.Cluster.PoolTest)
     test/xandra/cluster/pool_test.exs:239
     ** (exit) exited in: :sys.get_state(#PID<0.1042.0>)
         ** (EXIT) an exception was raised:
             ** (BadMapError) expected a map, got: nil
                 (erts 13.2) :erlang.map_get(:status, nil)
                 (elixir 1.14.4) lib/map.ex:319: Map.get_and_update!/3
                 (elixir 1.14.4) lib/map.ex:924: Map.get_and_update/3
                 (elixir 1.14.4) lib/map.ex:966: Map.get_and_update!/3
                 (xandra 0.17.0) lib/xandra/cluster/pool.ex:382: Xandra.Cluster.Pool.handle_event/4
                 (stdlib 4.3) gen_statem.erl:1428: :gen_statem.loop_state_callback/11
                 (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
     code: assert get_state(pid).pool_supervisor
     stacktrace:
       (stdlib 4.3) sys.erl:338: :sys.send_system_msg/2
       (stdlib 4.3) sys.erl:139: :sys.get_state/1
       test/xandra/cluster/pool_test.exs:364: Xandra.Cluster.PoolTest.get_state/1
       test/xandra/cluster/pool_test.exs:279: (test)