[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-88) Workspace.getIndexReader AssertionFailure: Tries to read for update a index while a writer is accessed

Charles Chappell (JIRA) noreply at atlassian.com
Fri Jun 22 01:16:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27305 ] 

Charles Chappell commented on HSEARCH-88:
-----------------------------------------

I first thought the NPE was the cause, and triggering something bad in the Hibernate Search libraries.  It turns out this is not the case, and the NPE was actually coming from my code as a result of a EntityManager.find operation failing due to some connection to this issue.  (I still haven't isolated why that happened... this demo works fine EXCEPT

During simplification of the problem, I isolated the NPE out of the equation, and that's just my fault, and doesn't seem related.

I had thought the NPE in my code was causing an early EJB return or closure, which was interrupting the Hibernate Search Indexing, and causing this problem.  That's why I brought it up, but this does not seem to be the case.

My test case has very few problems compared to what's happening in my production code, and I'll complicate the test case as I go to expose the variety of cases I'm seeing this in my code with, but my guess is that if this simple case can be solved, the more complex interactions I'm seeing in my other code will go away.

In my EJB code, I'm using EntityManager with automatic transactions, so the code is a bit different between the two.  If I remove the transactions from around the find() EntityManager calls, the Assertion Failure dissappears.

------------------------
I was able to simplify into a single test case instead of running things in a loop, and isolated the cause.
It seems like JTA does the latter automatically from my EJB setup, and so I cannot control this in the same way inside the EJB that I did in this test case.  In any event, this probably needs to be fixed:

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet NewServlet</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<pre>");
        String adminName = "admin - " + String.valueOf(new Date().getTime());
        try {
            utx.begin();
            out.println("Persisting new login bean and associated owner...");
            Person owner = new Person(null,"Admin");
            owner = em.merge(owner);
            em.persist(new Login(owner,adminName,"nothing"));
            utx.commit();
            Login l = null;

            // This is fine
            l = em.find(Login.class,adminName);
            
            out.println("Got Login: " + l);
            out.println("Got Person: " + l.getOwner());

            
            // This causes an assertion failure
            utx.begin();
            l = em.find(Login.class,adminName);
            utx.commit();
                    
            out.println("Got Login: " + l);
            out.println("Got Person: " + l.getOwner());

            if (l != null)
            {

                try {
                    utx.begin();
                    l = em.merge(l);
                    em.remove(l);
                    em.remove(l.getOwner());
                } catch (Exception ex) {
                    ex.printStackTrace();
                } finally {
                    utx.commit();
                }
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
        out.println("</pre>");
        out.println("</body>");
        out.println("</html>");
        
        out.close();
    }

> Workspace.getIndexReader AssertionFailure: Tries to read for update a index while a writer is accessed
> ------------------------------------------------------------------------------------------------------
>
>                 Key: HSEARCH-88
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-88
>             Project: Hibernate Search
>          Issue Type: Bug
>    Affects Versions: 3.0.0.beta3
>         Environment: Hibernate 3.2.4.sp1, PostGRESQL
>            Reporter: Charles Chappell
>            Priority: Minor
>         Attachments: Login.java, testcase.tar.gz
>
>
> May be an application server interaction.
> Somewhat sporatic, but always in the same places in my code.  Basically I had one class that created an entity exit via NullPointerException, (Database updates were successful) and a second attempt to read the same data was made, and failed due to this assertion.  The only connection to Hibernate Search is via the Annotations/Runtime, nowhere in this process did I directly use Hibernate Search.
> I'll attempt to produce test code, since this is the simplest case that I've gotten this assertion failure in.
> Application Server is Glassfish, reproducable both on OSX and Solaris 10 Intel.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list