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

The mounts discoverer cache usage is racey #731

Open
cpuguy83 opened this issue Oct 9, 2024 · 1 comment · May be fixed by #737
Open

The mounts discoverer cache usage is racey #731

cpuguy83 opened this issue Oct 9, 2024 · 1 comment · May be fixed by #737
Assignees

Comments

@cpuguy83
Copy link

cpuguy83 commented Oct 9, 2024

The mount cache is read here without locking:

func (d *mounts) Mounts() ([]Mount, error) {
if d.lookup == nil {
return nil, fmt.Errorf("no lookup defined")
}
if d.cache != nil {
d.logger.Debugf("returning cached mounts")
return d.cache, nil
}

But it is set here while locked:

Best case here is you end up with 2 (or technically possibly more) things running the mounts code needlessly.
Worse cases could be undefined behavior due to the go memory model.

@elezar elezar self-assigned this Oct 11, 2024
@elezar elezar linked a pull request Oct 11, 2024 that will close this issue
@elezar
Copy link
Member

elezar commented Oct 11, 2024

Thanks @cpuguy83. I recently added a WithCache decorator and I think we could use that here instead of managing the locks locally.

I have created #737 to make this change. Please take a look there.

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 a pull request may close this issue.

2 participants