Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-7389

Mongo/FileBlobStore does not update timestamp for already existing blobs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.2.14, 1.4.20, 1.8.2, 1.6.11
    • 1.9.0, 1.10.0, 1.2.30, 1.4.23, 1.6.14, 1.8.7
    • blob
    • None

    Description

      MongoBlobStore uses uses the insert call and ignores any exceptions which means any existing value won't be updated.

          @Override
          protected void storeBlock(byte[] digest, int level, byte[] data) throws IOException {
              String id = StringUtils.convertBytesToHex(digest);
              cache.put(id, data);
              // Check if it already exists?
              MongoBlob mongoBlob = new MongoBlob();
              mongoBlob.setId(id);
              mongoBlob.setData(data);
              mongoBlob.setLevel(level);
              mongoBlob.setLastMod(System.currentTimeMillis());
              // TODO check the return value
              // TODO verify insert is fast if the entry already exists
              try {
                  getBlobCollection().insertOne(mongoBlob);
              } catch (DuplicateKeyException e) {
                  // the same block was already stored before: ignore
              } catch (MongoException e) {
                  if (e.getCode() == DUPLICATE_KEY_ERROR_CODE) {
                      // the same block was already stored before: ignore
                  } else {
                      throw new IOException(e.getMessage(), e);
                  }
              }
          }
      

       FileBlobStore also returns if there's a file already existing without updating the timestamp

          @Override
          protected synchronized void storeBlock(byte[] digest, int level, byte[] data) throws IOException {
              File f = getFile(digest, false);
              if (f.exists()) {
                  return;
              }
              .........
      

      The above would cause data loss in DSGC if there are updates to the blob blocks which are re-surrected (stored again at the time of DSGC) because the timestamp would never have been modified.

       

      cc/ tmueller, mreutegg, chetanm, catholicon

      Attachments

        1. OAK-7389-v1.patch
          6 kB
          Amit Jain
        2. OAK-7389-v2.patch
          7 kB
          Vikas Saurabh
        3. OAK-7389-1.0.diff
          2 kB
          Julian Reschke
        4. OAK-7389-1.0.diff
          7 kB
          Julian Reschke
        5. OAK-7389-1.0.diff
          9 kB
          Julian Reschke
        6. OAK-7389-1.0.diff
          10 kB
          Julian Reschke

        Issue Links

          Activity

            People

              amitjain Amit Jain
              amitjain Amit Jain
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: