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: another config deadlock by trying to acquire a read lock twice #120

Merged
merged 3 commits into from
Sep 15, 2023

Conversation

atzoum
Copy link
Collaborator

@atzoum atzoum commented Sep 15, 2023

Description

config#registerXxxVar was acquiring a read lock on vLock and after that, another read lock was being acquired on the same lock by config#GetXxx before the previous read lock was released, causing a deadlock.

  • Simplifying locking by only acquiring locks when necessary (limited scope) and once
  • Adding a test to protect against a future regression
  • Avoiding to register a reloadable pointer more than once

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov
Copy link

codecov bot commented Sep 15, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.05% ⚠️

Comparison is base (ac71452) 79.28% compared to head (72266ee) 79.24%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   79.28%   79.24%   -0.05%     
==========================================
  Files          68       68              
  Lines        5089     5079      -10     
==========================================
- Hits         4035     4025      -10     
  Misses        853      853              
  Partials      201      201              
Files Changed Coverage Δ
config/config.go 82.79% <100.00%> (ø)
config/hotreloadable.go 87.36% <100.00%> (-0.27%) ⬇️
config/load.go 92.17% <100.00%> (-0.09%) ⬇️

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

Copy link
Collaborator

@fracasula fracasula left a comment

Choose a reason for hiding this comment

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

Nice one Aris! We've been improving this lib quite a bit 💪

@atzoum atzoum merged commit 95ddd6f into main Sep 15, 2023
14 checks passed
@atzoum atzoum deleted the fix.deadLock2 branch September 15, 2023 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants