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

Avoid race condition with initialization #34

Merged
merged 1 commit into from
May 24, 2023
Merged

Avoid race condition with initialization #34

merged 1 commit into from
May 24, 2023

Conversation

IanDBird
Copy link
Collaborator

I found that we were exposed to a number of race conditions, caused by the following:

  • The consuming app initialises the manager
  • The manager internally kicks off an async task to load state from storage
  • If the consuming app immediately calls our public API, this can happen before we have loaded our initial state
  • The initial state will overwrite any modified state set by the consuming app.

This workaround ensures that all public interfaces are aware of the initialisation of the manager. If they occur before, they are suspended until we are ready.

Copy link
Collaborator

@mindwalkr-ttd mindwalkr-ttd left a comment

Choose a reason for hiding this comment

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

Suggestion: add a test to ensure the race condition is removed

@IanDBird IanDBird merged commit b8200c5 into main May 24, 2023
@IanDBird IanDBird deleted the ian/racey branch May 24, 2023 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants