You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by IvanLatysh <iv...@yourmail.com> on 2007/07/19 17:54:42 UTC

Isolation level inconsistency.

Hello All!

  I would like to bring up an issue with accessing JCR Nodes withing a Session.

[quote]
3.1.3.2 Transient Storage in the Session
Changes not yet saved or discarded are called pending changes. Pending changes 
are immediately visible through the session that made them but are not visible 
through other sessions accessing the same workspace.
[/quote]

According to the 3.1.3.2 "Pending changes are immediately visible through the 
session that made them..."

No let's see how QueryResult will behave ?

[quote]
  4.6.12 QueryResult
As mentioned, all queries are run against the persistent state of a workspace, 
pending changes stored in the Session are not searched. However, when an item is 
accessed from within a QueryResult object, the state of the item returned will 
obey the same semantics as if it were retrieved using a normal Node.getNode or 
Node.getProperty, in other words the item state will reflect any pending changes 
currently stored in the session. As a result, it is possible that a property 
returned as a match will not reflect the value that caused it to be a match 
(i.e., its persistent state). Applications can clear the Session (either through 
save or refresh(false)) before running a query in order to avoid such 
discrepancies.
[/quote]

First of all it does not obey 3.1.3.2, for some unknown reason "... all queries 
are run against the persistent state of a workspace ..."
It is very confusing and it is very hard to find the use case for it.

But to make things worse, results will not match the query itself ".. the item 
state will reflect any pending changes currently stored in the session ..".

Here I can say that Query behavior are useless and have no real life use-case 
that ever need such functionality.

=== Proposal ===========================================
  4.6.12 QueryResult
QueryResults reflect any pending changes currently stored in the session.
========================================================

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Alex K <se...@gmail.com>.
>
> 1) In my eyes the public review is there to give any feedback, to discuss
> everything and to make proposals, whether they are major changes or just
> little remarks.
>
> 2) I wouldn't agree that discussions about implementation details should
> be
> part of a public review of a specification. Sure we should keep an eye on
> the implementation, it has to be done at some point. But, we talk about
> JCR,
> not Jackrabbit. The JCR specification shouldn't take care about
> implementation details of one product (Jackrabbit), but it should find the
> best way to make the specification according to people's needs and
> requirements.



The difference of opinions apparently lies not in the interpretation of the
JCR spec, but in how well it will satisfy the needs of users. Those used to
the RDBMS paradigm of transaction isolation are expecting to be able to
query transient changes and get them included in the results. The JCR
approach, though well-specified it may be, is not useful enough. Having to
reset the session or save changes prior to searching is cumbersome in my
opinion. Even if it does complicate implementation it's a very useful
feature and a more 'natural' model of data access.
The solution could include a facility to set the desired isolation level for
a Session if a particular implementation used supports it.

Alex Karshakevich

Re: Isolation level inconsistency.

Posted by Stefan Guggisberg <st...@gmail.com>.
On 7/20/07, Hendrik Beck (camunda) <he...@camunda.com> wrote:
> Aren't you missing an important point in this discussion? Maybe someone who
> is deeper into the spec and the Jackrabbit architecture can correct me if I
> am wrong but I understand it like that:
>
> 1) Accessing nodes always takes the transient state of my own session into
> account. That means, if I make changes, don't save them yet and then access
> my own nodes again, I will see my own changes. But I never see any transient
> changes of another session. That's clear, I think.
>
> 2) Searching always accesses the persistent state only. That means, I can't
> search for any transient changes, whether they were made by my session or by
> another session. But, and that's the important point (I guess), if I get my
> search results and then try to ACCESS one of these nodes from my search
> results, then I will (according to point 1) see the transient state of these
> nodes. But again, only MY transient changes, not the transient changes of
> someone else. This is the case where search result and accessed nodes can be
> different. For example:
>
> 1) The persistent state of a contact node has the name "Joe"
> 2) I change the name to "John" but don't save it (it's still transient for
> me or my session respectively)
> 3) If I access that node, I will see the (transient) name "John"
> 4) When I search for "Joe", I will still find that node, because searching
> only takes the persistent state into account
> 5) But when I now access this node (that I just found under the name "Joe"),
> then I will see the name "John"
>
>
> Of course, there might be discrepancies in such a case, but 1) it seems to
> be pretty clear to me how it works and 2) the spec says the following about
> that to avoid it if necessary:
>
> "Applications can clear the Session (either through save or refresh(false))
> before running a query in order to avoid such discrepancies."
>
>
> Does that make sense for you?

perfectly, that's an excellent and concise explanation.

cheers
stefan

>
>
> Especially I think that this has nothing to do with accessing transient
> changes from other sessions. It's always about the transient changes of my
> own session.
>
>
> > -----Original Message-----
> > From: Mark Waschkowski [mailto:mwaschkowski@gmail.com]
> > Sent: Friday, July 20, 2007 5:10 AM
> > To: users@jackrabbit.apache.org
> > Subject: Re: Isolation level inconsistency.
> >
> > Actually, the more I think about it the worse it gets. I would like to
> > know
> > to whom the following makes sense:
> >
> > 1) Get session and load a contact with name 'Joe'
> > 2) Update the name property from 'Joe' to 'John'
> > 3) Now, query the repo for the contact using the name 'Joe'
> > 4) The node that you get back from the query will have the name property
> > as
> > 'John' even though the persisted state is 'Joe' and the query was based on
> > the name 'Joe'!
> >
> > Or, worse yet:
> > 1) Get session and load a contact with name 'Joe'
> > 2) Update the name property from 'Joe' to 'John'
> > 3) Add a new contact
> > 4) Query to get all the contacts and iterate through them
> > 5) See nodes that have an updated state, but don't see any of the newly
> > added nodes! Now you have a strange mix all the previously persisted
> > nodes,
> > nodes that have been updated in the session, but without any of the newly
> > added nodes!
> >
> > Maybe I'm totally missing the point, but I can't fathom *why* the spec
> > would
> > be written this way and really think it should just be one way or the
> > other.
> >
> >   ie. Either (ideally) respect the current session state and include ALL
> > session changes in the query results, or, if that is somehow
> > unacceptable/complicated/expensive operation etc., show me the persistent
> > state - just not some funky combination!
> >
> > "again you're proposing a major change to JCR. If a query would need to
> > take
> > transient changes into account, it needs
> > to operate both on the persisted state, and on the local transient space.
> > "
> > Some part of the local transient space is *already* being taken into
> > account
> > (ie. updates of nodes) so maybe handling additions/deletions would be a
> > major change or maybe not. Regardless, IMHO, I think the spec will make
> > more
> > sense if one way or the other (see above) is decided on, and now, during
> > the
> > public review phase would seem to me like the best time to take these
> > inconsistencies.
> >
> > Best,
> >
> > Mark
> >
> >
> > On 7/19/07, Mark Waschkowski <mwaschkowski@gmail.com > wrote:
> > >
> > > Hi Julian,
> > >
> > > I've actually brought this issue up with the version 1.0 of the spec and
> > > found it confusing. Using
> > >
> > >   session.getRootNode().getNode(path)
> > >
> > > 'sees' any transient changes already, so there is already support for
> > the
> > > transient changes within JCR and the session, albeit not using queries.
> > > Furthermore, SQL databases all see transient changes within the same
> > > transaction, so there is certainly precedent (and examples) for this
> > type of
> > > behavior...
> > >
> > > Best,
> > >
> > > Mark
> > >
> > > On 7/19/07, Julian Reschke < julian.reschke@gmx.de> wrote:
> > > >
> > > > IvanLatysh wrote:
> > > > > Julian Reschke wrote:
> > > > >
> > > > >> again you're proposing a major change to JCR.
> > > > > Sorry for my ignorance, but it is funny, you just dropped XPath and
> > > > you
> > > > > saying that fixing of an obvious mistake is a major change ?
> > > >
> > > > (1) I didn't drop, the EG basically proposes to drop it. It's under
> > > > public review, right? That being said, I'm in favor of keeping XPath
> > as
> > > > mandatory.
> > > >
> > > > (2) I strongly disagree that the current property data model is a
> > > > mistake; actually, I think it's the right design.
> > > >
> > > > >> If a query would need to take transient changes into account, it
> > > > needs
> > > > >> to operate both on the persisted state, and on the local transient
> > > > >> space. Note that these may be on different machines. Maybe it's
> > just
> > > > >> me, but I have no idea how that could be implemented efficiently,
> > *in
> > > > >> particular* if you don't have the luxury to develop that
> > > > functionality
> > > > >> from scratch.
> > > > > I am sorry, but an implementation of that is a trivial task,
> > everybody
> > > > > does it.
> > > > > Have a look at any persistence engines.
> > > >
> > > > Well, you seem to be very sure, so I guess I won't argue with you and
> > go
> > > >
> > > > back to my JCR 1.0 L2 implementation, which does not and will not work
> > > > that way.
> > > >
> > > > Best regards, Julian
> > > >
> > >
> > >
> > >
> > > --
> > > Best,
> > >
> > > Mark Waschkowski
>
>

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Hendrik Beck (camunda) <he...@camunda.com> wrote:
> > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> >
> > Hendrik I am afraid you are confusing the visibility over different
> > sessions (you are discussing about this one), and the transient state
> > inside the same session (which is the topic discussed in here).
>
> Arrgh, you could be right, Alexandru ;-) But I think it's more about the way we use it. The way we use and share Sessions on the one hand but also the use cases we have. For example, we don't really have long running transaction with JCR, as Ivan just mentioned about...
>

The fact that my app or yours are not using long-lived
sessions/transactions is not really relevant when discussing a spec
:-).
A spec should be clear about the usage scenarios and this is what I am
trying to accomplish this (even if it is in the form of: if you using
long-lived sessions then you need to do this and that....).
And this is extremely important if we think about the adoption and
future of the spec. We don't want to get yet another spec that is
missing important aspects or a spec that will need to be changed very
soon because it was not looking at enough scenarios (we have plenty of
such wrong examples and personally I would hate that the JCR one will
join those).

bests,
./alex
--
.w( the_mindstorm )p.

>
> > -----Original Message-----
> > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > Sent: Friday, July 20, 2007 10:47 PM
> > To: users@jackrabbit.apache.org
> > Subject: Re: Isolation level inconsistency.
> >
> > On 7/20/07, Hendrik Beck (camunda) <he...@camunda.com> wrote:
> > > > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > > > I would really appreciate if somebody would post on this thread a
> > > > scenario in which the current behavior is proving helpful (and I have
> > > > in mind the scenario posted here: searching for a John and getting a
> > > > Joe instead -- frankly speaking I would be totally surprised in real
> > > > life if I would be looking for my wife and getting somebody else
> > > > instead :-) ).
> > >
> > > Uhm, which behaviour do you want to see? In one of our projects we use
> > JCR to enrich our business objects (like Products for a web shop) with
> > content data. This content is shown on the web site. The employees edit
> > this content concurrently with an application, every one on its one. They
> > make changes to different products and when they are finished, they
> > persist these changes by invoking save(). As long as they didn't do that,
> > the people who search and browse the web site only see the persistant
> > state, i.e. the data that is really stored "forever". It would be crucial
> > if people would see all the transient states on the websites and
> > furthermore it would be wrong. Invoking save is something like saying "ok,
> > now I am finished, now I want everybody else to see my changes".
> > >
> > > On the other hand as long as they haven't pressed save(), they still
> > want to see their own changes, that's also obvious. But they should only
> > see their own changes.
> > >
> > > So for me the only thing that could be a problem is, that an employee
> > didn't press save() and wants to search the repository. In that case they
> > could get results that differ from their local changes. But I would say,
> > if there are any good technical (Jackrabbit-) reasons, that's ok. Then
> > they just have to save their changes and then everything's right again.
> > But in our use cases that doesn't really happen. People rather use the
> > search to find the nodes they want to change. Then they select these
> > nodes, change them, press save() and that's it.
> > >
> > > Actually I thought that's one of the most common use cases JCR is used
> > for but apparanty not?!
> > >
> >
> > Hendrik I am afraid you are confusing the visibility over different
> > sessions (you are discussing about this one), and the transient state
> > inside the same session (which is the topic discussed in here).
> >
> > bests,
> > ./alex
> > --
> > .w( the_mindstorm )p.
> >
> > >
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > > > Sent: Friday, July 20, 2007 3:18 PM
> > > > To: users@jackrabbit.apache.org
> > > > Subject: Re: Isolation level inconsistency.
> > > >
> > > > On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> > > > > Hendrik Beck (camunda) wrote:
> > > > > > One more thing I want to say:
> > > > > >
> > > > > > "again you're proposing a major change to JCR."
> > > > > >
> > > > > > "Maybe it's just me, but I have no idea how that could be
> > implemented
> > > > > > efficiently, *in
> > > > > > particular* if you don't have the luxury to develop that
> > functionality
> > > > from
> > > > > > scratch."
> > > > > >
> > > > > >
> > > > > > 1) In my eyes the public review is there to give any feedback, to
> > > > discuss
> > > > > > everything and to make proposals, whether they are major changes
> > or
> > > > just
> > > > > > little remarks.
> > > > >
> > > > > That's right. The point I was trying to make (and apparently failed)
> > was
> > > > > that this is a major change to *JCR 1.0*.
> > > > >
> > > > > > 2) I wouldn't agree that discussions about implementation details
> > > > should be
> > > > > > part of a public review of a specification. Sure we should keep an
> > eye
> > > > on
> > > > > > the implementation, it has to be done at some point. But, we talk
> > > > about JCR,
> > > > > > not Jackrabbit. The JCR specification shouldn't take care about
> > > > > > implementation details of one product (Jackrabbit), but it should
> > find
> > > > the
> > > > > > best way to make the specification according to people's needs and
> > > > > > requirements.
> > > > >
> > > > > Actually, I wasn't talking about Jackrabbit either.
> > > > >
> > > > > If JCR 2.0 adds requirements that are unlikely to be implemented,
> > that's
> > > > > IMHO a problem. Either you'll end up with no implementations, or
> > with
> > > > > broken implementations (with respect to that feature).
> > > > >
> > > > > Best regards, Julian
> > > > >
> > > > >
> > > >
> > > > I agree with both you comments here. However, I do feel that the OP
> > > > may be right (I confess that I was not facing this situation so far,
> > > > but this is probably because my app is a bit different).
> > > >
> > > > I would really appreciate if somebody would post on this thread a
> > > > scenario in which the current behavior is proving helpful (and I have
> > > > in mind the scenario posted here: searching for a John and getting a
> > > > Joe instead -- frankly speaking I would be totally surprised in real
> > > > life if I would be looking for my wife and getting somebody else
> > > > instead :-) ).
> > > >
> > > > bests,
> > > >
> > > > ./alex
> > > > --
> > > > .w( the_mindstorm )p.
> > >
> > >
>
>

