-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Master/Slave: When updating an entity get an exception
PostPosted: Fri Oct 02, 2009 2:11 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

I have a master slave configuration set up and when I create the entity for the first time all is ok. However if try to update the entity before the master has copied to the local i get the following exception:

Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.amin.test.Project#253557]
   at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:409)
   at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:108)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:97)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
   at org.hibernate.Hibernate.getClass(Hibernate.java:364)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:622)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedIn(DocumentBuilderContainedEntity.java:590)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:564)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.addWorkToBuilderQueue(BatchedQueueingProcessor.java:162)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.processWorkByLayer(BatchedQueueingProcessor.java:140)
   at org.hibernate.search.backend.impl.BatchedQueueingProcessor.prepareWorks(BatchedQueueingProcessor.java:128)
   at org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization.flushWorks(PostTransactionWorkQueueSynchronization.java:69)
   at org.hibernate.search.backend.impl.TransactionalWorker.flushWorks(TransactionalWorker.java:78)


I'm not sure why I should be getting this exception when updating the entity. Project is an embedded object inside the @Indexed entity.

Apologies for asking so many questions. Final thing left now.

Cheers


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Sat Oct 03, 2009 7:20 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Just to add:

I am noticing that with jms backend i'm getting an entry in the local index when the refresh time is 30mins. This shouldn't happen right? Presumbly i shouldn't see anything until 30mins when the master copies changes to the local.

Cheers
Amin


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Sun Oct 04, 2009 8:16 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello amin-mc,

Quote:
However if try to update the entity before ...

What do you mean with "to update", just changing it through Hibernate ?

Quote:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists

This means Hibernate didn't find the object in the DB, this is unrelated with the index setup. As you're using the master/slave approach for indexes, please verify the two servers are sharing the same Database!
Would it be possible that you're doing several delete/inserts on the same object ID ? You're pointing me to a design knot which might have a problem, but it's just a theoretic idea in my mind: your issue could be the proof that it's real.

Quote:
Apologies for asking so many questions. Final thing left now.

No problem, you're also being helpful to other users, that's very nice and gives us more time to help you and work on next version's cool features.
Also we need people to report problems, even if it's only the Docs which need to be more clear on some points ;-)

Quote:
I am noticing that with jms backend i'm getting an entry in the local index when the refresh time is 30mins. This shouldn't happen right? Presumbly i shouldn't see anything until 30mins when the master copies changes to the local.

No this should' happen consistently, but it might occur if your update happens just before the timer trigger. I'd check the configuration to see if you're really using JMS, enable some logging.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Sun Oct 04, 2009 10:53 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

Thanks for your reply. I appreciate your reply and I'm hoping that by going through my issues I can help out other users.

Quote:
What do you mean with "to update", just changing it through Hibernate ?


Yes I initially created the entry using hibernate with JMS indexing backend and then when I subsequently tried to update the same entity I get the exception that I mentioned. One thing I guess I forgot to mention that I didn't have the master indexer running. I just wanted to see if the slave node could connect to JMS. I was looking around the forums and found that I need to be runnign my master first. I will try that again tomorrow (Monday) and it may be that it was my mistake. This exception occurs with the project at work.

Quote:
Would it be possible that you're doing several delete/inserts on the same object ID ? You're pointing me to a design knot which might have a problem, but it's just a theoretic idea in my mind: your issue could be the proof that it's real.


I'm not sure but it may be the case. Our domain model is so complex and we have creation done via hibernate and raw jdbc. Is there anything I can do to verify what you mention?

Quote:
No this should' happen consistently, but it might occur if your update happens just before the timer trigger. I'd check the configuration to see if you're really using JMS, enable some logging.

I'm not sure I follow. I presume no updates/creates will be done on the local index if I have the jms backend. If what you mention happens will this not be an issue with locks? I know I have JMS set up because I can see my master consuming the message. Just to mention that I have a sample project that I am working at home which I test stuff out. So the issue with local indexes being updated is a seperate issue from the excepiton that I posted. Hope i don't confuse people.

thanks again for your help. I owe you guys a drink after this project!


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Sun Oct 04, 2009 11:36 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
About the first problem, the exception means the node throwing it (the master right?) didn't find the object on the database; I didn't understand if you're seeing this on the Master, as you say it was not running? Forget the issue I was thinking about, I was wrong.

amin-mc wrote:
Quote:
No this should' happen consistently, but it might occur if your update happens just before the timer trigger. I'd check the configuration to see if you're really using JMS, enable some logging.

I'm not sure I follow. I presume no updates/creates will be done on the local index if I have the jms backend. If what you mention happens will this not be an issue with locks? I know I have JMS set up because I can see my master consuming the message.

Let's say your index is copied from master to slave every 30 minutes, like at 7:00, 7:30, 8:00, ...
If you make an update on your slave at 7:29: 55 seconds, the change is sent to master, it's written in index. 10 seconds later, at 7:30:05 you do a local query and you see the result, because you just received an updated copy of the index. Better to follow?
This might happen during tests.. make sure you enable logging to know if you're testing the old index and when the new index is getting copied.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Sun Oct 04, 2009 12:44 pm 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Quote:
About the first problem, the exception means the node throwing it (the master right?) didn't find the object on the database; I didn't understand if you're seeing this on the Master, as you say it was not running? Forget the issue I was thinking about, I was wrong.

