From dev-return-54700-archive-asf-public=cust-asf.ponee.io@jackrabbit.apache.org Tue Oct 13 15:51:55 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 4162618060E for ; Tue, 13 Oct 2020 17:51:55 +0200 (CEST) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id 64D831232FA for ; Tue, 13 Oct 2020 15:51:54 +0000 (UTC) Received: (qmail 58342 invoked by uid 500); 13 Oct 2020 15:51:54 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 58331 invoked by uid 99); 13 Oct 2020 15:51:54 -0000 Received: from Unknown (HELO mailrelay1-lw-us.apache.org) (10.10.3.159) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Oct 2020 15:51:53 +0000 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by mailrelay1-lw-us.apache.org (ASF Mail Server at mailrelay1-lw-us.apache.org) with ESMTPSA id BCD7E40BBF for ; Tue, 13 Oct 2020 15:51:53 +0000 (UTC) Received: by mail-oi1-f175.google.com with SMTP id j7so5400545oie.12 for ; Tue, 13 Oct 2020 08:51:53 -0700 (PDT) X-Gm-Message-State: AOAM533178RKEMFyGVc++UmqBZLOMNfZDy+S9nLQ2A63P0peXnU3eXtM q69pzDiEWQOiOm6DsKXzoJ5w0h7e8LKugkzWHP4= X-Google-Smtp-Source: ABdhPJzhOEZWxyoJBBWaBlVHBZ0duQCCCoCaRDgbWJf8GgUvqRWRam9MXz1pqnxbS73dGUwvp5TSzGR2VxjMkPzQdQI= X-Received: by 2002:aca:c387:: with SMTP id t129mr210776oif.97.1602604313260; Tue, 13 Oct 2020 08:51:53 -0700 (PDT) MIME-Version: 1.0 References: <46e9fc91.f9.1751e7a93bd.Coremail.fengiaw@163.com> In-Reply-To: <46e9fc91.f9.1751e7a93bd.Coremail.fengiaw@163.com> From: Matt Ryan Date: Tue, 13 Oct 2020 09:51:42 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Document deletion check To: dev@jackrabbit.apache.org Content-Type: multipart/alternative; boundary="000000000000ceb58505b18f6459" --000000000000ceb58505b18f6459 Content-Type: text/plain; charset="UTF-8" Hi Feng, You said: > I am working on JackRabbit Oak, and have questions about the node deletion. Do you mean you are working on an application that uses Jackrabbit Oak? Or do you mean that you are working on a code contribution to Jackrabbit Oak? Assuming you are working on an application that uses Jackrabbit Oak, the proper way to check whether a node is deleted is via the JCR API. Use the "exists" methods of the Session object, e.g.: session.nodeExists("/path/to/node"); See [0] for the specification. An example of this in the Oak unit tests is at [1]. Your application should not be checking the node storage backend (MySQL in your case) to determine if a node is deleted, nor really for any reason. The node storage backend is an implementation detail, as is the schema being used, and could change. [0] - https://docs.adobe.com/docs/en/spec/jcr/2.0/5_Reading.html#5.1.2%20Testing%20for%20Existence%20by%20Absolute%20Path [1] - https://github.com/apache/jackrabbit-oak/blob/23e0e73c86544a731d4dd4fdff5c36b852446956/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/RepositoryTest.java#L1360 - Matt Ryan On Mon, Oct 12, 2020 at 3:09 PM fengiaw wrote: > Hi Jackrabbit Dev Team, > > I am working on JackRabbit Oak, and have questions about the node deletion. > Our backend store is using mysql. > > From Jackrabbit documentation, I see this "The _deleted sub-document > contains the revision this node was created in. In the above example the > root node was created in revision r13f3875b5d1-0-1. If the node is later > deleted, the _deleted sub-document will get a new field with the revision > the node was deleted in." > And I can see this "_deleted" in mysql in the "data" field, > So I reply on the "_deleted" field, and tried to use the latest value of > it to determine whether it's gotten deleted. > For example, > _deleted={r173bcb4360b-0-34d=false, r173bcb2fb8f-0-34d=false, > r173bcaf6d2c-0-34e=false, r173bcae10fa-0-350=false, > r173bcac5862-0-34d=false, r173bcac5859-0-34d=false, > r173bc9bf9f0-0-342=false, r173bc9a42ce-0-343=false, > r173bc994dce-0-34d=false, r173bc962853-0-34d=false, > r173bc942ceb-0-34d=false, r173baa5a789-0-329=true, > r1739196c343-1-2e9=false}. > > The latest value is "r173bcb4360b-0-34d=false", base on this, I assume > it's not deleted. But actually, I have deleted this node via our UI, and it > disappears in explorer as well. > And there are some cases that we did not delete the anything, but the > "_deleted" field shows the last revison as "true", which means it's gotten > deleted. > Thsi quite confuses us. > So the question here is without mysql db connection (active jcr instance) > what is the best/correct way to determin a node indeed exists or gets > deleted from the mysql record? > > Thank for your support, > Feng > > > > > --000000000000ceb58505b18f6459 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Feng,