RE: Isolation level inconsistency.

Posted by "Hendrik Beck (camunda)" <he...@camunda.com>.
> From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
>
> Hendrik I am afraid you are confusing the visibility over different
> sessions (you are discussing about this one), and the transient state
> inside the same session (which is the topic discussed in here).

Arrgh, you could be right, Alexandru ;-) But I think it's more about the way we use it. The way we use and share Sessions on the one hand but also the use cases we have. For example, we don't really have long running transaction with JCR, as Ivan just mentioned about...


> -----Original Message-----
> From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> Sent: Friday, July 20, 2007 10:47 PM
> To: users@jackrabbit.apache.org
> Subject: Re: Isolation level inconsistency.
> 
> On 7/20/07, Hendrik Beck (camunda) <he...@camunda.com> wrote:
> > > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > > I would really appreciate if somebody would post on this thread a
> > > scenario in which the current behavior is proving helpful (and I have
> > > in mind the scenario posted here: searching for a John and getting a
> > > Joe instead -- frankly speaking I would be totally surprised in real
> > > life if I would be looking for my wife and getting somebody else
> > > instead :-) ).
> >
> > Uhm, which behaviour do you want to see? In one of our projects we use
> JCR to enrich our business objects (like Products for a web shop) with
> content data. This content is shown on the web site. The employees edit
> this content concurrently with an application, every one on its one. They
> make changes to different products and when they are finished, they
> persist these changes by invoking save(). As long as they didn't do that,
> the people who search and browse the web site only see the persistant
> state, i.e. the data that is really stored "forever". It would be crucial
> if people would see all the transient states on the websites and
> furthermore it would be wrong. Invoking save is something like saying "ok,
> now I am finished, now I want everybody else to see my changes".
> >
> > On the other hand as long as they haven't pressed save(), they still
> want to see their own changes, that's also obvious. But they should only
> see their own changes.
> >
> > So for me the only thing that could be a problem is, that an employee
> didn't press save() and wants to search the repository. In that case they
> could get results that differ from their local changes. But I would say,
> if there are any good technical (Jackrabbit-) reasons, that's ok. Then
> they just have to save their changes and then everything's right again.
> But in our use cases that doesn't really happen. People rather use the
> search to find the nodes they want to change. Then they select these
> nodes, change them, press save() and that's it.
> >
> > Actually I thought that's one of the most common use cases JCR is used
> for but apparanty not?!
> >
> 
> Hendrik I am afraid you are confusing the visibility over different
> sessions (you are discussing about this one), and the transient state
> inside the same session (which is the topic discussed in here).
> 
> bests,
> ./alex
> --
> .w( the_mindstorm )p.
> 
> >
> >
> >
> >
> > > -----Original Message-----
> > > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > > Sent: Friday, July 20, 2007 3:18 PM
> > > To: users@jackrabbit.apache.org
> > > Subject: Re: Isolation level inconsistency.
> > >
> > > On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> > > > Hendrik Beck (camunda) wrote:
> > > > > One more thing I want to say:
> > > > >
> > > > > "again you're proposing a major change to JCR."
> > > > >
> > > > > "Maybe it's just me, but I have no idea how that could be
> implemented
> > > > > efficiently, *in
> > > > > particular* if you don't have the luxury to develop that
> functionality
> > > from
> > > > > scratch."
> > > > >
> > > > >
> > > > > 1) In my eyes the public review is there to give any feedback, to
> > > discuss
> > > > > everything and to make proposals, whether they are major changes
> or
> > > just
> > > > > little remarks.
> > > >
> > > > That's right. The point I was trying to make (and apparently failed)
> was
> > > > that this is a major change to *JCR 1.0*.
> > > >
> > > > > 2) I wouldn't agree that discussions about implementation details
> > > should be
> > > > > part of a public review of a specification. Sure we should keep an
> eye
> > > on
> > > > > the implementation, it has to be done at some point. But, we talk
> > > about JCR,
> > > > > not Jackrabbit. The JCR specification shouldn't take care about
> > > > > implementation details of one product (Jackrabbit), but it should
> find
> > > the
> > > > > best way to make the specification according to people's needs and
> > > > > requirements.
> > > >
> > > > Actually, I wasn't talking about Jackrabbit either.
> > > >
> > > > If JCR 2.0 adds requirements that are unlikely to be implemented,
> that's
> > > > IMHO a problem. Either you'll end up with no implementations, or
> with
> > > > broken implementations (with respect to that feature).
> > > >
> > > > Best regards, Julian
> > > >
> > > >
> > >
> > > I agree with both you comments here. However, I do feel that the OP
> > > may be right (I confess that I was not facing this situation so far,
> > > but this is probably because my app is a bit different).
> > >
> > > I would really appreciate if somebody would post on this thread a
> > > scenario in which the current behavior is proving helpful (and I have
> > > in mind the scenario posted here: searching for a John and getting a
> > > Joe instead -- frankly speaking I would be totally surprised in real
> > > life if I would be looking for my wife and getting somebody else
> > > instead :-) ).
> > >
> > > bests,
> > >
> > > ./alex
> > > --
> > > .w( the_mindstorm )p.
> >
> >


Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Hendrik Beck (camunda) <he...@camunda.com> wrote:
> > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > I would really appreciate if somebody would post on this thread a
> > scenario in which the current behavior is proving helpful (and I have
> > in mind the scenario posted here: searching for a John and getting a
> > Joe instead -- frankly speaking I would be totally surprised in real
> > life if I would be looking for my wife and getting somebody else
> > instead :-) ).
>
> Uhm, which behaviour do you want to see? In one of our projects we use JCR to enrich our business objects (like Products for a web shop) with content data. This content is shown on the web site. The employees edit this content concurrently with an application, every one on its one. They make changes to different products and when they are finished, they persist these changes by invoking save(). As long as they didn't do that, the people who search and browse the web site only see the persistant state, i.e. the data that is really stored "forever". It would be crucial if people would see all the transient states on the websites and furthermore it would be wrong. Invoking save is something like saying "ok, now I am finished, now I want everybody else to see my changes".
>
> On the other hand as long as they haven't pressed save(), they still want to see their own changes, that's also obvious. But they should only see their own changes.
>
> So for me the only thing that could be a problem is, that an employee didn't press save() and wants to search the repository. In that case they could get results that differ from their local changes. But I would say, if there are any good technical (Jackrabbit-) reasons, that's ok. Then they just have to save their changes and then everything's right again. But in our use cases that doesn't really happen. People rather use the search to find the nodes they want to change. Then they select these nodes, change them, press save() and that's it.
>
> Actually I thought that's one of the most common use cases JCR is used for but apparanty not?!
>

Hendrik I am afraid you are confusing the visibility over different
sessions (you are discussing about this one), and the transient state
inside the same session (which is the topic discussed in here).

bests,
./alex
--
.w( the_mindstorm )p.

>
>
>
>
> > -----Original Message-----
> > From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> > Sent: Friday, July 20, 2007 3:18 PM
> > To: users@jackrabbit.apache.org
> > Subject: Re: Isolation level inconsistency.
> >
> > On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> > > Hendrik Beck (camunda) wrote:
> > > > One more thing I want to say:
> > > >
> > > > "again you're proposing a major change to JCR."
> > > >
> > > > "Maybe it's just me, but I have no idea how that could be implemented
> > > > efficiently, *in
> > > > particular* if you don't have the luxury to develop that functionality
> > from
> > > > scratch."
> > > >
> > > >
> > > > 1) In my eyes the public review is there to give any feedback, to
> > discuss
> > > > everything and to make proposals, whether they are major changes or
> > just
> > > > little remarks.
> > >
> > > That's right. The point I was trying to make (and apparently failed) was
> > > that this is a major change to *JCR 1.0*.
> > >
> > > > 2) I wouldn't agree that discussions about implementation details
> > should be
> > > > part of a public review of a specification. Sure we should keep an eye
> > on
> > > > the implementation, it has to be done at some point. But, we talk
> > about JCR,
> > > > not Jackrabbit. The JCR specification shouldn't take care about
> > > > implementation details of one product (Jackrabbit), but it should find
> > the
> > > > best way to make the specification according to people's needs and
> > > > requirements.
> > >
> > > Actually, I wasn't talking about Jackrabbit either.
> > >
> > > If JCR 2.0 adds requirements that are unlikely to be implemented, that's
> > > IMHO a problem. Either you'll end up with no implementations, or with
> > > broken implementations (with respect to that feature).
> > >
> > > Best regards, Julian
> > >
> > >
> >
> > I agree with both you comments here. However, I do feel that the OP
> > may be right (I confess that I was not facing this situation so far,
> > but this is probably because my app is a bit different).
> >
> > I would really appreciate if somebody would post on this thread a
> > scenario in which the current behavior is proving helpful (and I have
> > in mind the scenario posted here: searching for a John and getting a
> > Joe instead -- frankly speaking I would be totally surprised in real
> > life if I would be looking for my wife and getting somebody else
> > instead :-) ).
> >
> > bests,
> >
> > ./alex
> > --
> > .w( the_mindstorm )p.
>
>

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Thomas Mueller <th...@gmail.com> wrote:
> Hi,
>
> > the scenario posted here: searching for a John and getting a
> > Joe instead
>
> Ok, so the use case is:
>
> 1) Get session and load a contact with name 'Joe'
> 2) Update the name property from 'Joe' to 'John'
> 3) Now, query the repo for the contact using the name 'Joe'
>
> I would do this:
>
> 1) Node contact = ...getNode(...) // we have the node
> 2) contact.setProperty("name", "John")
>     contact.save()
> 3) ... query ...
>
> Then everything works fine. No problem.
> You _only_ have a problem if if you don't call 'save()'.
> So why exactly don't you want to call 'save' first?
>

Thomas, I don't think I have put the problem this way (I want or I
don't want to).
There are two sides of the story:
- the above workflow must be more clear in the spec
- people may be asking why they need to use a specific workflow, when
other persistence solutions are not requiring it.

We can definitely fix the first, but we must be prepared to have a
good answer for the 2nd too. And for the moment, frankly speaking, I
don't seem to have any other explanation than "that's what the spec
says" (or at most Jukka's explanation in this thread -- which while
valid is still complex for a RDBMS guy).

bests,
./alex
--
.w( the_mindstorm )p.

> Thomas
>

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
Hi,

> the scenario posted here: searching for a John and getting a
> Joe instead

Ok, so the use case is:

1) Get session and load a contact with name 'Joe'
2) Update the name property from 'Joe' to 'John'
3) Now, query the repo for the contact using the name 'Joe'

I would do this:

1) Node contact = ...getNode(...) // we have the node
2) contact.setProperty("name", "John")
    contact.save()
3) ... query ...

Then everything works fine. No problem.
You _only_ have a problem if if you don't call 'save()'.
So why exactly don't you want to call 'save' first?

Thomas

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> Alexandru Popescu ? wrote:
> > I agree with both you comments here. However, I do feel that the OP
> > may be right (I confess that I was not facing this situation so far,
> > but this is probably because my app is a bit different).
> >
> > I would really appreciate if somebody would post on this thread a
> > scenario in which the current behavior is proving helpful (and I have
> > in mind the scenario posted here: searching for a John and getting a
> > Joe instead -- frankly speaking I would be totally surprised in real
> > life if I would be looking for my wife and getting somebody else
> > instead :-) ).
>
> I don't think the current JCR behavior was specced this way because
> there are uses cases needing it. It's simply a result of queries working
> against the persisted state (as the workspace methods), while the
> regular read messages don't.
>

Agreed... and this probably the root cause that makes it look like an
implementation specific detail, and not as something generic enough.

> I totally agree that this can cause surprising results, and the fix for
> that is not to do it. That is, save the changes first, or query + read
> using a separate session object. If this is not clear in the spec, let's
> fix *that* first.
>

