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

access to dataset metadata not threadsafe #27

Closed
scottslewis opened this issue Dec 14, 2016 · 11 comments
Closed

access to dataset metadata not threadsafe #27

scottslewis opened this issue Dec 14, 2016 · 11 comments

Comments

@scottslewis
Copy link

The implementations of getMetadata(Class) addMetadata(T)/setMetadata and any of the *Metdata methods on the LazyDatasetBase class do not have any synchronization around the access to the 'metadata' field...wrt creating the Map or accessing elements (getting and setting). This means that the IDataset instances are not thread safe, and multithreaded access could result in non-deterministic NPEs or ConcurrentModification exceptions.

It would be helpful for some use cases to make LazyDatasetBase.*Metdata thread safe.

@PeterC-DLS
Copy link
Contributor

Thanks for the issue. Yes, it should be though we haven't required it so far. Do you have time to fix this?

@gerring
Copy link
Contributor

gerring commented Dec 14, 2016 via email

@jayjaybillings
Copy link
Member

jayjaybillings commented Dec 14, 2016 via email

@gerring
Copy link
Contributor

gerring commented Feb 2, 2017

Are Atomics things like ReetrantLock?

@jonahgraham
Copy link
Contributor

No, Atomics are their own thing, stuff in java.util.concurrent.atomic. Here is the article from Brian Geotz (author of Java Concurrency in Practice) from when the new feature was added in Java 5: http://www.ibm.com/developerworks/library/j-jtp11234/

@scottslewis
Copy link
Author

Hi Matt. Using synchronized keyword is essentially a Reentrant lock (in python threading lib terms). You can also use the concurrent API (especially java 8), but my suggestion would be to use synchronized keyword in necessary places. I would offer to provide a patch, but just can't at the moment.

@scottslewis
Copy link
Author

I hadn't noticed discussion above...wrt synchronized keyword. Although I agree that using synchronized in many locations is bad, I don't think that is necessary to have many uses of synchronized to satisfy...rather just protecting the add/removal/lookup to the metadata storage (preventing ConcurrentModificationExceptions) is what we are looking for.

@gerring
Copy link
Contributor

gerring commented Feb 3, 2017 via email

@jonahgraham
Copy link
Contributor

@PeterC-DLS PR #71 seems to have fixed this issue. Is there anything else left in this bug report that needs resolving?

@scottslewis
Copy link
Author

My answer to Jonah is no...the fix in 71 looks good to me. Thanks for the work.

@PeterC-DLS
Copy link
Contributor

Done with merged PR

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

5 participants