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

Resolve deadlock caused by fetching snapshot during update #126

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

pkachelhoffer
Copy link
Collaborator

When a market snapshot is requested by the client from within the UpdateCallback delegate, a mutex deadlock is encountered. This is caused by the write mutex not being released when UpdateCallback is called by the stream and the snapshot function trying to read lock the same mutex.

Getting the snapshot during the UpdateCallback call is useful because this enables the client to consider the full orderbook when applying trading logic.

The resolution is to first release the write mutex before calling the UpdateCallback delegate.

streaming/streaming.go Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Mar 19, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@pkachelhoffer pkachelhoffer merged commit 4e516c7 into master Mar 19, 2024
2 checks passed
@pkachelhoffer pkachelhoffer deleted the snapshot-deadlock-fix branch March 19, 2024 13:19
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.

3 participants