Yep. We should probably try to make it more strong in the spec and
provide this level of information in there. At least this will
guarantee that the spec offers the solution if this behavior
represents a problem to the users.

bests,
./alex
--
.w( the_mindstorm )p.

> Best regards, Julian
>

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Jukka Zitting wrote:

> Would you design a relational database client that leaves a
> transaction open like that for extended amounts of time? I don't think
> that's best practice.
It is not - for majority use-cases but in limited resource environment it is.
And yes it is cheaper to re-use and keep open session rather than produce 
garbage. Jukka have you tried to write something when you have 64k heap ?

And to minimize application footprint I will consider keep session alive for 
standalone and embedded applications, if it make sense.

> In fact I think JCR is better suited for managing such long-lived
> draft content for the very reason that the transient changes are
> clearly separate from the persistent storage and can be handled
> entirely on the client side of a client-server model. A relational
> database typically (at least) write-locks all rows that are being
> modified in a transaction.
It depends on your isolation level, and often they are not locked, that will 
bring concurrent modification issues, but it is a different topic :) I will 
stick to our issues.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 7/20/07, IvanLatysh <iv...@yourmail.com> wrote:
> Jukka Zitting wrote:
> > Also, I still don't think there are real use cases for the opposite
> > requirement, i.e. having transient changes visible in search.
> For me it looks like members of this list assume that we are on the webapp or
> client-server architecture where transactions are short.
>
> Let's move to a swing application. Embedded JCR 1 session for entire
> application, long lasting transactions (2+ hours, lunch,...,coffe,...,meeting)
>
> And here is a real-life use cases.
>
> Imagine you are creating/editing a document where you need to add a contact
> and happened that contact is not there so you add the contact, but you can't
> save it yet because you are creating/editing a document, but you need to
> look-up this contact to add to the document, so you run a query ...

Would you design a relational database client that leaves a
transaction open like that for extended amounts of time? I don't think
that's best practice.

In fact I think JCR is better suited for managing such long-lived
draft content for the very reason that the transient changes are
clearly separate from the persistent storage and can be handled
entirely on the client side of a client-server model. A relational
database typically (at least) write-locks all rows that are being
modified in a transaction.

BR,

Jukka Zitting

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Jukka Zitting wrote:

> Also, I still don't think there are real use cases for the opposite
> requirement, i.e. having transient changes visible in search.
For me it looks like members of this list assume that we are on the webapp or 
client-server architecture where transactions are short.

Let's move to a swing application. Embedded JCR 1 session for entire 
application, long lasting transactions (2+ hours, lunch,...,coffe,...,meeting)

And here is a real-life use cases.

Imagine you are creating/editing a document where you need to add a contact and 
happened that contact is not there so you add the contact, but you can't save it 
yet because you are creating/editing a document, but you need to look-up this 
contact to add to the document, so you run a query ...

Or other use-case. Editing complex document that assembled from 3-5 
sub-documents that are represented in a list. Now when you detached a 
sub-document you may re-run query but detached document still there ...

And so on.

You will see ton's use-cases as soon you start thinking about long transactions.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Jukka Zitting <ju...@gmail.com> wrote:
> Hi,
>
> On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> > Alexandru Popescu ? wrote:
> > > I would really appreciate if somebody would post on this thread a
> > > scenario in which the current behavior is proving helpful (and I have
> > > in mind the scenario posted here: searching for a John and getting a
> > > Joe instead -- frankly speaking I would be totally surprised in real
> > > life if I would be looking for my wife and getting somebody else
> > > instead :-) ).
> >
> > I don't think the current JCR behavior was specced this way because
> > there are uses cases needing it. It's simply a result of queries working
> > against the persisted state (as the workspace methods), while the
> > regular read messages don't.
>
> Also, I still don't think there are real use cases for the opposite
> requirement, i.e. having transient changes visible in search.
>

Indeed, the lack of use cases for each approach is making this part of
the spec look so fragile. And I am just trying to figure out a way to
make it more clear/simple to explain-harder to argue upon/etc.


> The real world analogue would be that you are getting married and even
> though you've already said "I do", the magistrate would still claim
> that you are not married until the proper paperwork has been
> submitted. :-)
>

He he... I guess now we have 2 valid scenarios for each of the
perspectives (though I am wondering why both are related to marriage?
:-)) ).

bests,
./alex
--
.w( the_mindstorm )p.


> BR,
>
> Jukka Zitting
>

Re: Isolation level inconsistency.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> Alexandru Popescu ? wrote:
> > I would really appreciate if somebody would post on this thread a
> > scenario in which the current behavior is proving helpful (and I have
> > in mind the scenario posted here: searching for a John and getting a
> > Joe instead -- frankly speaking I would be totally surprised in real
> > life if I would be looking for my wife and getting somebody else
> > instead :-) ).
>
> I don't think the current JCR behavior was specced this way because
> there are uses cases needing it. It's simply a result of queries working
> against the persisted state (as the workspace methods), while the
> regular read messages don't.

Also, I still don't think there are real use cases for the opposite
requirement, i.e. having transient changes visible in search.

The real world analogue would be that you are getting married and even
though you've already said "I do", the magistrate would still claim
that you are not married until the proper paperwork has been
submitted. :-)

BR,

Jukka Zitting

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Alexandru Popescu ? wrote:
> I agree with both you comments here. However, I do feel that the OP
> may be right (I confess that I was not facing this situation so far,
> but this is probably because my app is a bit different).
> 
> I would really appreciate if somebody would post on this thread a
> scenario in which the current behavior is proving helpful (and I have
> in mind the scenario posted here: searching for a John and getting a
> Joe instead -- frankly speaking I would be totally surprised in real
> life if I would be looking for my wife and getting somebody else
> instead :-) ).

I don't think the current JCR behavior was specced this way because 
there are uses cases needing it. It's simply a result of queries working 
against the persisted state (as the workspace methods), while the 
regular read messages don't.

I totally agree that this can cause surprising results, and the fix for 
that is not to do it. That is, save the changes first, or query + read 
using a separate session object. If this is not clear in the spec, let's 
fix *that* first.

Best regards, Julian

RE: Isolation level inconsistency.

Posted by "Hendrik Beck (camunda)" <he...@camunda.com>.
> From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> I would really appreciate if somebody would post on this thread a
> scenario in which the current behavior is proving helpful (and I have
> in mind the scenario posted here: searching for a John and getting a
> Joe instead -- frankly speaking I would be totally surprised in real
> life if I would be looking for my wife and getting somebody else
> instead :-) ).

Uhm, which behaviour do you want to see? In one of our projects we use JCR to enrich our business objects (like Products for a web shop) with content data. This content is shown on the web site. The employees edit this content concurrently with an application, every one on its one. They make changes to different products and when they are finished, they persist these changes by invoking save(). As long as they didn't do that, the people who search and browse the web site only see the persistant state, i.e. the data that is really stored "forever". It would be crucial if people would see all the transient states on the websites and furthermore it would be wrong. Invoking save is something like saying "ok, now I am finished, now I want everybody else to see my changes".

On the other hand as long as they haven't pressed save(), they still want to see their own changes, that's also obvious. But they should only see their own changes.

So for me the only thing that could be a problem is, that an employee didn't press save() and wants to search the repository. In that case they could get results that differ from their local changes. But I would say, if there are any good technical (Jackrabbit-) reasons, that's ok. Then they just have to save their changes and then everything's right again. But in our use cases that doesn't really happen. People rather use the search to find the nodes they want to change. Then they select these nodes, change them, press save() and that's it.

Actually I thought that's one of the most common use cases JCR is used for but apparanty not?!





> -----Original Message-----
> From: Alexandru Popescu ☀ [mailto:the.mindstorm.mailinglist@gmail.com]
> Sent: Friday, July 20, 2007 3:18 PM
> To: users@jackrabbit.apache.org
> Subject: Re: Isolation level inconsistency.
> 
> On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> > Hendrik Beck (camunda) wrote:
> > > One more thing I want to say:
> > >
> > > "again you're proposing a major change to JCR."
> > >
> > > "Maybe it's just me, but I have no idea how that could be implemented
> > > efficiently, *in
> > > particular* if you don't have the luxury to develop that functionality
> from
> > > scratch."
> > >
> > >
> > > 1) In my eyes the public review is there to give any feedback, to
> discuss
> > > everything and to make proposals, whether they are major changes or
> just
> > > little remarks.
> >
> > That's right. The point I was trying to make (and apparently failed) was
> > that this is a major change to *JCR 1.0*.
> >
> > > 2) I wouldn't agree that discussions about implementation details
> should be
> > > part of a public review of a specification. Sure we should keep an eye
> on
> > > the implementation, it has to be done at some point. But, we talk
> about JCR,
> > > not Jackrabbit. The JCR specification shouldn't take care about
> > > implementation details of one product (Jackrabbit), but it should find
> the
> > > best way to make the specification according to people's needs and
> > > requirements.
> >
> > Actually, I wasn't talking about Jackrabbit either.
> >
> > If JCR 2.0 adds requirements that are unlikely to be implemented, that's
> > IMHO a problem. Either you'll end up with no implementations, or with
> > broken implementations (with respect to that feature).
> >
> > Best regards, Julian
> >
> >
> 
> I agree with both you comments here. However, I do feel that the OP
> may be right (I confess that I was not facing this situation so far,
> but this is probably because my app is a bit different).
> 
> I would really appreciate if somebody would post on this thread a
> scenario in which the current behavior is proving helpful (and I have
> in mind the scenario posted here: searching for a John and getting a
> Joe instead -- frankly speaking I would be totally surprised in real
> life if I would be looking for my wife and getting somebody else
> instead :-) ).
> 
> bests,
> 
> ./alex
> --
> .w( the_mindstorm )p.


Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Julian Reschke <ju...@gmx.de> wrote:
> Hendrik Beck (camunda) wrote:
> > One more thing I want to say:
> >
> > "again you're proposing a major change to JCR."
> >
> > "Maybe it's just me, but I have no idea how that could be implemented
> > efficiently, *in
> > particular* if you don't have the luxury to develop that functionality from
> > scratch."
> >
> >
> > 1) In my eyes the public review is there to give any feedback, to discuss
> > everything and to make proposals, whether they are major changes or just
> > little remarks.
>
> That's right. The point I was trying to make (and apparently failed) was
> that this is a major change to *JCR 1.0*.
>
> > 2) I wouldn't agree that discussions about implementation details should be
> > part of a public review of a specification. Sure we should keep an eye on
> > the implementation, it has to be done at some point. But, we talk about JCR,
> > not Jackrabbit. The JCR specification shouldn't take care about
> > implementation details of one product (Jackrabbit), but it should find the
> > best way to make the specification according to people's needs and
> > requirements.
>
> Actually, I wasn't talking about Jackrabbit either.
>
> If JCR 2.0 adds requirements that are unlikely to be implemented, that's
> IMHO a problem. Either you'll end up with no implementations, or with
> broken implementations (with respect to that feature).
>
> Best regards, Julian
>
>

I agree with both you comments here. However, I do feel that the OP
may be right (I confess that I was not facing this situation so far,
but this is probably because my app is a bit different).

I would really appreciate if somebody would post on this thread a
scenario in which the current behavior is proving helpful (and I have
in mind the scenario posted here: searching for a John and getting a
Joe instead -- frankly speaking I would be totally surprised in real
life if I would be looking for my wife and getting somebody else
instead :-) ).

bests,

./alex
--
.w( the_mindstorm )p.

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Hendrik Beck (camunda) wrote:
> Let's just say in the end we want the same, Jackrabbit to work according to
> a good JCR spec ;-)

Actually, I want *many* independent implementations. If it would be only 
Jackrabbit, we wouldn't need the JCP process at all.

Best regards, Julian

RE: Isolation level inconsistency.

Posted by "Hendrik Beck (camunda)" <he...@camunda.com>.
> From: Julian Reschke [mailto:julian.reschke@gmx.de]
> Actually, I wasn't talking about Jackrabbit either.
> 
> If JCR 2.0 adds requirements that are unlikely to be implemented, that's
> IMHO a problem. Either you'll end up with no implementations, or with
> broken implementations (with respect to that feature).

Ok, that's also a good point, Julian, I haven't thought about that one. For
me it just seemed to be more logical to talk about the specification and the
requirements first and then maybe think about implementation details, not
vice versa. "Maybe", because it's JCR, not Jackrabbit...


Let's just say in the end we want the same, Jackrabbit to work according to
a good JCR spec ;-)

Best regards
Hendrik


Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Hendrik Beck (camunda) wrote:
> One more thing I want to say:
> 
> "again you're proposing a major change to JCR."
> 
> "Maybe it's just me, but I have no idea how that could be implemented
> efficiently, *in
> particular* if you don't have the luxury to develop that functionality from
> scratch."
> 
> 
> 1) In my eyes the public review is there to give any feedback, to discuss
> everything and to make proposals, whether they are major changes or just
> little remarks.

That's right. The point I was trying to make (and apparently failed) was 
that this is a major change to *JCR 1.0*.

> 2) I wouldn't agree that discussions about implementation details should be
> part of a public review of a specification. Sure we should keep an eye on
> the implementation, it has to be done at some point. But, we talk about JCR,
> not Jackrabbit. The JCR specification shouldn't take care about
> implementation details of one product (Jackrabbit), but it should find the
> best way to make the specification according to people's needs and
> requirements.

