bitwalker / bitwalker/swarm

join / publish race condition

Open
#24 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
1.3k
Forks
110
PR merge metrics
No merged PRs in 30d

Description

When a process joins a group and then immediately publishes in that group, the newly joined process doesn't receive the message. For example:

```` elixir
Swarm.join(:test, self())
Swarm.publish(:test, :ping)
# Doesn't receive :ping message
````

However, when adding a sleep:
```` elixir
Swarm.join(:test, self())
:timer.sleep(500)
Swarm.publish(:test, :ping)
# Does receive :ping message
````

Even though add_meta [uses call](https://github.com/bitwalker/swarm/blob/79eb589490bd47e092aa45e991c9c397aeff9b9a/lib/swarm/tracker/tracker.ex#L72) it doesn't seem to get registered immediately. The behavior would probably also depend on the host machine being used.

I'm not sure if this is a bug or intended, but I didn't see any mention of this in the readme. Other people might bump into the same issue so I decided to report it. Could you please confirm if this is a bug or not? Thanks

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the join and publish paths, especially add_meta in lib/swarm/tracker/tracker.ex around line 72, and reproduce the issue using the Elixir examples in the report. Trace when registration becomes visible to publishing, then determine whether the behavior should be fixed or documented in the README. Done means the race is resolved or its intended semantics are clearly documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.