bitwalker / swarm

Easy clustering, registration, and distribution of worker processes for Erlang/Elixir
MIT License
1.19k stars 102 forks source link

No function clause matching in Swarm.IntervalTreeClock.fill/2 #97

Closed chrisalmeida closed 6 years ago

chrisalmeida commented 6 years ago

Swarm: 3.0 Elixir: 1.6.3 OTP: 20.0

Hi @bitwalker, This tuple seems to change shape after a short period of time registering and unregistering processes in Swarm. I've read through the code related to Swarm.IntervalTreeClock.fill/2, but I'm still unsure of what is causing this to happen and how to fix. Any help would be greatly appreciated. Thanks


** (FunctionClauseError) no function clause matching in Swarm.IntervalTreeClock.fill/2
    (swarm) lib/swarm/tracker/crdt.ex:164: Swarm.IntervalTreeClock.fill({0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, {5230, {108, {73, {87, {90, {74, 2, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, {5230, {108, {73, {87, {90, {74, 2, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}})
    (swarm) lib/swarm/tracker/crdt.ex:53: Swarm.IntervalTreeClock.event/1
    (swarm) lib/swarm/tracker/tracker.ex:367: anonymous fn/4 in Swarm.Tracker.sync_registry/4
    (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
    (swarm) lib/swarm/tracker/tracker.ex:274: Swarm.Tracker.syncing/3
    (stdlib) gen_statem.erl:1240: :gen_statem.call_state_function/5
    (stdlib) gen_statem.erl:1012: :gen_statem.loop_event/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Callback mode: :state_functions
Last event: {:cast, {:sync_recv, #PID<35955.1250.0>, {{{{{{{{{{{{{{{{{{{{{{{{{{{{{0, 1}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, {5230, {108, {73, {87, {90, {74, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, [{:entry, "aug02_ba7a21e4-db74-44aa-ad61-cf0c18bf7c1c", #PID<35955.23603.4>, #Reference<35955.2189142045.2291138563.214700>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, 2350, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, 2350, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_cf827eca-607f-4d92-945a-d40bbe877453", #PID<35955.21426.4>, #Reference<35955.2189142045.2290876421.108040>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, 2244, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {3156, 2244, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_1d1e6761-579e-46f4-905b-7f8b0b19ef50", #PID<35955.6668.0>, #Reference<35955.2189142045.2266497029.228451>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, 2032, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, 2032, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_09eca2df-1c85-444f-9f1f-9a7aa07a22bf", #PID<35955.4558.0>, #Reference<35955.2189142045.2266497029.78510>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, 1186, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, 1186, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_259b0cdd-1d40-40c0-8d55-73841498d124", #PID<35955.2716.0>, #Reference<35955.2189142045.2266759170.238634>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, 452, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_e0009870-22a7-469e-ac01-e01b91f73e8d", #PID<35955.14350.6>, #Reference<35955.2189142045.2296381442.126236>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_27abd5db-9f44-4d27-9036-65d84617497a", #PID<35955.20622.2>, #Reference<35955.2189142045.2285895683.111285>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_e15182c5-37a9-4012-9b43-95be2db3426f", #PID<35955.3435.0>, #Reference<35955.2189142045.2267021314.32326>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_f0148d88-e0f7-475b-936d-e2d28a8530a5", #PID<35955.2697.0>, #Reference<35955.2189142045.2266759170.238525>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_42186689-a8b7-4055-8b51-5d5ee7139ae2", #PID<35955.21778.4>, #Reference<35955.2189142045.2291138563.30459>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_b13808a4-d4dd-4e95-9e95-2816260e9e60", #PID<35955.12943.6>, #Reference<35955.2189142045.2295595013.181503>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_e3611e89-4b28-485d-910f-88eab34412c5", #PID<35955.19210.2>, #Reference<35955.2189142045.2285895687.229747>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_ee61ebcc-832b-4806-9626-24082e9d8b20", #PID<35955.9583.6>, #Reference<35955.2189142045.2295595012.63737>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}}}, {:entry, "aug02_c8c0e0f9-9518-44eb-86af-4a59886aa6b2", #PID<35955.9174.5>, #Reference<35955.2189142045.2292973571.32513>, %{"aug02" => true}, {{0, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {0, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}}, {{{{{{{{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, {8, {0, {0, {0, {0, {0, {0, {0, {0, {0, {...}, ...}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}} (truncated)

Initial tracker state


{:tracking,
 %Swarm.Tracker.TrackerState{
   clock: {{{{{{{{{{{1, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 0}, 8},
   nodes: [:"api_node@x.x.x.x"],
   pending_sync_reqs: [],
   self: :"worker_node@x.x.x.x",
   strategy: #,
   sync_node: nil,
   sync_ref: nil
 }}

tschmittni commented 6 years ago

All these issues with interval tree clocks should be fixed in my pull request: https://github.com/bitwalker/swarm/pull/85

Could you try out my branch and let me know how it works for you? Maybe we can convince @bitwalker to get my change merged :)

arjan commented 6 years ago

Yes and maybe also the #94 branch, which merges #85 and fixes the test cases :-)

chrisalmeida commented 6 years ago

Tested out your #94 branch with #85 included fixes last night. Everything worked well! Thank you for the fixes and hopefully we can get them merged soon🤞

arjan commented 6 years ago

Thanks! I think Paul's quite busy, hopefully he finds some time soon.

bitwalker commented 6 years ago

I've merged #85 - waiting for a rebase on #94 - so I'll close this for now. Sorry for the hold up!