Actually, I wasn't talking about Jackrabbit either.

If JCR 2.0 adds requirements that are unlikely to be implemented, that's 
IMHO a problem. Either you'll end up with no implementations, or with 
broken implementations (with respect to that feature).

Best regards, Julian


RE: Isolation level inconsistency.

Posted by "Hendrik Beck (camunda)" <he...@camunda.com>.
One more thing I want to say:

"again you're proposing a major change to JCR."

"Maybe it's just me, but I have no idea how that could be implemented
efficiently, *in
particular* if you don't have the luxury to develop that functionality from
scratch."


1) In my eyes the public review is there to give any feedback, to discuss
everything and to make proposals, whether they are major changes or just
little remarks.

2) I wouldn't agree that discussions about implementation details should be
part of a public review of a specification. Sure we should keep an eye on
the implementation, it has to be done at some point. But, we talk about JCR,
not Jackrabbit. The JCR specification shouldn't take care about
implementation details of one product (Jackrabbit), but it should find the
best way to make the specification according to people's needs and
requirements.


> -----Original Message-----
> From: Mark Waschkowski [mailto:mwaschkowski@gmail.com]
> Sent: Friday, July 20, 2007 5:10 AM
> To: users@jackrabbit.apache.org
> Subject: Re: Isolation level inconsistency.
> 
> Actually, the more I think about it the worse it gets. I would like to
> know
> to whom the following makes sense:
> 
> 1) Get session and load a contact with name 'Joe'
> 2) Update the name property from 'Joe' to 'John'
> 3) Now, query the repo for the contact using the name 'Joe'
> 4) The node that you get back from the query will have the name property
> as
> 'John' even though the persisted state is 'Joe' and the query was based on
> the name 'Joe'!
> 
> Or, worse yet:
> 1) Get session and load a contact with name 'Joe'
> 2) Update the name property from 'Joe' to 'John'
> 3) Add a new contact
> 4) Query to get all the contacts and iterate through them
> 5) See nodes that have an updated state, but don't see any of the newly
> added nodes! Now you have a strange mix all the previously persisted
> nodes,
> nodes that have been updated in the session, but without any of the newly
> added nodes!
> 
> Maybe I'm totally missing the point, but I can't fathom *why* the spec
> would
> be written this way and really think it should just be one way or the
> other.
> 
>   ie. Either (ideally) respect the current session state and include ALL
> session changes in the query results, or, if that is somehow
> unacceptable/complicated/expensive operation etc., show me the persistent
> state - just not some funky combination!
> 
> "again you're proposing a major change to JCR. If a query would need to
> take
> transient changes into account, it needs
> to operate both on the persisted state, and on the local transient space.
> "
> Some part of the local transient space is *already* being taken into
> account
> (ie. updates of nodes) so maybe handling additions/deletions would be a
> major change or maybe not. Regardless, IMHO, I think the spec will make
> more
> sense if one way or the other (see above) is decided on, and now, during
> the
> public review phase would seem to me like the best time to take these
> inconsistencies.
> 
> Best,
> 
> Mark
> 
> 
> On 7/19/07, Mark Waschkowski <mwaschkowski@gmail.com > wrote:
> >
> > Hi Julian,
> >
> > I've actually brought this issue up with the version 1.0 of the spec and
> > found it confusing. Using
> >
> >   session.getRootNode().getNode(path)
> >
> > 'sees' any transient changes already, so there is already support for
> the
> > transient changes within JCR and the session, albeit not using queries.
> > Furthermore, SQL databases all see transient changes within the same
> > transaction, so there is certainly precedent (and examples) for this
> type of
> > behavior...
> >
> > Best,
> >
> > Mark
> >
> > On 7/19/07, Julian Reschke < julian.reschke@gmx.de> wrote:
> > >
> > > IvanLatysh wrote:
> > > > Julian Reschke wrote:
> > > >
> > > >> again you're proposing a major change to JCR.
> > > > Sorry for my ignorance, but it is funny, you just dropped XPath and
> > > you
> > > > saying that fixing of an obvious mistake is a major change ?
> > >
> > > (1) I didn't drop, the EG basically proposes to drop it. It's under
> > > public review, right? That being said, I'm in favor of keeping XPath
> as
> > > mandatory.
> > >
> > > (2) I strongly disagree that the current property data model is a
> > > mistake; actually, I think it's the right design.
> > >
> > > >> If a query would need to take transient changes into account, it
> > > needs
> > > >> to operate both on the persisted state, and on the local transient
> > > >> space. Note that these may be on different machines. Maybe it's
> just
> > > >> me, but I have no idea how that could be implemented efficiently,
> *in
> > > >> particular* if you don't have the luxury to develop that
> > > functionality
> > > >> from scratch.
> > > > I am sorry, but an implementation of that is a trivial task,
> everybody
> > > > does it.
> > > > Have a look at any persistence engines.
> > >
> > > Well, you seem to be very sure, so I guess I won't argue with you and
> go
> > >
> > > back to my JCR 1.0 L2 implementation, which does not and will not work
> > > that way.
> > >
> > > Best regards, Julian
> > >
> >
> >
> >
> > --
> > Best,
> >
> > Mark Waschkowski


Re: Isolation level inconsistency.

Posted by Florent Guillaume <fg...@nuxeo.com>.
Marcel Reutegger wrote:
> Florent Guillaume wrote:
>> In JCR, there are *three* stages, the first stage being the transient 
>> space.
>>
>> 1. The data you write is transient.
>> 2. You save() the transient space and it becomes the equivalent
>>    of "uncommitted" in a RDB, and is taken into account in
>>    searches.
>>    Or you can refresh() and all *or part of* your transient changes
>>    are lost (you have granularity here).
> 
> jackrabbit does not take into account saved changes that are not yet 
> committed. after looking up the relevant spec section again, it seems to 
> me that the spec is not clear about this:
> 
> 6.6.7 Search Scope
> "A query searches the persistent workspace associated with the current 
> session. It does not search any pending changes that may be recorded on 
> the session but not yet saved."
> 
> The first sentence implies that you have to commit before you can search 
> your changes. the second sentence says that you cannot search transient 
> changes. it doesn't really say what happens with saved, yet uncommitted 
> changes.

"persistent workspace", in the absence of transactions, is whatever has 
been saved. As transactions are not supposed to change the semantics, 
but just provide a level of isolation/rollback with the rest of the 
world, to me it still means "whatever has been saved" when transactions 
are enabled.

Florent

-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87

Re: Isolation level inconsistency.

Posted by Florent Guillaume <fg...@nuxeo.com>.
Peeter Piegaze wrote:
> On 8/14/07, Marcel Reutegger <ma...@gmx.net> wrote:
>> Florent Guillaume wrote:
>>> In JCR, there are *three* stages, the first stage being the transient
>>> space.
>>>
>>> 1. The data you write is transient.
>>> 2. You save() the transient space and it becomes the equivalent
>>>    of "uncommitted" in a RDB, and is taken into account in
>>>    searches.
>>>    Or you can refresh() and all *or part of* your transient changes
>>>    are lost (you have granularity here).
>> jackrabbit does not take into account saved changes that are not yet committed.
>> after looking up the relevant spec section again, it seems to me that the spec
>> is not clear about this:
>>
>> 6.6.7 Search Scope
>> "A query searches the persistent workspace associated with the current session.
>> It does not search any pending changes that may be recorded on the session but
>> not yet saved."
>>
>> The first sentence implies that you have to commit before you can search your
>> changes. the second sentence says that you cannot search transient changes. it
>> doesn't really say what happens with saved, yet uncommitted changes.
> 
> The spec is written throughout as if transactions are not present.
> Section 8.1.3 Save vs.Commit says:
> 
> "Throughout this specification we often mention the distinction
> between transient and persistent levels. The persistent level refers
> to the (one or more) workspaces that make up the actual content
> storage of the repository. The transient level refers to in-memory
> storage associated with a particular Session object.
> 
> In these discussions we usually assume that operations occur
> outside the context of transactions; it is assumed that
> save and other workspace-altering methods immediately effect changes to
> the persistent layer, causing those changes to be made visible to
> other sessions.
> 
> This is not the case, however, once transactions are introduced.
> Within a transaction, changes made by save (or other, workspace-
> direct, methods) are transactionalized and are only persisted and
> published (made visible to other sessions), upon commit of the
> transaction. A rollback will, conversely, revert the effects of any
> saves or workspace-direct methods called within the transaction. "
> 
> Basically it means that in the context of transactions any mention of
> "save" in the spec must be read as "save + commit"

I don't agree. I read it as "in the context of a transaction, things 
behave in exactly the same way from the point of view of the session 
that opened the transaction, but others session will see only committed 
changes."

That's the point of the transaction. Otherwise if would mean that you'd 
have different semantics when you switch from one session that works 
alone without transactions, to a session that is in a transaction 
because there may be other concurrent ones.

> So, taking that section along with the 6.6.7 Search Scope its clear
> that jackrabbit does implement according to spec. Whether this is the
> best behavior is another question.

It's not clear for me that this is what has to be read in the spec.

Florent


-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87

Re: Isolation level inconsistency.

Posted by Peeter Piegaze <pe...@day.com>.
On 8/14/07, Marcel Reutegger <ma...@gmx.net> wrote:
> Florent Guillaume wrote:
> > In JCR, there are *three* stages, the first stage being the transient
> > space.
> >
> > 1. The data you write is transient.
> > 2. You save() the transient space and it becomes the equivalent
> >    of "uncommitted" in a RDB, and is taken into account in
> >    searches.
> >    Or you can refresh() and all *or part of* your transient changes
> >    are lost (you have granularity here).
>
> jackrabbit does not take into account saved changes that are not yet committed.
> after looking up the relevant spec section again, it seems to me that the spec
> is not clear about this:
>
> 6.6.7 Search Scope
> "A query searches the persistent workspace associated with the current session.
> It does not search any pending changes that may be recorded on the session but
> not yet saved."
>
> The first sentence implies that you have to commit before you can search your
> changes. the second sentence says that you cannot search transient changes. it
> doesn't really say what happens with saved, yet uncommitted changes.

The spec is written throughout as if transactions are not present.
Section 8.1.3 Save vs.Commit says:

"Throughout this specification we often mention the distinction
between transient and persistent levels. The persistent level refers
to the (one or more) workspaces that make up the actual content
storage of the repository. The transient level refers to in-memory
storage associated with a particular Session object.

In these discussions we usually assume that operations occur
outside the context of transactions; it is assumed that
save and other workspace-altering methods immediately effect changes to
the persistent layer, causing those changes to be made visible to
other sessions.

This is not the case, however, once transactions are introduced.
Within a transaction, changes made by save (or other, workspace-
direct, methods) are transactionalized and are only persisted and
published (made visible to other sessions), upon commit of the
transaction. A rollback will, conversely, revert the effects of any
saves or workspace-direct methods called within the transaction. "

Basically it means that in the context of transactions any mention of
"save" in the spec must be read as "save + commit"

So, taking that section along with the 6.6.7 Search Scope its clear
that jackrabbit does implement according to spec. Whether this is the
best behavior is another question.

Cheers,
Peeter

>
> regards
>   marcel
>
> > 3. You commit() the transaction and the changes become visible
> >    to other sessions.
> >    Or you can rollback() and all your changes are lost.
>
>


-- 
Peeter Piegaze

Day Software
Suite 331
67 Mowat Avenue
Toronto Ontario M6K 3E3
Canada

office +1 416 987 5720
mobile +1 647 205 2403
fax +1 866 719 3988

Re: Isolation level inconsistency.

Posted by Marcel Reutegger <ma...@gmx.net>.
Florent Guillaume wrote:
> In JCR, there are *three* stages, the first stage being the transient 
> space.
> 
> 1. The data you write is transient.
> 2. You save() the transient space and it becomes the equivalent
>    of "uncommitted" in a RDB, and is taken into account in
>    searches.
>    Or you can refresh() and all *or part of* your transient changes
>    are lost (you have granularity here).

jackrabbit does not take into account saved changes that are not yet committed. 
after looking up the relevant spec section again, it seems to me that the spec 
is not clear about this:

6.6.7 Search Scope
"A query searches the persistent workspace associated with the current session. 
It does not search any pending changes that may be recorded on the session but 
not yet saved."

The first sentence implies that you have to commit before you can search your 
changes. the second sentence says that you cannot search transient changes. it 
doesn't really say what happens with saved, yet uncommitted changes.

regards
  marcel

> 3. You commit() the transaction and the changes become visible
>    to other sessions.
>    Or you can rollback() and all your changes are lost.


Re: Isolation level inconsistency.

Posted by Florent Guillaume <fg...@nuxeo.com>.
IvanLatysh wrote:
> Jukka Zitting wrote:
>> Hi,
>>
>> On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
>>> AFAIK databases simply don't support the concept of transient changes.
>>> please note that the JCR save() is not the equivalent of a db commit().
>>
>> Well said! A better analogue, as already mentoned, is 
>> Statement.execute().
> 
> Also we can state that DB results are immutable, but it does not change 
> the subject.
> 
> Let's put is this way.
>  * RDBMS provide a way to query not-commited changes
>  * I expect JCR to provide a way to query not-persisted changes


