Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 364507

Summary: [prefs] Preferences lost on disk full
Product: [Eclipse Project] Equinox Reporter: John Arthorne <john.arthorne>
Component: CompendiumAssignee: John Arthorne <john.arthorne>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: dj.houghton, Mike_Wilson, tjwatson
Version: 3.7   
Target Milestone: Juno M4   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description John Arthorne CLA 2011-11-22 14:38:52 EST
Our metadata files are written via IEclipsePreference#flush. If the disk is full this results in a zero length file (file is opened for write, which truncates the file, and then flushing stream fails). We should change either orion server code or IEclipsePreferences to use something like SafeFileOutputStream to avoid data loss in this case.
Comment 1 Mike Wilson CLA 2011-11-22 15:03:07 EST
Ugh.

We need to do everything possible to be bulletproof in the face of problems like this. If there is metadata that is critical, it needs to be written transaction style.
Comment 2 John Arthorne CLA 2011-11-22 15:49:32 EST
Yes. We have deliberately avoided investing in the server infrastructure so far. I have always thought for the server to be *real* it needs to plugin into a serious content repository for handling data persistence rather than writing something from scratch. For example we looked at Jackrabbit early on, but it felt overkill for a demo server. 

All I'm thinking of doing here is something as good as the Eclipse platform, which writes to a temp file first, and then renames the file if the write was successful. This helps with disk full and disk access errors while writing, but isn't true transaction semantics.
Comment 3 John Arthorne CLA 2011-11-29 10:45:02 EST
I think it is best to fix this at the Equinox preference level.

Sample stack trace:

java.io.IOException: No space left on device
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:266)
        at java.io.BufferedOutputStream.write(BufferedOutputStream.java:117)
        at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:343)
        at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:404)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:147)
        at java.io.OutputStreamWriter.emptyBuffer(OutputStreamWriter.java:279)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:240)
        at java.io.Writer.write(Writer.java:152)
        at java.util.Properties.store(Properties.java:590)
        at org.eclipse.core.internal.preferences.EclipsePreferences.save(EclipsePreferences.java:1000)
        at org.eclipse.core.internal.preferences.EclipsePreferences.save(EclipsePreferences.java:968)
        at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:353)
        at org.eclipse.core.internal.preferences.EclipsePreferences.flush(EclipsePreferences.java:341)