Bug 780363 (SOA-2772) - modeshape sequencers glitch
Summary: modeshape sequencers glitch
Keywords:
Status: CLOSED NEXTRELEASE
Alias: SOA-2772
Product: JBoss Enterprise SOA Platform 5
Classification: JBoss
Component: EDS
Version: 5.1.0.ER6
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: FUTURE
Assignee: Van Halbert
QA Contact:
URL: http://jira.jboss.org/jira/browse/SOA...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-01-14 11:27 UTC by Aleksandar Kostadinov
Modified: 2011-11-02 15:10 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
jsp
Last Closed: 2011-11-02 15:10:36 UTC
Type: Bug


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 780316 0 urgent CLOSED modeshape QueryResult.getNodes() exception 2021-02-22 00:41:40 UTC
Red Hat Issue Tracker SOA-2772 0 None None None Never

Internal Links: 780316

Description Aleksandar Kostadinov 2011-01-14 11:27:30 UTC
Affects: Release Notes
project_key: SOA

Hello, I'm running a test jsp program that inserts into the repository a *.csv file. Sequencer is extracting information but a subsequent query may result in a PathNotFoundException. My app is https://svn.devel.redhat.com/repos/jboss-qa/hudson/config_repository/resources/soa/modeshape/basic-repo-test.war/sequencer_csv.jsp (rev 13867)

Exception I'm getting is:
{code}
javax.servlet.ServletException: javax.jcr.PathNotFoundException: Unable to find "{}sequenced/{}text/{}delimited/{}myfile.csv/{http://www.modeshape.org/sequencer/text/1.0}row[2]/{http://www.modeshape.org/sequencer/text/1.0}column[2]"; lowest existing path is "/{}sequenced/{}text"
{code}

I have tried jcrSession.refresh(true); before the full-text search with no success. Thread.sleep(15000) helped tough. So it seems the node is created and found by the full-text search but not yet all its parents created?

Comment 1 John Graham 2011-01-14 14:13:03 UTC
Triage on 1/14: release note item

Comment 2 Van Halbert 2011-01-14 15:28:18 UTC
Release Notes Docs Status: Added: Documented as Known Issue
Release Notes Text: Added: The sequencing is done in a separate thread (right away after the session is saved from uploading the content).  And after the sequencing saves it's content, the indexing thread runs.    Therefore, depending on how slow the box is, the user may have to wait several seconds before the full-text search will find the related data.


Comment 3 Aleksandar Kostadinov 2011-01-14 15:44:14 UTC
The problem is not that items are not found but that the item is found before all its parents are created which results in an exception.

I have a guess that the fix for SOA-2722 will hide that away but it looked to me strange that the nod is found by the search an path to it is not existing.

Comment 4 Aleksandar Kostadinov 2011-01-16 17:22:20 UTC
I have tested ER7 thoroughly and cannot reproduce this problem. If you believe order of creating of nodes by sequencers doesn't lead to any other issues feel free to close this JIRA issue.

Thank you.

Comment 5 Aleksandar Kostadinov 2011-01-16 17:22:20 UTC
Link: Added: This issue related SOA-2722


Comment 6 Aleksandar Kostadinov 2011-01-17 05:42:25 UTC
I also notice another interesting behavior that's worth looking at.

{code}
      ftsResult = ftsQuery.execute();

      // wait for data to be sequenced
      for (int i = 0; i <= 100; i++) {
         ir = ftsResult.getRows();
         out.println("iteration: " + i);
         if (ir.hasNext()) break;
         if (i == 100) throw new ServletException("10 seconds not enough to sequence the file");
         Thread.sleep(100);
      }
{code}

As you see from the code above (yes, I made a mistake), I execute query just once before the loop. My application output shows that the check succeeds after a few iterations of the loop. So it seems like after awhile getRows() and getNodes() return a different result than initially. I think that this is a consequence of the changes from SOA-2722.

From what I see things happen like:
1. File node inserted into repo.
2. data is sequenced and inserted into repo but still not all parent nodes of sequenced data created (or some other inconsistency?)
3. My query finds the sequenced data
4. queryResult.getNodes() returns nothing (because of SOA-2722 ?)
5. After awhile sequencer finally puts the sequenced data Nodes in a consistent state
5. queryResult.getNodes() starts returning nodes

Although JCR2 API anticipates an exception if getRows() or getNodes() is called for the second time on a QueryResult (http://www.day.com/maven/javax.jcr/javadocs/jcr-2.0/javax/jcr/query/QueryResult.html#getRows()), I don't think that is a problem for modeshape.
I don't have deep modeshape knowledge so I'd ask you to look and consider if this behavior could be problematic in some use cases, for example within transactions?

IMHO ideally all these possible cases where multiple threads are creating and querying data, should be covered by modeshape test cases perhaps with the help of www.jboss.org/byteman so operations ordering is well controlled.

Comment 7 Randall Hauch 2011-01-17 16:24:45 UTC
Interesting. The section 6.12.3 of the JCR 2.0 specification specifies the behavior that the QueryResult (row values and Node references) reflect the state of the transient session. Here's a quote from this section:

    "Regardless of which scope is used, 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: the item state will reflect any pending changes in transient 
    store of the Session. As a result, it is possible that an item returned as a match will not reflect the 
    state 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."

We don't have a problem with users calling getRows() more than once. I don't see anything in the specification about that restriction, but as you point out it is in the JavaDoc. I guess I'll log that as an issue with ModeShape and change the code to throw the exception. Unfortunately there is no 'close()' mechanism on the QueryResult; that should really be the signal that you can't call methods on the result set. Barring that, throwing the exception as described in the JavaDoc is probably the only way to prevent accidental errors like yours.


Comment 8 Aleksandar Kostadinov 2011-01-18 08:17:13 UTC
I think I understand. I also read the query and queryresult sections in the spec and I don't see anything modeshape violates specification with, so please consider this issue *not* a blocker for SOA-P.

I hope though to have modeshape behavior covered by test cases in the upstream project (if not already done) so any changes in behavior (although non violating the specification) wont go unnoticed and will be communicated to modeshape/SOA-P users. If you like I can file a MODE-* jira issue for that.

Thank you for looking into this!

Comment 9 Randall Hauch 2011-01-18 15:05:23 UTC
I understand about this not being a blocker.

I would love to have additional test cases in the upstream project, so if you have any to contribute, please let us know by logging an issue and providing the tests. If possible, add them to the codebase yourself (see the instructions on http://community.jboss.org/wiki/ModeShapeDevelopmentWorkflow for details on how to contribute).

Comment 10 Anne-Louise Tangring 2011-01-20 17:18:43 UTC
Affects: Added: [Release Notes]



Note You need to log in before you can comment on or make changes to this bug.