You and other people are being confused by the fact that JCR is more
powerful than the standard uncommitted/committed model.


In a classic RDB there are two stages:

1. The data you write is uncommitted. You can search it.
2. You commit() the transaction and other sessions can see the changes.
    Or you can rollback() and all your changes are lost.


In JCR, there are *three* stages, the first stage being the transient space.

1. The data you write is transient.
2. You save() the transient space and it becomes the equivalent
    of "uncommitted" in a RDB, and is taken into account in
    searches.
    Or you can refresh() and all *or part of* your transient changes
    are lost (you have granularity here).
3. You commit() the transaction and the changes become visible
    to other sessions.
    Or you can rollback() and all your changes are lost.


Anyone who doesn't see and understand this model is missing the point.

Cheers,
Florent


-- 
Florent Guillaume, Director of R&D, Nuxeo
Open Source Enterprise Content Management (ECM)
http://www.nuxeo.com   http://www.nuxeo.org   +33 1 40 33 79 87

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Jukka Zitting wrote:
> Hi,
> 
> On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
>> AFAIK databases simply don't support the concept of transient changes.
>> please note that the JCR save() is not the equivalent of a db commit().
> 
> Well said! A better analogue, as already mentoned, is Statement.execute().

Also we can state that DB results are immutable, but it does not change the subject.

Let's put is this way.
  * RDBMS provide a way to query not-commited changes
  * I expect JCR to provide a way to query not-persisted changes

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Stefan Guggisberg <st...@gmail.com>.
On 7/20/07, Alexandru Popescu ☀ <th...@gmail.com> wrote:
> On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > On 7/20/07, Alexandru Popescu ☀ <th...@gmail.com> wrote:
> > > On 7/20/07, Jukka Zitting <ju...@gmail.com> wrote:
> > > > Hi,
> > > >
> > > > On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > > > > AFAIK databases simply don't support the concept of transient changes.
> > > > > please note that the JCR save() is not the equivalent of a db commit().
> > > >
> > > > Well said! A better analogue, as already mentoned, is Statement.execute().
> > > >
> > >
> > > Hope you will not get angry on me :-), but an uncommitted change is a
> > > transient change, so I do think RDBMS are using the transient concept.
> >
> > hehe, i won't ;) but i don't agree.
>
> Great!
>
> > IMO an INSERT, UPDATE or DELETE on
> > database is the equivalent of a saved transient change in JCR.
> >
> > uncommitted (but saved) changes in JCR are the equivalent of uncommitted
> > db changes. at least that's how i view it.
> >
>
> Now, you got me confused :-). What is a saved transient change and
> what is an uncommitted but saved change?

assuming the repository supports transactions, here's an example of a
saved, but uncommitted transient change:

    ...
    node.setProperty("foo", "bar");
    session.save();

and here's an example of a committed saved change
(using a UserTransaction):

    ...
    userTx.begin();
    node.setProperty("foo", "bar");
    session.save();
    userTx.commit();

for more details please see "6.1 Transactions" and specifically
"6.1.3 Save vs. Commit" in the spec.

cheers
stefan

>
> tia,
> ./alex
> --
> .w( the_mindstorm )p.
>
> > cheers
> > stefan
> >
> > >
> > > bests,
> > > ./alex
> > > --
> > > .w( the_mindstorm )p.
> > >
> > > > BR,
> > > >
> > > > Jukka Zitting
> > > >
> > >
> >
>

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> On 7/20/07, Alexandru Popescu ☀ <th...@gmail.com> wrote:
> > On 7/20/07, Jukka Zitting <ju...@gmail.com> wrote:
> > > Hi,
> > >
> > > On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > > > AFAIK databases simply don't support the concept of transient changes.
> > > > please note that the JCR save() is not the equivalent of a db commit().
> > >
> > > Well said! A better analogue, as already mentoned, is Statement.execute().
> > >
> >
> > Hope you will not get angry on me :-), but an uncommitted change is a
> > transient change, so I do think RDBMS are using the transient concept.
>
> hehe, i won't ;) but i don't agree.

Great!

> IMO an INSERT, UPDATE or DELETE on
> database is the equivalent of a saved transient change in JCR.
>
> uncommitted (but saved) changes in JCR are the equivalent of uncommitted
> db changes. at least that's how i view it.
>

Now, you got me confused :-). What is a saved transient change and
what is an uncommitted but saved change?

tia,
./alex
--
.w( the_mindstorm )p.

> cheers
> stefan
>
> >
> > bests,
> > ./alex
> > --
> > .w( the_mindstorm )p.
> >
> > > BR,
> > >
> > > Jukka Zitting
> > >
> >
>

Re: Isolation level inconsistency.

Posted by Stefan Guggisberg <st...@gmail.com>.
On 7/20/07, Alexandru Popescu ☀ <th...@gmail.com> wrote:
> On 7/20/07, Jukka Zitting <ju...@gmail.com> wrote:
> > Hi,
> >
> > On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > > AFAIK databases simply don't support the concept of transient changes.
> > > please note that the JCR save() is not the equivalent of a db commit().
> >
> > Well said! A better analogue, as already mentoned, is Statement.execute().
> >
>
> Hope you will not get angry on me :-), but an uncommitted change is a
> transient change, so I do think RDBMS are using the transient concept.

hehe, i won't ;) but i don't agree. IMO an INSERT, UPDATE or DELETE on
database is the equivalent of a saved transient change in JCR.

uncommitted (but saved) changes in JCR are the equivalent of uncommitted
db changes. at least that's how i view it.

cheers
stefan

>
> bests,
> ./alex
> --
> .w( the_mindstorm )p.
>
> > BR,
> >
> > Jukka Zitting
> >
>

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
Hi,

> Hope you will not get angry on me :-), but an uncommitted change is a
> transient change, so I do think RDBMS are using the transient concept.

As a database guy, I would say a JCR transient change for the JDBC API
is a 'Batch Update' (Statement.addBatch(), Statement.executeBatch()).

I found something in the Java Persistent API (JPA): JCR transient
changes behave like JPA 'not yet persisted objects' or 'detached
objects'. To 'save' an object in JPA, you need to call 'persist' (for
new objects) or 'merge' (for detatched objects).

I agree the JCR documentation should be more specific about that. I
was confused first as well.

Thomas

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/20/07, Jukka Zitting <ju...@gmail.com> wrote:
> Hi,
>
> On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > AFAIK databases simply don't support the concept of transient changes.
> > please note that the JCR save() is not the equivalent of a db commit().
>
> Well said! A better analogue, as already mentoned, is Statement.execute().
>

Hope you will not get angry on me :-), but an uncommitted change is a
transient change, so I do think RDBMS are using the transient concept.

bests,
./alex
--
.w( the_mindstorm )p.

> BR,
>
> Jukka Zitting
>

Re: Isolation level inconsistency.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 7/20/07, Stefan Guggisberg <st...@gmail.com> wrote:
> AFAIK databases simply don't support the concept of transient changes.
> please note that the JCR save() is not the equivalent of a db commit().

Well said! A better analogue, as already mentoned, is Statement.execute().

BR,

Jukka Zitting

Re: Isolation level inconsistency.

Posted by Stefan Guggisberg <st...@gmail.com>.
On 7/20/07, IvanLatysh <iv...@yourmail.com> wrote:
> Hendrik Beck (camunda) wrote:
>
> > 1) The persistent state of a contact node has the name "Joe"
> > 2) I change the name to "John" but don't save it (it's still transient for
> > me or my session respectively)
> > 3) If I access that node, I will see the (transient) name "John"
> > 4) When I search for "Joe", I will still find that node, because searching
> > only takes the persistent state into account
> > 5) But when I now access this node (that I just found under the name "Joe"),
> > then I will see the name "John"
> >
> > Of course, there might be discrepancies in such a case, but 1) it seems to
> > be pretty clear to me how it works and 2) the spec says the following about
> > that to avoid it if necessary:
> >
> > "Applications can clear the Session (either through save or refresh(false))
> > before running a query in order to avoid such discrepancies."
> >
> > Especially I think that this has nothing to do with accessing transient
> > changes from other sessions. It's always about the transient changes of my
> > own session.
>
> If your DB session would have such behavior would you be happy ?

AFAIK databases simply don't support the concept of transient changes.
please note that the JCR save() is not the equivalent of a db commit().

cheers
stefan

>
>
> It is an outrageous bug in the spec, that has to be fixed and it is not a 'big
> change' because _nobody_ use search without committing or clearing the session
> first!
>
> --
> Ivan Latysh
> ivan@yourmail.com
>

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
Hi,

First I was confused with the behavior defined in JSR 170 as well.
Now, I view it like this:

Node.setProperty(...): doesn't store the change.
Node.save(): store the changes.

In the JDBC API, this is like
PreparedStatement.setString(...): doesn't store the changes.
PreparedStatement.execute(): stores the changes

So the JCR transient space is similar not yet executed prepared
statements. Does this make any sense?

Thomas

Re: Isolation level inconsistency.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 7/20/07, IvanLatysh <iv...@yourmail.com> wrote:
> Can anybody find a real-life use-case where query run against persistent
> state but fetched object has transient state ?

I would turn your question around and ask for a real-life use case
where you'd want to search for transient changes.

> Jukka Zitting wrote:
> > This difference, and the
> > fact there are virtually no use cases where you'd want to search for
> > transient changes,
>
> Today I saw a message from Mark Waschkowski with a good use case.

You mean the one in this thread? It's more a sequence of events than a
real use case. Who is the user and what's the reason she would want to
do something like that? More specifically, is there a reason why
someone could not do a save() before executing a query that targets
the same content?

> > coupled with the architectural goal of keeping
> > transient changes fully local (i.e. not involved in full text index
> > updates, etc.) makes IMHO a pretty good rationale for the way search
> > is specified in JCR.
>
> B.t.w. there are no need to do the full index update, search result always
> post-processed to account for the transient state, that how it usually done.

This is OK when you are handling "traditional" database rows that
consist just of relatively small scalar values like integers or
strings, but there's no way to efficiently query large binary
properties without parsing and indexing the content.

Full text search is an essential part of the JCR query features, and
implementing it properly for transient changes *is* expensive. It's
also something that many major pre-JCR content repositories explicitly
don't do (i.e. they only index persisted changes).

> P.S. Thank you for getting into the discussion.

You're welcome. It's an interesting subject, and I agree that the
"query evaluated against persistent state, but results presented as
transient nodes" mode of operation is confusing.

BR,

Jukka Zitting

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
IvanLatysh wrote:
> ...
> B.t.w. there are no need to do the full index update, search result 
> always post-processed to account for the transient state, that how it 
> usually done.
> ...

When you say post-process, do you mean something like "remove false 
positives, and add missing nodes from the transient space"?

Because that, I think, would not be sufficient for some queries possible 
in JCR 2.0.

Best regards, Julian

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Jukka Zitting wrote:

> On 7/20/07, IvanLatysh <iv...@yourmail.com> wrote:
>> It is an outrageous bug in the spec, that has to be fixed [...]
> 
> I do appreciate your opinions and the fact that you are raising
> issues, but the way you are presenting them is borderline trolling.
> There are valid reasons for the design decisions taken by the JCR
> spec, and while you are free to disagree and debate the rationale,
> calling them "outrageous bugs" is IMHO rather extreme.
Yes it is, I absolutely agree with you that this expression is extreme, and it 
serve it's purpose.

Can anybody find a real-life use-case where query run against persistent state 
but fetched object has transient state ?

>> If your DB session would have such behavior would you be happy ?
> 
> Note that there's a crucial difference between JCR and DB sessions. In
> relational databases search (i.e. SELECT) is the one and only way to
> access content, whereas a content repository supports both direct API
> access and search as ways to access content.
Personally I do not see the difference in accessing the date between
SQL QUERY/SP/VIEW and JCR QUERY/XPATH/API
But it doesn't even matter, let's take a Hibernate (ORM) for instance.
It has 2 ways of retrieving the data SQL and API. And Hibernate query always 
return transient state of the object.

> This difference, and the
> fact there are virtually no use cases where you'd want to search for
> transient changes, 
Today I saw a message from Mark Waschkowski with a good use case.

> coupled with the architectural goal of keeping
> transient changes fully local (i.e. not involved in full text index
> updates, etc.) makes IMHO a pretty good rationale for the way search
> is specified in JCR.

B.t.w. there are no need to do the full index update, search result always 
post-processed to account for the transient state, that how it usually done.

P.S. Thank you for getting into the discussion.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 7/20/07, IvanLatysh <iv...@yourmail.com> wrote:
> It is an outrageous bug in the spec, that has to be fixed [...]

I do appreciate your opinions and the fact that you are raising
issues, but the way you are presenting them is borderline trolling.
There are valid reasons for the design decisions taken by the JCR
spec, and while you are free to disagree and debate the rationale,
calling them "outrageous bugs" is IMHO rather extreme.

> If your DB session would have such behavior would you be happy ?

Note that there's a crucial difference between JCR and DB sessions. In
relational databases search (i.e. SELECT) is the one and only way to
access content, whereas a content repository supports both direct API
access and search as ways to access content. This difference, and the
fact there are virtually no use cases where you'd want to search for
transient changes, coupled with the architectural goal of keeping
transient changes fully local (i.e. not involved in full text index
updates, etc.) makes IMHO a pretty good rationale for the way search
is specified in JCR.

