Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-4195

Sync on a Preference doesn't do a OS side sync

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • prefs-1.0.6
    • None
    • Preferences Service
    • None
    • Angstroem Embedded Linux
      UBIFS on a flash drive

    Description

      I ran in to the following problem using the Preferences Service on an embedded device with a flash memory:
      When a preference is changed the sync method is called to persist it. A sudden power loss occurs. On restart the preference file in the bundle cache is empty and causes a BackingStoreException: Could not load preference.

      It seems to me as that the OS is caching the write to the flash drive and the change is not actually persisted. I was able to fix this issue by performing a sync on the FileDescriptor of the OutputStream in the store method of the DataFileBackingStoreImpl

      try {
      final FileOutputStream os = (FileOutputStream) this.getOutputStream(root.getDescription());
      this.write(root, os);
      os.getFD().sync();
      os.close();
      }
      catch (IOException ioe) {
      throw new BackingStoreException("Unable to store preferences.", ioe);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mwiselka Matt Wiselka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: