Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 210478 - [artifact] Simple artifact repo is not thread safe
Summary: [artifact] Simple artifact repo is not thread safe
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M6   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 248602
  Show dependency tree
 
Reported: 2007-11-20 21:57 EST by Pascal Rapicault CLA
Modified: 2009-02-11 17:54 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Rapicault CLA 2007-11-20 21:57:18 EST
The implementation of simple artifact repository is not thread safe which will likely cause us great pain as we start doing multi threaded download manager.
Note that I don't think we need to be fancy in the solution.
Comment 1 Stefan Liebig CLA 2007-11-29 03:44:16 EST
Added "non fancy" synchronization on methods accessing the fields of this class/super classes.
Comment 2 Stefan Liebig CLA 2007-11-29 03:58:28 EST
This "non fancy" synchronization does not prevent from getting multiple output streams for the same artifact descriptor.
Should the artifact repository care about that?
Comment 3 Pascal Rapicault CLA 2007-11-29 10:36:15 EST
I think that it depends on how/where the artifact repo stores the bytes until the stream is closed. 
For example if they are written in a temporary file then it does not really matter since the worst thing that could happen is having the file being downloaded multiple times simultaneously, and once one of the download has been successful then the descriptor is written and all subsequent completed download ends up doing nothing since the descriptor for the artifact is already there.
Comment 4 Pascal Rapicault CLA 2008-02-07 09:12:35 EST
Stefan are you confident that the solution in place is enough to not cause problems in the 1.0 timeframe?
Comment 5 Pascal Rapicault CLA 2008-09-08 21:44:55 EDT
Need to take a last pass over this as part of 3.5 and our effort on robustness.
Comment 6 Pascal Rapicault CLA 2008-12-12 22:06:34 EST
Reassigning to John to glance through the code
Comment 7 John Arthorne CLA 2009-02-11 17:54:00 EST
The synchronization added by Stefan looks good to me. The only holes are getOutputStream and getArtifact(descriptor, stream, monitor), in the case where two threads attempt to read/write the same file at once. Concurrent reads should be ok as long as the callers are passing in different output streams to write to. Concurrent writes will fail - on Windows the second thread will fail to open the file while the first thread is writing, and on Linux the second writer will win and overwrite the first write. I think this is ok. Since we have been doing concurrent downloads in several threads without any problems since before 1.0 I think we are in good shape.