Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Option 2] Fix race between handle_replica_event and start_pid_remotely #2

Open
wants to merge 1 commit into
base: optimizations
Choose a base branch
from

Conversation

d-b
Copy link

@d-b d-b commented Mar 29, 2021

There appears to be a race condition leading the Swarm.Tracker process to die. When this happens the monitors that were acquired by Swarm.Tracker are lost and the process :down events will fail to be captured.

The race occurs when handle_replica_event attempts to find the remote process in the local registry. If it is not found, but is then registered in the mean time by start_pid_remotely an error will occur when handle_replica_event tries to register the process itself

:undefined ->
ref = Process.monitor(pid)
lclock = Clock.join(clock, rclock)
Registry.new!(entry(name: name, pid: pid, ref: ref, meta: meta, clock: lclock))
:keep_state_and_data

This solution removes the call to add_registration from start_pid_remotely to remove the potential race condition. This reintroduces the issue bitwalker#45 fixed by bitwalker#46. Option 1 may be preferable.

@d-b d-b force-pushed the fix-register-race-option-2 branch from 7dc8656 to 558dc22 Compare March 29, 2021 23:15
@Corvillus
Copy link

As we decided on option 1 I'm removing myself from the reviewers on this PR. If this comes back, feel free to re-add me.

@Corvillus Corvillus removed their request for review April 26, 2021 14:49
@jeffli-thescore jeffli-thescore removed their request for review March 20, 2023 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants