noamt / elasticsearch-grails-plugin

The revived ElasticSearch grails plugin
Based on Graeme Rocher initial stub. Note that it is still in early stage.
Other
63 stars 83 forks source link

LazyInitializationException when saving a entity #59

Open sergiofm opened 10 years ago

sergiofm commented 10 years ago

Hi! Im my system, I have a job that start some threads to update entitys and in some entitys elasticsearch plugin is throwing a LazyInitializationException like the log below. Any ideas what could cause this? My guess is that other thread is closing that session before IndexRequestQueue realize the marshall of the instance. Is there a way to force IndexRequestQueue to start a new session if the session is allready closed?

Thanks very mutch.

2014-10-15 19:28:34,360 [elasticsearch[Uatu][transport_client_worker][T#4]{New I/O worker #4}] ERROR index.IndexRequestQueue  - Error Indexing class br.com.fofertas.Produto (index: br.com.fofertas , type: produto) of id 67379
Message: Failed to marshall domain instance [Produto: Macacão Baby Natural Zig Mundi]
    Line | Method
->>  107 | toJSON                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    148 | doCall                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue$_executeRequests_closure1
|    142 | executeRequests . . . . . .  in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    322 | push                         in org.grails.plugins.elasticsearch.index.IndexRequestQueue$OperationBatch
|    281 | onResponse . . . . . . . . . in     ''
|    131 | executeListener              in org.elasticsearch.action.support.AbstractListenableActionFuture
|    103 | done . . . . . . . . . . . . in     ''
|    162 | set                          in org.elasticsearch.common.util.concurrent.BaseFuture
|     98 | onResponse . . . . . . . . . in org.elasticsearch.action.support.AdapterActionFuture
|    338 | finishHim                    in org.elasticsearch.action.bulk.TransportBulkAction$2
|    308 | onResponse . . . . . . . . . in     ''
|    301 | onResponse                   in     ''
|    462 | handleResponse . . . . . . . in org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$2
|    448 | handleResponse               in     ''
|    158 | handleResponse . . . . . . . in org.elasticsearch.transport.netty.MessageChannelHandler
|    127 | messageReceived              in     ''
|     70 | handleUpstream . . . . . . . in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream                 in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived          in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode                   in     ''
|    303 | messageReceived . . . . . .  in     ''
|     70 | handleUpstream               in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream                 in     ''
|    268 | fireMessageReceived . . . .  in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived          in     ''
|     88 | read . . . . . . . . . . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process                      in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run                          in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run                          in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker                    in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run                          in java.lang.Thread
Caused by LazyInitializationException: could not initialize proxy - no Session
->>  150 | doCall                       in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory$_buildJSON_closure3
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    148 | buildJSON                    in org.grails.plugins.elasticsearch.conversion.JSONDomainFactory
|    105 | toJSON . . . . . . . . . . . in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    148 | doCall                       in org.grails.plugins.elasticsearch.index.IndexRequestQueue$_executeRequests_closure1
|    142 | executeRequests . . . . . .  in org.grails.plugins.elasticsearch.index.IndexRequestQueue
|    322 | push                         in org.grails.plugins.elasticsearch.index.IndexRequestQueue$OperationBatch
|    281 | onResponse . . . . . . . . . in     ''
|    131 | executeListener              in org.elasticsearch.action.support.AbstractListenableActionFuture
|    103 | done . . . . . . . . . . . . in     ''
|    162 | set                          in org.elasticsearch.common.util.concurrent.BaseFuture
|     98 | onResponse . . . . . . . . . in org.elasticsearch.action.support.AdapterActionFuture
|    338 | finishHim                    in org.elasticsearch.action.bulk.TransportBulkAction$2
|    308 | onResponse . . . . . . . . . in     ''
|    301 | onResponse                   in     ''
|    462 | handleResponse . . . . . . . in org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$2
|    448 | handleResponse               in     ''
|    158 | handleResponse . . . . . . . in org.elasticsearch.transport.netty.MessageChannelHandler
|    127 | messageReceived              in     ''
|     70 | handleUpstream . . . . . . . in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream                 in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    791 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext
|    296 | fireMessageReceived          in org.elasticsearch.common.netty.channel.Channels
|    462 | unfoldAndFireMessageReceived in org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder
|    443 | callDecode                   in     ''
|    303 | messageReceived . . . . . .  in     ''
|     70 | handleUpstream               in org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler
|    564 | sendUpstream . . . . . . . . in org.elasticsearch.common.netty.channel.DefaultChannelPipeline
|    559 | sendUpstream                 in     ''
|    268 | fireMessageReceived . . . .  in org.elasticsearch.common.netty.channel.Channels
|    255 | fireMessageReceived          in     ''
|     88 | read . . . . . . . . . . . . in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | process                      in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    318 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector
|     89 | run                          in org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker
|    178 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.channel.socket.nio.NioWorker
|    108 | run                          in org.elasticsearch.common.netty.util.ThreadRenamingRunnable
|     42 | run . . . . . . . . . . . .  in org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1
|   1145 | runWorker                    in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    724 | run                          in java.lang.Thread
zhuravskiy commented 9 years ago

+1 when i call elasticSearchService?.index(domain) on some domain instances happen same problem, are session is bound to thread?

priyanshuch commented 9 years ago

Hey, I'm working with mongodb and I'm having the same problem Failed to marshall domain instance. Did anyone solve it, yet?