You said:

>=C2=A0I = am working on JackRabbit Oak, and have questions about the node deletion.
=
Do you mean you are working on an application that uses Jackrabbit Oa= k?=C2=A0 Or do you mean that you are working on a code contribution to Jack= rabbit Oak?

Assuming you are working on an application that uses Jac= krabbit Oak, the proper way to check whether a node is deleted is via the J= CR API.=C2=A0 Use the "exists" methods of the Session object, e.g= .:

=C2=A0 session.nodeExists("/path/to/node");

=
See = [0] for the specification.=C2=A0 An example of this in the Oak unit tests i= s at [1].


Your application should not be checking the node sto= rage backend (MySQL in your case) to determine if a node is deleted, nor re= ally for any reason.=C2=A0 The node storage backend is an implementation de= tail, as is the schema being used, and could change.


[0] -=C2= =A0https://docs.adobe.= com/docs/en/spec/jcr/2.0/5_Reading.html#5.1.2%20Testing%20for%20Existence%2= 0by%20Absolute%20Path


- Matt Ryan



On Mon, Oct 12, 2020= at 3:09 PM fengiaw <fengiaw@163.com<= /a>> wrote:
<= div style=3D"line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Ar= ial">
Hi Jackrabbit Dev Team,

I = am working on JackRabbit Oak, and have questions about the node deletion.
Our backend store is using mysql.

From Jackrabbit doc= umentation, I see this "The=C2=A0_deleted=C2=A0sub-do= cument contains the revision this node was created in. In the above example= the root node was created in revision=C2=A0. If the node is later de= leted, the=C2=A0_deleted=C2=A0sub-document will get a new field with the revision t= he node was deleted in."
And I c= an see this "_deleted" in mysql in the "data" field,=C2= =A0
So I=C2=A0 reply on the "_deleted&q= uot; field, and tried to use the latest value of it to determine whether it= 's gotten deleted.
For example,=C2=A0
_deleted=3D{r173bcb4360b-0-34d=3Dfalse, r173bc= b2fb8f-0-34d=3Dfalse, r173bcaf6d2c-0-34e=3Dfalse, r173bcae10fa-0-350=3Dfals= e, r173bcac5862-0-34d=3Dfalse, r173bcac5859-0-34d=3Dfalse, r173bc9bf9f0-0-3= 42=3Dfalse, r173bc9a42ce-0-343=3Dfalse, r173bc994dce-0-34d=3Dfalse, r173bc9= 62853-0-34d=3Dfalse, r173bc942ceb-0-34d=3Dfalse, r173baa5a789-0-329=3Dtrue,= r1739196c343-1-2e9=3Dfalse}.

The latest value is "r173bcb4360b-0-34d=3Dfalse&= quot;, base on this, I assume it's not deleted. But actually, I have de= leted this node via our UI, and it disappears in explorer as well.
And there are some cases that we did not delete the = anything, but the "_deleted" field shows the last revison as &quo= t;true", which means it's gotten deleted.=C2=A0
Thsi quite confuses us.
So the = question here is without mysql db connection (active jcr instance) what is = the best/correct way to determin a node indeed exists or gets deleted from = the mysql record?

Thank for your support,
Feng
=



=C2=A0

--000000000000ceb58505b18f6459--