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 1] Fix race between handle_replica_event and start_pid_remotely #1

Open
wants to merge 2 commits 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 attempts to remedy the problem by serializing the call to add_registration by start_pid_remotely within the Tracker GenStateMachine process. This will prevent the registration from executing concurrently with handle_replica_event

Copy link

@tristan-secord tristan-secord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/scorebet/sportsbook-api/pull/2261

Lets let it soak on staging for a bit and I'll throw it up on UAT.
If no issues come up we can toss it onto prod.

Also not sure how far along you've gotten with the stress testing stuff, could hand it off to someone on the infrastructure team if you need to focus on Marketing Push

@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.

3 participants