Phoenix.Tracker desync after connecting to node
szlend opened this issue · 6 comments
When Phoenix.Tracker nodes connect for the first time, and boths nodes already hold presences, their state will not merge correctly.
Steps to reproduce
Pull https://github.com/szlend/tracker_test
Node 1
iex --sname n1 --cookie test -S mix
for n <- 1..51, do: Phoenix.Tracker.track(TrackerTest.Tracker, self(), "test", "#{inspect Node.self()}_#{n}", %{})
Node 2
iex --sname n2 --cookie test -S mix
for n <- 1..51, do: Phoenix.Tracker.track(TrackerTest.Tracker, self(), "test", "#{inspect Node.self()}_#{n}", %{})
Node.connect :"n1@your_hostname"
Both nodes
Wait a while for Phoenix.Tracker to do it's thing, then:
Phoenix.Tracker.list(TrackerTest.Tracker, "test") |> Enum.count
# Node 1
> 51
# Node 2
> 102
I can only reproduce this issue when the number of tracked presences is above 50 on each node. Looking at the debug logs, I can see one difference:
When N > 50, I get:
sending delta generation 1
When N <= 50, I get:
falling back to sending entire crdt
Thanks for the report! I will try to reproduce this and see what's going on. I have some higher item priorities to take care of first so it may take some time for me to get to this one.
@chrismccord This is still an issue onphoenixframework/phoenix_pubsub
branch cm-clouds
. Tested with the exact same steps as before.
@szlend thanks for following up! I just pushed an additional fixed for your issue. Can you retry and report back? Thanks!
@chrismccord Awesome, it's working now. Thanks!
I have pushed v1.0.2 with this fix. Thanks!