BR,

Jukka Zitting

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Julian Reschke wrote:

>> ...
>> It is an outrageous bug in the spec, that has to be fixed and it is 
>> not a 'big change' because _nobody_ use search without committing or 
>> clearing the session first!
> 
> How can you say that? In fact, I'm willing to say that almost 
> *everybody* does that today, because otherwise it won't work.
Please read the sentence again. And if you are sure that everybody does it, 
please provide an example.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
IvanLatysh wrote:
> ...
> It is an outrageous bug in the spec, that has to be fixed and it is not 
> a 'big change' because _nobody_ use search without committing or 
> clearing the session first!

How can you say that? In fact, I'm willing to say that almost 
*everybody* does that today, because otherwise it won't work.

Best regards, Julian


Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Hendrik Beck (camunda) wrote:

> 1) The persistent state of a contact node has the name "Joe"
> 2) I change the name to "John" but don't save it (it's still transient for
> me or my session respectively)
> 3) If I access that node, I will see the (transient) name "John"
> 4) When I search for "Joe", I will still find that node, because searching
> only takes the persistent state into account
> 5) But when I now access this node (that I just found under the name "Joe"),
> then I will see the name "John" 
> 
> Of course, there might be discrepancies in such a case, but 1) it seems to
> be pretty clear to me how it works and 2) the spec says the following about
> that to avoid it if necessary:
> 
> "Applications can clear the Session (either through save or refresh(false))
> before running a query in order to avoid such discrepancies."
>  
> Especially I think that this has nothing to do with accessing transient
> changes from other sessions. It's always about the transient changes of my
> own session.

If your DB session would have such behavior would you be happy ?


It is an outrageous bug in the spec, that has to be fixed and it is not a 'big 
change' because _nobody_ use search without committing or clearing the session 
first!

-- 
Ivan Latysh
ivan@yourmail.com

RE: Isolation level inconsistency.

Posted by "Hendrik Beck (camunda)" <he...@camunda.com>.
Aren't you missing an important point in this discussion? Maybe someone who
is deeper into the spec and the Jackrabbit architecture can correct me if I
am wrong but I understand it like that:

1) Accessing nodes always takes the transient state of my own session into
account. That means, if I make changes, don't save them yet and then access
my own nodes again, I will see my own changes. But I never see any transient
changes of another session. That's clear, I think.

2) Searching always accesses the persistent state only. That means, I can't
search for any transient changes, whether they were made by my session or by
another session. But, and that's the important point (I guess), if I get my
search results and then try to ACCESS one of these nodes from my search
results, then I will (according to point 1) see the transient state of these
nodes. But again, only MY transient changes, not the transient changes of
someone else. This is the case where search result and accessed nodes can be
different. For example:

1) The persistent state of a contact node has the name "Joe"
2) I change the name to "John" but don't save it (it's still transient for
me or my session respectively)
3) If I access that node, I will see the (transient) name "John"
4) When I search for "Joe", I will still find that node, because searching
only takes the persistent state into account
5) But when I now access this node (that I just found under the name "Joe"),
then I will see the name "John"


Of course, there might be discrepancies in such a case, but 1) it seems to
be pretty clear to me how it works and 2) the spec says the following about
that to avoid it if necessary:

"Applications can clear the Session (either through save or refresh(false))
before running a query in order to avoid such discrepancies."


Does that make sense for you?


Especially I think that this has nothing to do with accessing transient
changes from other sessions. It's always about the transient changes of my
own session.


> -----Original Message-----
> From: Mark Waschkowski [mailto:mwaschkowski@gmail.com]
> Sent: Friday, July 20, 2007 5:10 AM
> To: users@jackrabbit.apache.org
> Subject: Re: Isolation level inconsistency.
> 
> Actually, the more I think about it the worse it gets. I would like to
> know
> to whom the following makes sense:
> 
> 1) Get session and load a contact with name 'Joe'
> 2) Update the name property from 'Joe' to 'John'
> 3) Now, query the repo for the contact using the name 'Joe'
> 4) The node that you get back from the query will have the name property
> as
> 'John' even though the persisted state is 'Joe' and the query was based on
> the name 'Joe'!
> 
> Or, worse yet:
> 1) Get session and load a contact with name 'Joe'
> 2) Update the name property from 'Joe' to 'John'
> 3) Add a new contact
> 4) Query to get all the contacts and iterate through them
> 5) See nodes that have an updated state, but don't see any of the newly
> added nodes! Now you have a strange mix all the previously persisted
> nodes,
> nodes that have been updated in the session, but without any of the newly
> added nodes!
> 
> Maybe I'm totally missing the point, but I can't fathom *why* the spec
> would
> be written this way and really think it should just be one way or the
> other.
> 
>   ie. Either (ideally) respect the current session state and include ALL
> session changes in the query results, or, if that is somehow
> unacceptable/complicated/expensive operation etc., show me the persistent
> state - just not some funky combination!
> 
> "again you're proposing a major change to JCR. If a query would need to
> take
> transient changes into account, it needs
> to operate both on the persisted state, and on the local transient space.
> "
> Some part of the local transient space is *already* being taken into
> account
> (ie. updates of nodes) so maybe handling additions/deletions would be a
> major change or maybe not. Regardless, IMHO, I think the spec will make
> more
> sense if one way or the other (see above) is decided on, and now, during
> the
> public review phase would seem to me like the best time to take these
> inconsistencies.
> 
> Best,
> 
> Mark
> 
> 
> On 7/19/07, Mark Waschkowski <mwaschkowski@gmail.com > wrote:
> >
> > Hi Julian,
> >
> > I've actually brought this issue up with the version 1.0 of the spec and
> > found it confusing. Using
> >
> >   session.getRootNode().getNode(path)
> >
> > 'sees' any transient changes already, so there is already support for
> the
> > transient changes within JCR and the session, albeit not using queries.
> > Furthermore, SQL databases all see transient changes within the same
> > transaction, so there is certainly precedent (and examples) for this
> type of
> > behavior...
> >
> > Best,
> >
> > Mark
> >
> > On 7/19/07, Julian Reschke < julian.reschke@gmx.de> wrote:
> > >
> > > IvanLatysh wrote:
> > > > Julian Reschke wrote:
> > > >
> > > >> again you're proposing a major change to JCR.
> > > > Sorry for my ignorance, but it is funny, you just dropped XPath and
> > > you
> > > > saying that fixing of an obvious mistake is a major change ?
> > >
> > > (1) I didn't drop, the EG basically proposes to drop it. It's under
> > > public review, right? That being said, I'm in favor of keeping XPath
> as
> > > mandatory.
> > >
> > > (2) I strongly disagree that the current property data model is a
> > > mistake; actually, I think it's the right design.
> > >
> > > >> If a query would need to take transient changes into account, it
> > > needs
> > > >> to operate both on the persisted state, and on the local transient
> > > >> space. Note that these may be on different machines. Maybe it's
> just
> > > >> me, but I have no idea how that could be implemented efficiently,
> *in
> > > >> particular* if you don't have the luxury to develop that
> > > functionality
> > > >> from scratch.
> > > > I am sorry, but an implementation of that is a trivial task,
> everybody
> > > > does it.
> > > > Have a look at any persistence engines.
> > >
> > > Well, you seem to be very sure, so I guess I won't argue with you and
> go
> > >
> > > back to my JCR 1.0 L2 implementation, which does not and will not work
> > > that way.
> > >
> > > Best regards, Julian
> > >
> >
> >
> >
> > --
> > Best,
> >
> > Mark Waschkowski


Re: Isolation level inconsistency.

Posted by Mark Waschkowski <mw...@gmail.com>.
Actually, the more I think about it the worse it gets. I would like to know
to whom the following makes sense:

1) Get session and load a contact with name 'Joe'
2) Update the name property from 'Joe' to 'John'
3) Now, query the repo for the contact using the name 'Joe'
4) The node that you get back from the query will have the name property as
'John' even though the persisted state is 'Joe' and the query was based on
the name 'Joe'!

Or, worse yet:
1) Get session and load a contact with name 'Joe'
2) Update the name property from 'Joe' to 'John'
3) Add a new contact
4) Query to get all the contacts and iterate through them
5) See nodes that have an updated state, but don't see any of the newly
added nodes! Now you have a strange mix all the previously persisted nodes,
nodes that have been updated in the session, but without any of the newly
added nodes!

Maybe I'm totally missing the point, but I can't fathom *why* the spec would
be written this way and really think it should just be one way or the other.

  ie. Either (ideally) respect the current session state and include ALL
session changes in the query results, or, if that is somehow
unacceptable/complicated/expensive operation etc., show me the persistent
state - just not some funky combination!

"again you're proposing a major change to JCR. If a query would need to take
transient changes into account, it needs
to operate both on the persisted state, and on the local transient space. "
Some part of the local transient space is *already* being taken into account
(ie. updates of nodes) so maybe handling additions/deletions would be a
major change or maybe not. Regardless, IMHO, I think the spec will make more
sense if one way or the other (see above) is decided on, and now, during the
public review phase would seem to me like the best time to take these
inconsistencies.

Best,

Mark


On 7/19/07, Mark Waschkowski <mwaschkowski@gmail.com > wrote:
>
> Hi Julian,
>
> I've actually brought this issue up with the version 1.0 of the spec and
> found it confusing. Using
>
>   session.getRootNode().getNode(path)
>
> 'sees' any transient changes already, so there is already support for the
> transient changes within JCR and the session, albeit not using queries.
> Furthermore, SQL databases all see transient changes within the same
> transaction, so there is certainly precedent (and examples) for this type of
> behavior...
>
> Best,
>
> Mark
>
> On 7/19/07, Julian Reschke < julian.reschke@gmx.de> wrote:
> >
> > IvanLatysh wrote:
> > > Julian Reschke wrote:
> > >
> > >> again you're proposing a major change to JCR.
> > > Sorry for my ignorance, but it is funny, you just dropped XPath and
> > you
> > > saying that fixing of an obvious mistake is a major change ?
> >
> > (1) I didn't drop, the EG basically proposes to drop it. It's under
> > public review, right? That being said, I'm in favor of keeping XPath as
> > mandatory.
> >
> > (2) I strongly disagree that the current property data model is a
> > mistake; actually, I think it's the right design.
> >
> > >> If a query would need to take transient changes into account, it
> > needs
> > >> to operate both on the persisted state, and on the local transient
> > >> space. Note that these may be on different machines. Maybe it's just
> > >> me, but I have no idea how that could be implemented efficiently, *in
> > >> particular* if you don't have the luxury to develop that
> > functionality
> > >> from scratch.
> > > I am sorry, but an implementation of that is a trivial task, everybody
> > > does it.
> > > Have a look at any persistence engines.
> >
> > Well, you seem to be very sure, so I guess I won't argue with you and go
> >
> > back to my JCR 1.0 L2 implementation, which does not and will not work
> > that way.
> >
> > Best regards, Julian
> >
>
>
>
> --
> Best,
>
> Mark Waschkowski

Re: Isolation level inconsistency.

Posted by Mark Waschkowski <mw...@gmail.com>.
Hi Julian,

I've actually brought this issue up with the version 1.0 of the spec and
found it confusing. Using

  session.getRootNode().getNode(path)

'sees' any transient changes already, so there is already support for the
transient changes within JCR and the session, albeit not using queries.
Furthermore, SQL databases all see transient changes within the same
transaction, so there is certainly precedent (and examples) for this type of
behavior...

Best,

Mark

On 7/19/07, Julian Reschke <ju...@gmx.de> wrote:
>
> IvanLatysh wrote:
> > Julian Reschke wrote:
> >
> >> again you're proposing a major change to JCR.
> > Sorry for my ignorance, but it is funny, you just dropped XPath and you
> > saying that fixing of an obvious mistake is a major change ?
>
> (1) I didn't drop, the EG basically proposes to drop it. It's under
> public review, right? That being said, I'm in favor of keeping XPath as
> mandatory.
>
> (2) I strongly disagree that the current property data model is a
> mistake; actually, I think it's the right design.
>
> >> If a query would need to take transient changes into account, it needs
> >> to operate both on the persisted state, and on the local transient
> >> space. Note that these may be on different machines. Maybe it's just
> >> me, but I have no idea how that could be implemented efficiently, *in
> >> particular* if you don't have the luxury to develop that functionality
> >> from scratch.
> > I am sorry, but an implementation of that is a trivial task, everybody
> > does it.
> > Have a look at any persistence engines.
>
> Well, you seem to be very sure, so I guess I won't argue with you and go
> back to my JCR 1.0 L2 implementation, which does not and will not work
> that way.
>
> Best regards, Julian
>



-- 
Best,

Mark Waschkowski

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
IvanLatysh wrote:
> Julian Reschke wrote:
> 
>> again you're proposing a major change to JCR.
> Sorry for my ignorance, but it is funny, you just dropped XPath and you 
> saying that fixing of an obvious mistake is a major change ?

(1) I didn't drop, the EG basically proposes to drop it. It's under 
public review, right? That being said, I'm in favor of keeping XPath as 
mandatory.

(2) I strongly disagree that the current property data model is a 
mistake; actually, I think it's the right design.

