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: nil client causes panic #408

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

thisthat
Copy link
Member

@thisthat thisthat commented Dec 13, 2023

Signed-off-by: Giovanni Liva <this_that@hotmail.it>
@thisthat thisthat requested a review from a team as a code owner December 13, 2023 19:05
@thisthat thisthat changed the title fix: fix nil client fix(flagd): fix nil client Dec 13, 2023
@thisthat thisthat marked this pull request as draft December 13, 2023 19:21
Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
func (p *Provider) setStatus(status of.State) {
p.mtx.Lock()
defer p.mtx.Unlock()
p.status = status
Copy link
Member

Choose a reason for hiding this comment

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

I would assume this is atomic and therefore locking doesn't help? 🤔

Copy link
Member

@toddbaert toddbaert Dec 14, 2023

Choose a reason for hiding this comment

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

Oh, this might be needed actually, to prevent interleaving threads checking it during init.

I think I thread isn't blocked by a lock it already owns, right? So I guess you might want to lock in Init() and well as here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do need it, yes - if you execute the tests with the -race flag enabled, a data race error occurs, due to p.status being set in the goroutine created within the Init() function, while being accessed via the Status() function in the test

@bacherfl bacherfl marked this pull request as ready for review December 19, 2023 09:14
@toddbaert toddbaert changed the title fix(flagd): fix nil client fix: fix nil client Dec 20, 2023
@toddbaert toddbaert changed the title fix: fix nil client fix: nil client causes panic Dec 20, 2023
@toddbaert toddbaert merged commit 74df958 into open-feature:main Dec 20, 2023
7 checks passed
@toddbaert
Copy link
Member

Thanks @bacherfl and @thisthat !

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.

[bug] Panic in flagd provider
4 participants