From oak-issues-return-60976-archive-asf-public=cust-asf.ponee.io@jackrabbit.apache.org Thu Apr 5 12:45:06 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id A5D9118063B for ; Thu, 5 Apr 2018 12:45:05 +0200 (CEST) Received: (qmail 52352 invoked by uid 500); 5 Apr 2018 10:45:04 -0000 Mailing-List: contact oak-issues-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-issues@jackrabbit.apache.org Received: (qmail 52341 invoked by uid 99); 5 Apr 2018 10:45:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Apr 2018 10:45:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 97AFC180681 for ; Thu, 5 Apr 2018 10:45:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.511 X-Spam-Level: X-Spam-Status: No, score=-109.511 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Mp9Vy-WE40Yy for ; Thu, 5 Apr 2018 10:45:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id AEA5C5F33E for ; Thu, 5 Apr 2018 10:45:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B7202E0917 for ; Thu, 5 Apr 2018 10:45:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2F66225623 for ; Thu, 5 Apr 2018 10:45:00 +0000 (UTC) Date: Thu, 5 Apr 2018 10:45:00 +0000 (UTC) From: "Vikas Saurabh (JIRA)" To: oak-issues@jackrabbit.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (OAK-7389) Mongo/FileBlobStore does not update timestamp for already existing blobs MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/OAK-7389?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D164267= 32#comment-16426732 ]=20 Vikas Saurabh edited comment on OAK-7389 at 4/5/18 10:44 AM: ------------------------------------------------------------- {quote}could not get the upsert working with Mongo findOneAndUpdate so, res= orted to a separate call for update on error. {quote} [1] says that calling findOneAndUpdate only accepts update operators [2] - = I think {{$currentDate}} and {{$set}} should serve the purpose well. Also, = you'd probably need to pass \{"upsert": true} for {{options}} param. *EDIT*: btw, \[1] mentions that the method is new in 3.2 and updated (how??= ) in 3.6. I don't recall what we recommend for 1.2 users - but, I think it = won't be 3.2. Maybe, instead of having different impls in different branche= s, we could work with what you suggested (I won't expect resurrections of b= lobs just in time during blob gc... so, 2 remote calls might be ok).=C2=A0 [1]: [https://docs.mongodb.com/manual/reference/method/db.collection.findOn= eAndUpdate/] [2]: [https://docs.mongodb.com/manual/reference/operator/update/] was (Author: catholicon): bq. could not get the upsert working with Mongo findOneAndUpdate so, resort= ed to a separate call for update on error. \[1] says that calling findOneAndUpdate only accepts update operators \[2] = - I think {{$currentDate}} and {{$set}} should serve the purpose well. Also= , you'd probably need to pass \{"upsert": true} for {{options}} param. \[1]: https://docs.mongodb.com/manual/reference/method/db.collection.findOn= eAndUpdate/ \[2]: https://docs.mongodb.com/manual/reference/operator/update/ > Mongo/FileBlobStore does not update timestamp for already existing blobs > ------------------------------------------------------------------------ > > Key: OAK-7389 > URL: https://issues.apache.org/jira/browse/OAK-7389 > Project: Jackrabbit Oak > Issue Type: Bug > Components: blob > Affects Versions: 1.2.14, 1.4.20, 1.8.2, 1.6.11 > Reporter: Amit Jain > Assignee: Amit Jain > Priority: Critical > Fix For: 1.2.30 > > Attachments: OAK-7389-v1.patch > > > MongoBlobStore uses uses the {{insert}} call and ignores any exceptions w= hich means any existing value won't be updated. > {code:java} > @Override > protected void storeBlock(byte[] digest, int level, byte[] data) thro= ws IOException { > String id =3D StringUtils.convertBytesToHex(digest); > cache.put(id, data); > // Check if it already exists? > MongoBlob mongoBlob =3D 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() =3D=3D DUPLICATE_KEY_ERROR_CODE) { > // the same block was already stored before: ignore > } else { > throw new IOException(e.getMessage(), e); > } > } > } > {code} > =C2=A0FileBlobStore also returns if there's a file already existing witho= ut updating the timestamp > {code:java} > @Override > protected synchronized void storeBlock(byte[] digest, int level, byte= [] data) throws IOException { > File f =3D getFile(digest, false); > if (f.exists()) { > return; > } > ......... > {code} > 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 th= e timestamp would never have been modified. > =C2=A0 > cc/ [~tmueller], [~mreutegg], [~chetanm], [~catholicon] -- This message was sent by Atlassian JIRA (v7.6.3#76005)