-->
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.  [ 2 posts ] 
Author Message
 Post subject: FlushMode.MANUAL leads to LazyInit errors when indexing
PostPosted: Wed Dec 15, 2010 9:59 pm 
Beginner
Beginner

Joined: Fri Jan 29, 2010 8:17 pm
Posts: 20
Location: Portland OR
Whenever I set a session to FlushMode.MANUAL, it leads to lazy initialization exceptions when Hibernate Search goes to queue indexing work.

The basic flow of the code is:
1. beginTransaction
2. set flush mode to manual
3. do work: Which is a series of multiple validation queries + inserts/updates
4. flush and clear the session(doesn't matter if I also do a fullTextSession.flushToIndexes or not). To be quite clear I'm doing:
//FullTextSession fts = new FullTextSession(sees);
//fts.flushToIndexes() <=== happens whether or not I do this
sess.flush();
sess.clear();
5. Commit the transaction

This looks like either something that isn't supported by search, or a bug. For this use case, bulk import of data, I really need to be able to set the flush mode to manual as the 'work' does a lot of queries for validation, which destroys batching benefits, and we know its OK to disable auto-flushing since we don't expect any new or updated entities to match the queries.

As far as versions of search/core/annotations I have:
Maven deps are:
hibernate-search: 3.2.1.Final
hibernate-entitymanager: 3.5.6

I've tried this with both async, with the worker thread/in memory queue option, and sync indexing modes. Both behave the same.

The stack trace I'm seeing, that causes the transaction to fail, is:
Daemon Thread [ImportThread_ImportTaskID_53] (Suspended (exception LazyInitializationException))
JavassistLazyInitializer(AbstractLazyInitializer).initialize() line: 167
JavassistLazyInitializer(AbstractLazyInitializer).getImplementation() line: 215
DocumentBuilderIndexedEntity<T>.unproxy(Object) line: 533
DocumentBuilderIndexedEntity<T>.buildDocumentFields(Object, Document, PropertiesMetadata, Map<String,String>, Set<String>) line: 425
DocumentBuilderIndexedEntity<T>.buildDocumentFields(Object, Document, PropertiesMetadata, Map<String,String>, Set<String>) line: 484
DocumentBuilderIndexedEntity<T>.buildDocumentFields(Object, Document, PropertiesMetadata, Map<String,String>, Set<String>) line: 484
DocumentBuilderIndexedEntity<T>.buildDocumentFields(Object, Document, PropertiesMetadata, Map<String,String>, Set<String>) line: 484
DocumentBuilderIndexedEntity<T>.getDocument(T, Serializable, Map<String,String>) line: 414
DocumentBuilderIndexedEntity<T>.createAddWork(Class<T>, T, Serializable, String, boolean) line: 364
DocumentBuilderIndexedEntity<T>.addWorkToQueue(Class<T>, T, Serializable, WorkType, List<LuceneWork>, SearchFactoryImplementor) line: 348
BatchedQueueingProcessor.addWorkToBuilderQueue(List<LuceneWork>, Work<T>) line: 264
BatchedQueueingProcessor.processWorkByLayer(List<Work>, int, List<LuceneWork>, Layer) line: 251
BatchedQueueingProcessor.prepareWorks(WorkQueue) line: 149
PostTransactionWorkQueueSynchronization.beforeCompletion() line: 85
EventSourceTransactionContext$DelegateToSynchronizationOnBeforeTx.doBeforeTransactionCompletion(SessionImplementor) line: 159
ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion() line: 533
ActionQueue.beforeTransactionCompletion() line: 210
SessionImpl.beforeTransactionCompletion(Transaction) line: 563
JDBCContext.beforeTransactionCompletion(Transaction) line: 229
CacheSynchronization.beforeCompletion() line: 96
Sync2Sync.beforeCompletion() line: 73
TxActiveStateHandler(TransactionStateHandler).commit() line: 253
CompositeTransactionImp.doCommit() line: 511
CompositeTerminatorImp.commit() line: 138
TransactionImp.commit() line: 317
TransactionManagerImp.commit() line: 613
UserTransactionImp.commit() line: 168
JtaTransactionManager.doCommit(DefaultTransactionStatus) line: 1009
JtaTransactionManager(AbstractPlatformTransactionManager).processCommit(DefaultTransactionStatus) line: 754
JtaTransactionManager(AbstractPlatformTransactionManager).commit(TransactionStatus) line: 723
SpringTxUtil.commit(TransactionStatus, PlatformTransactionManager) line: 49

Any known issues around manual flush mode with regards to indexing?


Top
 Profile  
 
 Post subject: Re: FlushMode.MANUAL leads to LazyInit errors when indexing
PostPosted: Thu Dec 16, 2010 5:47 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
I am not sure exactly what's going on. It would be great to see the annotated entity and the exact code you execute between the session open and close. A complete test case would even be better ;-)
Given that the error is a LazyInitializationException i assume your indexed entity contains some lazy loaded associations. It is important that in this case the session is still active when the indexing occurs.
You can also try to upgrade to Search 3.3.0.Final which just got released recently (using Core 3.6 though). Even if it does not fix your problem you would get a lot of bug fixes and performance improvements.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.