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?
|