>> If a query would need to take transient changes into account, it needs 
>> to operate both on the persisted state, and on the local transient 
>> space. Note that these may be on different machines. Maybe it's just 
>> me, but I have no idea how that could be implemented efficiently, *in 
>> particular* if you don't have the luxury to develop that functionality 
>> from scratch.
> I am sorry, but an implementation of that is a trivial task, everybody 
> does it.
> Have a look at any persistence engines.

Well, you seem to be very sure, so I guess I won't argue with you and go 
back to my JCR 1.0 L2 implementation, which does not and will not work 
that way.

Best regards, Julian

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Julian Reschke wrote:

> again you're proposing a major change to JCR.
Sorry for my ignorance, but it is funny, you just dropped XPath and you saying 
that fixing of an obvious mistake is a major change ?

> If a query would need to take transient changes into account, it needs 
> to operate both on the persisted state, and on the local transient 
> space. Note that these may be on different machines. Maybe it's just me, 
> but I have no idea how that could be implemented efficiently, *in 
> particular* if you don't have the luxury to develop that functionality 
> from scratch.
I am sorry, but an implementation of that is a trivial task, everybody does it.
Have a look at any persistence engines.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Ivan,

again you're proposing a major change to JCR.

If a query would need to take transient changes into account, it needs 
to operate both on the persisted state, and on the local transient 
space. Note that these may be on different machines. Maybe it's just me, 
but I have no idea how that could be implemented efficiently, *in 
particular* if you don't have the luxury to develop that functionality 
from scratch.

Best regards, Julian

Re: Isolation level inconsistency.

Posted by Alexandru Popescu ☀ <th...@gmail.com>.
On 7/22/07, David Nuescheler <da...@day.com> wrote:
> Hi Ivan et al,
>
> I would like to make sure that I understand your intention.
>
> (a) JCR should not mandate the scope of query wrt the transient space
> (b) Jackrabbit should implement isolation differently
>
> In case you are interested in option (a) then I would like to suggest to
> send this to jsr-283-comments@jcp.org
>

David is that email address working as a mailing list? Or is it just a
normal email address to the group members? I would definitely be
interested (as I already showed in this thread) to continue the
discussion and I just want to make sure it is possible to do so if we
redirect this one to the pointed address.

tia,
./alex
--
.w( the_mindstorm )p.

> I guess that from the discussion on this list it is relatively evident
> though that there are a number of arguments that can be made for either
> way implementing or using a content repository.
>
> I think you have a point that if one can argue both ways it probably
> makes sense to allow both implementations in the specification, and
> therefore rewrite the section you quoted in the beginning of this thread.
>
> Again, please feel free to suggest that to jsr-283-comments@jcp.org
>
> If you comments are more targeted at (b) I think
> dev@jackrabbit.apache.org is the correct audience, and a patch would
> certainly be a good start ;).
> Personally, I believe that the isolation levels problem particularly when
> it comes to things like ranking in full-text search or transient modifications
> that do not satisfy nodetype constraints can become more tricky than
> expected.
>
> regards,
> david
>

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
Hi,

> loosen this contract by leaving the query scope unspecified

I think that would be good. Even better would be: Add a descriptor
(see Repository.getDescriptor()) QUERY_TRANSIENT_CHANGE_VISIBILITY
(false for current Jackrabbit) where the behavior is defined.

I would still keep in the specification that returned nodes include
transient changes.

Thomas




On 7/23/07, David Nuescheler <da...@day.com> wrote:
> Hi Ivan,
>
> Thanks for your summary.
>
> > When discussion will cool down I will summarize it and send a feedback to
> > jsr-283-comments@jcp.org.
> very good.
>
> > So far it looks like I hit the honey pot, I see a few use-cases from list
> > members in support of an idea and none against and it bother me.
>
> I support your idea that from an API users perspective this behaviour
> could be desirable.
>
> This particular limitation was originally put into the spec because
> a lot of vendors believe that that it is hard to implement or they cannot
> implement it at all. So you can consider that the current specification
> is what most vendors can implement.
> The section you originally quoted is in the spec on purpose, it is not
> an oversight.
>
> As I mentioned I think one could suggest to loosen this contract by
> leaving the query scope unspecified as a compromise.
>
> Personally, just from my gut feeling I cannot see a lot of support from
> the vendors for your proposed strict change, but feel free to submit
> it anyway, and it will certainly be considered.
>
> regards,
> david
>

Re: Isolation level inconsistency.

Posted by Mark Waschkowski <mw...@gmail.com>.
Julian,

I understand that you have efficiency related concerns. Fair enough.
However, this is a discussion of the semantics of the spec, not
implementation discussion. As well, this is the user list, I would assume
that implementation discussions would belong in the dev mailing list...

Secondly, I know the original poster suggested only one way (update query
results with transient state) but I've stated twice before that either that
approach or just showing the persistent state (without ANY transient
information) would be acceptable to me:
"Maybe I'm totally missing the point, but I can't fathom *why* the spec
would be written this way and really think it should just be one way or the
other.
  ie. Either (ideally) respect the current session state and include ALL
session changes in the query results, or, if that is somehow
unacceptable/complicated/expensive operation etc., show me the persistent
state - just not some funky combination!"

Please note the *or* in the proposal that I gave, and read my full post for
all the details.

Best,

Mark

so far I haven't seen a proposal how the desired semantics (query
> operating on the transient state) can be implemented efficiently at all,
> without closely coupling the transient space implementation to the
> storage. And, as a matter of fact, the contrary (de-coupling them) is
> what's currently being done in the Jackrabbit SPI work.
>
So, I'm not opposed to discuss this, but right now I just don't see how
> to implement that.
>
> For the record, I'm fine with *allowing* repositories to implement that
> (but not making it required).
>
> Best regards, Julian
>



-- 
Best,

Mark Waschkowski

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
> No, not in the spec. But if you close coupling, then
> 1) it will be hard to remote the protocol, and

This depends on how you implement it.

> 2) it will be impossible to execute the plans for an SPI layer (because
> it involves a generic transient layer on top of SPI).

I suggest to keep the current behavior of Jackrabbit. But I would only
change the spec, so that both behaviors are allowed. I would add a
descriptor (see Repository.getDescriptor())
QUERY_TRANSIENT_CHANGE_VISIBILITY (false for current Jackrabbit) where
the behavior is defined.

Thomas

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Thomas Mueller wrote:
> Hi Julian,
> 
>> so far I haven't seen a proposal how the desired semantics (query
>> operating on the transient state) can be implemented efficiently at all,
> 
> As far as I know, old Hibernate and JPA works like this (except
> objects that are not persisted, and detached objects; both cases are
> not relevant for JCR). So it can be implemented. I would even say if
> somebody wants to implement JCR using an JPA, it would be easier that
> way.
> 
>> ... without closely coupling the transient space implementation to the
>> storage.
> 
> Is there a rule in the spec that says the transient space must be
> decoupled (except, the rule we are talking about)?

No, not in the spec. But if you close coupling, then

1) it will be hard to remote the protocol, and

2) it will be impossible to execute the plans for an SPI layer (because 
it involves a generic transient layer on top of SPI).

> ...

Best regards, Julian

Re: Isolation level inconsistency.

Posted by Thomas Mueller <th...@gmail.com>.
Hi Julian,

> so far I haven't seen a proposal how the desired semantics (query
> operating on the transient state) can be implemented efficiently at all,

As far as I know, old Hibernate and JPA works like this (except
objects that are not persisted, and detached objects; both cases are
not relevant for JCR). So it can be implemented. I would even say if
somebody wants to implement JCR using an JPA, it would be easier that
way.

> ... without closely coupling the transient space implementation to the
> storage.

Is there a rule in the spec that says the transient space must be
decoupled (except, the rule we are talking about)?

> I just don't see how to implement that.

It goes like this: there is a hash set of changed nodes (when the app
calls setProperty the JCR implementation adds the node to this set).
When the application runs a query, the engine would store the changed
nodes but don't commit (that is, when using a database backend and the
same engine for querying). That's it.

> For the record, I'm fine with *allowing* repositories to implement that
> (but not making it required).

I fully agree. For some implementations it is easy, for some very hard.

Thomas

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
Mark Waschkowski wrote:
> Back after a long weekend away...
> 
> For the record, the only reasoning for the below case was that its easiest
> to implement by the vendors. Here is one of my original examples:
> ...

Mark,

so far I haven't seen a proposal how the desired semantics (query 
operating on the transient state) can be implemented efficiently at all, 
without closely coupling the transient space implementation to the 
storage. And, as a matter of fact, the contrary (de-coupling them) is 
what's currently being done in the Jackrabbit SPI work.

So, I'm not opposed to discuss this, but right now I just don't see how 
to implement that.

For the record, I'm fine with *allowing* repositories to implement that 
(but not making it required).

Best regards, Julian

Re: Isolation level inconsistency.

Posted by Mark Waschkowski <mw...@gmail.com>.
Back after a long weekend away...

For the record, the only reasoning for the below case was that its easiest
to implement by the vendors. Here is one of my original examples:

Snip--
1) Get session and load a contact with name 'Joe'
2) Update the name property from 'Joe' to 'John'
3) Add a new contact
4) Query to get all the contacts and iterate through them
5) See nodes that have an updated state, but don't see any of the newly
added nodes! Now you have a strange mix all the previously persisted nodes,
nodes that have been updated in the session, but without any of the newly
added nodes!

Maybe I'm totally missing the point, but I can't fathom *why* the spec would
be written this way and really think it should just be one way or the other.

  ie. Either (ideally) respect the current session state and include ALL
session changes in the query results, or, if that is somehow
unacceptable/complicated/expensive operation etc., show me the persistent
state - just not some funky combination!
---end snip

I'm disappointed that there was so much dancing around the issues (by some
of the mailing list users) of why this should be considered proper or
reasonable, even though its odd, and has results that one would not expect.
Defending the spec because its the spec, or saying that its a *big change*
or *unfeasible* etc. is unhelpful when a new idea is proposed: -1 to those
of you doing so. At least some agreement on whether or not the idea is
reasonable or an improvement is needed before shooting suggestions down.

David said (re: a proposal for a more strict specification)
"I support your idea that from an API users perspective this behaviour could
be desirable."
Great.

David said (re: current spec)
"This particular limitation was originally put into the spec because a lot
of vendors believe that that it is hard to implement or they cannot
implement it at all. "
I can perfectly understand why this limitation might exist (many vendors
with implementations before JCR came along). However, one of the goals of
the spec was to make the API easy for developers, so that has to be
considered as well.

David said:
"As I mentioned I think one could suggest to loosen this contract by leaving
the query scope unspecified as a compromise."
Yes, would be an OK compromise, and one that I think would be better than
the current strange (and mandated) behavior. Ideally, a "particular
limitation" would be removed as the spec evolves, but at least it would
allow for the newer implementations to provide more sensible behaviors. I
would go further and suggest that a default behavior be stated within the
spec (either seeing persistent changes or not).

I'm going to go write to the 283 committee to update this part of the spec,
thanks to everyone for their comments.

Best,

Mark

On 7/23/07, David Nuescheler <da...@day.com> wrote:
>
> Hi Ivan,
>
> Thanks for your summary.
>
> > When discussion will cool down I will summarize it and send a feedback
> to
> > jsr-283-comments@jcp.org.
> very good.
>
> > So far it looks like I hit the honey pot, I see a few use-cases from
> list
> > members in support of an idea and none against and it bother me.
>
> I support your idea that from an API users perspective this behaviour
> could be desirable.
>
> This particular limitation was originally put into the spec because
> a lot of vendors believe that that it is hard to implement or they cannot
> implement it at all. So you can consider that the current specification
> is what most vendors can implement.
> The section you originally quoted is in the spec on purpose, it is not
> an oversight.
>
> As I mentioned I think one could suggest to loosen this contract by
> leaving the query scope unspecified as a compromise.
>
> Personally, just from my gut feeling I cannot see a lot of support from
> the vendors for your proposed strict change, but feel free to submit
> it anyway, and it will certainly be considered.
>
> regards,
> david
>



-- 
Best,

Mark Waschkowski

Re: Isolation level inconsistency.

Posted by David Nuescheler <da...@day.com>.
Hi Ivan,

Thanks for your summary.

> When discussion will cool down I will summarize it and send a feedback to
> jsr-283-comments@jcp.org.
very good.

> So far it looks like I hit the honey pot, I see a few use-cases from list
> members in support of an idea and none against and it bother me.

I support your idea that from an API users perspective this behaviour
could be desirable.

This particular limitation was originally put into the spec because
a lot of vendors believe that that it is hard to implement or they cannot
implement it at all. So you can consider that the current specification
is what most vendors can implement.
The section you originally quoted is in the spec on purpose, it is not
an oversight.

As I mentioned I think one could suggest to loosen this contract by
leaving the query scope unspecified as a compromise.

Personally, just from my gut feeling I cannot see a lot of support from
the vendors for your proposed strict change, but feel free to submit
it anyway, and it will certainly be considered.

regards,
david

Re: Isolation level inconsistency.

