Function clause error in `Swarm.IntervalTreeClock.fill` on topology change
- Dominant language
- Elixir
- Stars
- 1.3k
- Forks
- 110
- PR merge metrics
- No merged PRs in 30d
Description
Howdy!
Our error tracker picked up the following error that happened when we deployed our application yesterday.
We're using Swarm (version 3.4.0) to manage a two node cluster on Kubernetes. When the first node was shut down as part of the rolling deploy, the following `ErlangError` was raised (I've formatted it a bit to make it easier to read):
```elixir
{{:function_clause,
[
{Swarm.IntervalTreeClock, :fill, [{1, 0}, {1, 81714}],
[file: 'lib/swarm/tracker/crdt.ex', line: 170]},
{Swarm.IntervalTreeClock, :event, 1, [file: 'lib/swarm/tracker/crdt.ex', line: 52]},
{Swarm.Tracker, :remove_registration, 2, [file: 'lib/swarm/tracker/tracker.ex', line: 1494]},
{Swarm.Tracker, :"-handle_topology_change/2-fun-0-", 3,
[file: 'lib/swarm/tracker/tracker.ex', line: 911]},
{:lists, :foldl, 3, [file: 'lists.erl', line: 1263]},
{:ets, :do_foldl, 4, [file: 'ets.erl', line: 638]},
{:ets, :foldl, 3, [file: 'ets.erl', line: 627]},
{Swarm.Tracker, :handle_topology_change, 2, [file: 'lib/swarm/tracker/tracker.ex', line: 840]}
]},
{:gen_statem, :call,
[
Swarm.Tracker,
{:track, #Reference<0.2697759696.1380188162.160667>,
%{
mfa:
{GenServer, :start_link,
[
PotionWeb.Devices.SendAfter,
{"device::id",
{PotionWeb.Devices.Worker, :device_offline, []}, 30000}
]}
}},
:infinity
]}}
```
It looks like a function clause error where `Swarm.IntervalTreeClock.fill({1, 0}, {1, 81714})` was called, but none of the function clauses match:
```elixir
defp fill(0, e), do: e
defp fill(1, {_, _, _} = e), do: height(e)
defp fill(_, n) when is_integer(n), do: n
defp fill({1, r}, {n, el, er}) do
er1 = fill(r, er)
d = max(height(el), base(er1))
norm_ev({n, d, er1})
end
defp fill({l, 1}, {n, el, er}) do
el1 = fill(l, el)
d = max(height(er), base(el1))
norm_ev({n, el1, d})
end
defp fill({l, r}, {n, el, er}) do
norm_ev({n, fill(l, el), fill(r, er)})
end
```
This is pretty deep in the CRDT weeds so I don't think I'm going to be able to help much in figuring out how that function got called with those arguments, but I'd be happy to help with any other information about the application that can help in fixing this.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.