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

Cache pointer updates are not thread safe #11

Open
kayrus opened this issue Aug 24, 2020 · 4 comments
Open

Cache pointer updates are not thread safe #11

kayrus opened this issue Aug 24, 2020 · 4 comments

Comments

@kayrus
Copy link

kayrus commented Aug 24, 2020

Multiple threads may cause simultaneous cache updates, e.g.

a.headers = &headers

a.headers = nil

a.caps = &caps

c.headers = &headers

c.headers = &headers

o.headers = hdr

o.headers = nil

o.symlinkHeaders = &newHeaders

o.headers = &newHeaders

o.headers = o.symlinkHeaders

@majewsky
Copy link
Owner

As a stop-gap measure, bd1c745 adds documentation that these methods are not thread-safe on the same object. I'm willing to take a PR that guards these fields with RwLocks.

@majewsky
Copy link
Owner

Besides, it would be helpful to know your usecase. I didn't really anticipate objects to be held for a long time (except for Account where your concern is entirely valid) or shared between goroutines. It may be enough to clone objects by obj2 := obj.Container().Object(obj.Name()) before sharing them with another goroutine.

@kayrus
Copy link
Author

kayrus commented Oct 14, 2020

@majewsky
Copy link
Owner

I had another look to be sure. When run with a multi-job config, s-h-i treats all jobs as wholly separate, so we're talking about different schwift.Container instances. While there could be a concern to change that code structure to allow for more data sharing between jobs, it's not a concern of Schwift and won't be solved by the issue described herein. This is a concern of s-h-i's code structure.

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

No branches or pull requests

2 participants