Posted by Marcel Reutegger <ma...@gmx.net>.
> > If query return persistent state only you will see a bit different 
> > behavior.
> >   1) query repo for node with property P=steve
> >   2) got node A with property P=steve
> >   3) set node A property P=john (making it transient, resulting in node
> A')
> >   4) query repository for node with property P=john
> >   5) got nothing
> >   6) query repo for node with property P=steve
> >   7) got node A (the original from the store because A' is still
> transient)
> > with property P=steve
> > 
> > And what Marcel was trying to say was:
> > 
> >   8) set node A property Q=test (making it transient, resulting in node
> A''
> > because it's not the same as the one in the store and also different
> from
> > A'? Or does something else happen?)
> >   9) What happens when we call save() or refresh() on A' or A''?
> > 
> refresh will do it's job per spec, no difference here.

but the spec doesn't cover the case when you have three instances of the same node: A, A' and A''.

> Save will throw an exception when transient state has such conflict.

how do you resolve such a situation? let's say theoretically you can refresh A' in order to save A'', how do you get to that node using a path or the UUID? e.g. if the node is referenceable and I call Session.getNodeByUUID() will the method return A' or A''?

Returning transient nodes for QueryResult.getNodes() is the only reasonable option!

However I agree with you that a JCR implementation should be allow to also consider transient changes when executing a query.

regards
 marcel
-- 
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Tako Schotanus wrote:

> No he's talking about  what would happen  if you return persisted nodes 
> from
> queries, more like you said below:
> 
> What you missed is that every time query will return the same transient
>> state,
>> so no A' and A'' will ever exist, and node A persisted with all changes.
>>
>> If query return persistent state only you will see a bit different
>> behavior.
>>    1) query repo for node with property P=steve
>>    2) got node A with property P=steve
>>    3) set node A property P=john (making it transient)
>>    4) query repository for node with property P=john
>>    5) got nothing
>>    6) query repo for node with property P=steve
>>    7) got node A' (since A is a transient at this moment) with property
>> P=steve
> 
> 
> No, changing node A makes it A', remember it's different now from the 
> node A
> that is persisted because you haven't saved it yet! So to change your
> example:
> 
> If query return persistent state only you will see a bit different 
> behavior.
>   1) query repo for node with property P=steve
>   2) got node A with property P=steve
>   3) set node A property P=john (making it transient, resulting in node A')
>   4) query repository for node with property P=john
>   5) got nothing
>   6) query repo for node with property P=steve
>   7) got node A (the original from the store because A' is still transient)
> with property P=steve
> 
> And what Marcel was trying to say was:
> 
>   8) set node A property Q=test (making it transient, resulting in node A''
> because it's not the same as the one in the store and also different from
> A'? Or does something else happen?)
>   9) What happens when we call save() or refresh() on A' or A''?
> 
refresh will do it's job per spec, no difference here.
Save will throw an exception when transient state has such conflict.


-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Marcel Reutegger <ma...@gmx.net>.
> changing node A makes it A', remember it's different now from the node
> A
> that is persisted because you haven't saved it yet! So to change your
> example:
> 
> If query return persistent state only you will see a bit different
> behavior.
>    1) query repo for node with property P=steve
>    2) got node A with property P=steve
>    3) set node A property P=john (making it transient, resulting in node
> A')
>    4) query repository for node with property P=john
>    5) got nothing
>    6) query repo for node with property P=steve
>    7) got node A (the original from the store because A' is still
> transient)
> with property P=steve
> 
> And what Marcel was trying to say was:
> 
>    8) set node A property Q=test (making it transient, resulting in node
> A''
> because it's not the same as the one in the store and also different from
> A'? Or does something else happen?)
>    9) What happens when we call save() or refresh() on A' or A''?
> 
> At least that's what I think he was trying to say :-)

that's exactly what I meant. Thanks for the clarification.

regards
 marcel
-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

Re: Isolation level inconsistency.

Posted by Tako Schotanus <qu...@gmail.com>.
On 7/23/07, IvanLatysh <iv...@yourmail.com> wrote:
>
> Marcel Reutegger wrote:
>
> > I agree with you that this not intuitive but returning a node with the
> > persistent state is IMO worse.
> >
> > Let say you have a node A. Then you set property p which gives you A'
> > (the transiently modified A). Then you query the workspace for nodes
> > with property p and the value you just set. The query would then return
> > node A. Now you modify that very same node instance and set property q
> > to another value. Will this result in A''? What happens to A'? What
> > happens if you call refresh() on A'' will it also refresh A'? What will
> > be persisted if you call Session.save(), A' or A'' or modifications from
> > both? Assuming it were possible that you *can* save just A', does a save
> > on A'' throw a InvalidItemStateException? If I had the time I could
> > probably go one for minutes and write down more of those tricky
> questions.
> If I understood you correctly:
>    1) query repository for node with property P=steve
>    2) got node A with property P=steve
>    3) set node A property P=john (making it transient)
>    4) query repository for node with property P=john
>    5) got node A (transient) with property P=john
>    6) set property Q=test


No he's talking about  what would happen  if you return persisted nodes from
queries, more like you said below:

What you missed is that every time query will return the same transient
> state,
> so no A' and A'' will ever exist, and node A persisted with all changes.
>
> If query return persistent state only you will see a bit different
> behavior.
>    1) query repo for node with property P=steve
>    2) got node A with property P=steve
>    3) set node A property P=john (making it transient)
>    4) query repository for node with property P=john
>    5) got nothing
>    6) query repo for node with property P=steve
>    7) got node A' (since A is a transient at this moment) with property
> P=steve


No, changing node A makes it A', remember it's different now from the node A
that is persisted because you haven't saved it yet! So to change your
example:

If query return persistent state only you will see a bit different behavior.
   1) query repo for node with property P=steve
   2) got node A with property P=steve
   3) set node A property P=john (making it transient, resulting in node A')
   4) query repository for node with property P=john
   5) got nothing
   6) query repo for node with property P=steve
   7) got node A (the original from the store because A' is still transient)
with property P=steve

And what Marcel was trying to say was:

   8) set node A property Q=test (making it transient, resulting in node A''
because it's not the same as the one in the store and also different from
A'? Or does something else happen?)
   9) What happens when we call save() or refresh() on A' or A''?

At least that's what I think he was trying to say :-)

Cheers,
 -Tako

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Marcel Reutegger wrote:

> I agree with you that this not intuitive but returning a node with the 
> persistent state is IMO worse.
> 
> Let say you have a node A. Then you set property p which gives you A' 
> (the transiently modified A). Then you query the workspace for nodes 
> with property p and the value you just set. The query would then return 
> node A. Now you modify that very same node instance and set property q 
> to another value. Will this result in A''? What happens to A'? What 
> happens if you call refresh() on A'' will it also refresh A'? What will 
> be persisted if you call Session.save(), A' or A'' or modifications from 
> both? Assuming it were possible that you *can* save just A', does a save 
> on A'' throw a InvalidItemStateException? If I had the time I could 
> probably go one for minutes and write down more of those tricky questions.
If I understood you correctly:
   1) query repository for node with property P=steve
   2) got node A with property P=steve
   3) set node A property P=john (making it transient)
   4) query repository for node with property P=john
   5) got node A (transient) with property P=john
   6) set property Q=test

What you missed is that every time query will return the same transient state, 
so no A' and A'' will ever exist, and node A persisted with all changes.

If query return persistent state only you will see a bit different behavior.
   1) query repo for node with property P=steve
   2) got node A with property P=steve
   3) set node A property P=john (making it transient)
   4) query repository for node with property P=john
   5) got nothing
   6) query repo for node with property P=steve
   7) got node A' (since A is a transient at this moment) with property P=steve

> However there is one thing I never really paid attention to so far: 
> while the method QueryResult.getNodes() returns items that reflect the 
> transient changes of the session, QueryResult.getRows() does not have to 
> and probably should not reflect transient changes. I think the current 
> spec does not really mention whether values of transient properties or 
> persisted properties are returned. Since a JCR Row does not return JCR 
> Items but only JCR Values which are not attached to Items the Row should 
> return the values of the persistent properties. This is currently not 
> the case in Jackrabbit. But as mentioned before it is not clearly 
> specified.
Thank you for pointing it out. It is one more reason to make sure that isolation 
level *must* be defined in the spec and impl. should obey it.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Marcel Reutegger <ma...@gmx.net>.
IvanLatysh wrote:
>   But now query run against persistent state and return transient state, 
> that is totally confusing.

I agree with you that this not intuitive but returning a node with the 
persistent state is IMO worse.

Let say you have a node A. Then you set property p which gives you A' (the 
transiently modified A). Then you query the workspace for nodes with property p 
and the value you just set. The query would then return node A. Now you modify 
that very same node instance and set property q to another value. Will this 
result in A''? What happens to A'? What happens if you call refresh() on A'' 
will it also refresh A'? What will be persisted if you call Session.save(), A' 
or A'' or modifications from both? Assuming it were possible that you *can* save 
just A', does a save on A'' throw a InvalidItemStateException? If I had the time 
I could probably go one for minutes and write down more of those tricky questions.

However there is one thing I never really paid attention to so far: while the 
method QueryResult.getNodes() returns items that reflect the transient changes 
of the session, QueryResult.getRows() does not have to and probably should not 
reflect transient changes. I think the current spec does not really mention 
whether values of transient properties or persisted properties are returned. 
Since a JCR Row does not return JCR Items but only JCR Values which are not 
attached to Items the Row should return the values of the persistent properties. 
This is currently not the case in Jackrabbit. But as mentioned before it is not 
clearly specified.

regards
  marcel

Re: Isolation level inconsistency.

Posted by Mark Waschkowski <mw...@gmail.com>.
Go away for a long weekend and come back to 50ish responses. Wow, this
thread has touched a cord.

re:session scope
"It has been stated before that you can easily avoid that by either
calling save() before, or doing the query on a separate session without
pending changes."
Yes, but the whole point is that the user *shouldn't have to*.

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
IvanLatysh wrote:
> ...
>  >>Because that, I think, would not be sufficient for some queries 
> possible in
>  >>JCR 2.0.
> Can you please provide an example of such query?

I would think it could happen as soon as there's a join in the query. 
Part of the query will evaluate to false in the persistent state, so the 
node will not be included in the result set. However, to re-evaluate the 
query again on nodes changed in transient storage, you would have to 
re-access the whole persisted state.

>   At the end consistence is more important. Even if query run against 
> persistence state only without taking into account transient state is 
> should return persistent state.
>   But now query run against persistent state and return transient state, 
> that is totally confusing.

It has been stated before that you can easily avoid that by either 
calling save() before, or doing the query on a separate session without 
pending changes.

Best regards, Julian

Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
Julian Reschke wrote:

> Ivan, on the other hand you didn't reply to my question about how the 
> "query result post-processing" you proposed is going to work. Maybe you 
> could enlighten us on that?
I am sorry.

 >>When you say post-process, do you mean something like "remove false positives,
 >>and add missing nodes from the transient space"?
Yes.

 >>Because that, I think, would not be sufficient for some queries possible in
 >>JCR 2.0.
Can you please provide an example of such query?

   At the end consistence is more important. Even if query run against 
persistence state only without taking into account transient state is should 
return persistent state.
   But now query run against persistent state and return transient state, that 
is totally confusing.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by Julian Reschke <ju...@gmx.de>.
IvanLatysh wrote:
 > ...
> So far it looks like I hit the honey pot, I see a few use-cases from 
> list members in support of an idea and none against and it bother me.
> ...

Ivan, on the other hand you didn't reply to my question about how the 
"query result post-processing" you proposed is going to work. Maybe you 
could enlighten us on that?

Best regards, Julian



Re: Isolation level inconsistency.

Posted by IvanLatysh <iv...@yourmail.com>.
David Nuescheler wrote:

> I would like to make sure that I understand your intention.
> 
> (a) JCR should not mandate the scope of query wrt the transient space
> (b) Jackrabbit should implement isolation differently
I will quote my original message:
[quote]
=== Proposal ===========================================
  4.6.12 QueryResult
QueryResults reflect any pending changes currently stored in the session.
========================================================
[/quote]

My intention is:
  1) Spec *must* define query scope and isolation level(s).
  2) JackRabbit *must* implement query exactly per spec.

I am listening for all members and looking for a use-cases that contradict my 
idea. Such discussions prove my idea right or wrong.

When discussion will cool down I will summarize it and send a feedback to 
jsr-283-comments@jcp.org.

So far it looks like I hit the honey pot, I see a few use-cases from list 
members in support of an idea and none against and it bother me.

-- 
Ivan Latysh
ivan@yourmail.com

Re: Isolation level inconsistency.

Posted by David Nuescheler <da...@day.com>.
Hi Ivan et al,

I would like to make sure that I understand your intention.

(a) JCR should not mandate the scope of query wrt the transient space
(b) Jackrabbit should implement isolation differently

In case you are interested in option (a) then I would like to suggest to
send this to jsr-283-comments@jcp.org

I guess that from the discussion on this list it is relatively evident
though that there are a number of arguments that can be made for either
way implementing or using a content repository.

I think you have a point that if one can argue both ways it probably
makes sense to allow both implementations in the specification, and
therefore rewrite the section you quoted in the beginning of this thread.

Again, please feel free to suggest that to jsr-283-comments@jcp.org

If you comments are more targeted at (b) I think
dev@jackrabbit.apache.org is the correct audience, and a patch would
certainly be a good start ;).
Personally, I believe that the isolation levels problem particularly when
it comes to things like ranking in full-text search or transient modifications
that do not satisfy nodetype constraints can become more tricky than
expected.

regards,
david