This exception is happening on the slave node. It occurs when I update the root entity via web front end. It's strange as I don't get this exception when running on normal backend (lucene). I think this exception is probably related to something I am doing wrong. I will run the master and perform this again (my guess is that it's something to do with my config).

Quote:
Let's say your index is copied from master to slave every 30 minutes, like at 7:00, 7:30, 8:00, ...
If you make an update on your slave at 7:29: 55 seconds, the change is sent to master, it's written in index. 10 seconds later, at 7:30:05 you do a local query and you see the result, because you just received an updated copy of the index. Better to follow?
This might happen during tests.. make sure you enable logging to know if you're testing the old index and when the new index is getting copied.

with this scenario what i did was see a message on the jms queue and the master insert into master directory. I then used Luke to see if the master had added the document to the index (which it did). I then subsequently checked the local index to make sure that there was no entry for the document that was added to the master. When doing this i found an entry in the local index. Again I will turn on logging and verify the local index entry is actually coming from the master, rather than a direct insert by the slave.

thanks.


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Mon Oct 05, 2009 5:55 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Hi

I am still seeing this exception:
Code:
org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.test.Layer#253564]
   at org.hibernate.impl.SessionFactoryImpl$2.handleEntityNotFound(SessionFactoryImpl.java:409)
   at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:108)
   at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:97)
   at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:140)
   at org.hibernate.Hibernate.getClass(Hibernate.java:364)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.processSingleContainedInInstance(DocumentBuilderContainedEntity.java:622)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.processContainedIn(DocumentBuilderContainedEntity.java:590)
   at org.hibernate.search.engine.DocumentBuilderContainedEntity.addWorkToQueue(DocumentBuilderContainedEntity.java:564)


I checked the database and there is a Layer with the id 253564. After looking at the code more I found that the exception occurs with

Code:
Class<T> valueClass = Hibernate.getClass( value ); of

private <T> void processSingleContainedInInstance(List<LuceneWork> queue, SearchFactoryImplementor searchFactoryImplementor, T value) {
      @SuppressWarnings("unchecked")
      Class<T> valueClass = Hibernate.getClass( value );
      DocumentBuilderIndexedEntity<T> builderIndexedEntity =
            searchFactoryImplementor.getDocumentBuilderIndexedEntity( valueClass );

      // it could be we have a nested @IndexedEmbedded chain in which case we have to find the top level @Indexed entities
      if ( builderIndexedEntity == null ) {
         DocumentBuilderContainedEntity<T> builderContainedEntity =
               searchFactoryImplementor.getDocumentBuilderContainedEntity( valueClass );
         if ( builderContainedEntity != null ) {
            processContainedIn( value, queue, builderContainedEntity.metadata, searchFactoryImplementor );
         }
      }
      else {
         addWorkForEmbeddedValue( value, queue, valueClass, builderIndexedEntity, searchFactoryImplementor );
      }
   }


Digging down into Hibernate.getClass() i found that it tries to find the class information and I'm not sure why it's doing a lookup for com.test.Layer#253564.

Ok just to add again..this happens when the value is a proxy as opposed to a real object.


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Mon Oct 05, 2009 11:11 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Apologies guys but it looks as though i can explain the situation better. Basically we have a Layer and LayerDetails object with the following mapping:
Code:
LayerDetails.hbm.xml

....

<one-to-one name="layer" class="Layer" constrained="true" access="field" />


Layer
<joined-subclass name="Layer" table="layer">
...

<many-to-one name="layerDetails" class="LayerDetails"
            column="layer_id" cascade="save-update" insert="false" update="false" foreign-key="layerId" not-found="ignore"/>

</joined-subclass>



The object mapping I have is:

Code:
Layer.java
    @IndexedEmbedded
    private LayerDetails layerDetails;
    ....

LayerDetails.java

@ContainedIn
    private Layer layer;
...


And so as a result I get the below exception. Hope that gives abit more exception or knowing my luck confused the situation even more! Any help would be appreciated.

Cheers


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Mon Oct 05, 2009 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi amin-mc,
please post all hibernate libs versions.
This happens ONLY when using JMS backend on the client side right? Could you also try the Lucene backend when put in async mode to confirm this?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Master/Slave: When updating an entity get an exception
PostPosted: Tue Oct 06, 2009 4:08 am 
Pro
Pro

Joined: Wed Oct 03, 2007 2:31 pm
Posts: 205
Quote:
Hi amin-mc,
please post all hibernate libs versions.
This happens ONLY when using JMS backend on the client side right? Could you also try the Lucene backend when put in async mode to confirm this?


The exception occurs when using both JMS and normal Lucene back end on the slave node. I am using the following:

hibernate-3.3.1.GA
hibernate-annotations 3.4.0.GA
hibernate search 3.1.1 GA (built from source using patch see viewtopic.php?f=9&t=999947)
hibernate-commons-annotation-3.1.0.GA

Thanks again for your help.

I just updated the following:

Code:
<one-to-one name="layer" class="Layer" constrained="true" access="field" />

to

<one-to-one name="layer" class="Layer" constrained="false" access="field" />



And this fixed the problem. I'm concerned that changing this might have a knock on effect else where in the system.
Cheers


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.