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

Fix data race #2363

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Fix data race #2363

wants to merge 1 commit into from

Conversation

AnkushinDaniil
Copy link
Contributor

This pull request includes a small but important change to the Run method in the rpc/handlers.go file. The change ensures thread safety by locking and unlocking a mutex around the loop that waits for all subscriptions to complete.

Reason for the Change:

During testing, I encountered a panic that occurred intermittently—sometimes the tests would pass, and other times they would fail unpredictably. This behavior was caused by concurrent access to the map of active subscriptions during iteration, resulting in a race condition. Such issues are common in Go when shared resources are accessed by multiple goroutines without proper synchronization.

Solution:

To address this, I added a mutex lock around the loop that processes subscriptions.

@AnkushinDaniil AnkushinDaniil added Bug Something isn't working or security issue go Pull requests that update Go code labels Jan 8, 2025
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.59%. Comparing base (2653ae9) to head (7594251).

Files with missing lines Patch % Lines
rpc/handlers.go 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2363      +/-   ##
==========================================
+ Coverage   74.52%   74.59%   +0.06%     
==========================================
  Files         110      110              
  Lines       11908    11913       +5     
==========================================
+ Hits         8875     8887      +12     
+ Misses       2343     2338       -5     
+ Partials      690      688       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AnkushinDaniil AnkushinDaniil reopened this Jan 8, 2025
@AnkushinDaniil AnkushinDaniil marked this pull request as draft January 8, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working or security issue go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant