wisdom-framework / wisdom-orientdb

Wisdom OrientDB integration
Apache License 2.0
2 stars 3 forks source link

Connection pool issue after a lot of request #25

Closed hboumedane closed 9 years ago

hboumedane commented 9 years ago

I have an application with orientdb db and when running this application I got an exception after a period of time it depend on the number of request excuted against the DB

ODatabaseException: Database instance has been released to the pool. Get another database instance from the pool with the right username and password.

they talk about this issue here : https://github.com/orientechnologies/orientdb/issues/3529

A suggestion would be to upgrade the orientdb version inside the plugin to use the latest version ?!

barjo commented 9 years ago

Thanks! I Definitively need to update to the last stable version because of that, and check that we use the latest pool implementation.

barjo commented 9 years ago

@hboumedane I just update the dependencies, let me know if it solve your problem :+1: :bow:

hboumedane commented 9 years ago

Ok, i well let you know soon

hboumedane commented 9 years ago

after two day of running , I got the exception today :-(

barjo commented 9 years ago

:( Could you put your stack trace here?

hboumedane commented 9 years ago

unfortunately I lost it but I will upload it when it will happen again

hboumedane commented 9 years ago

here the exception

com.orientechnologies.orient.core.exception.ODatabaseException: Database instance has been released to the pool. Get another database instance from the pool with the right username and password
at com.orientechnologies.orient.object.db.OObjectDatabaseTxPooled.checkOpeness(OObjectDatabaseTxPooled.java:137)
at com.orientechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:219)
at com.orientechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:211)
at com.orie
ntechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:204)
    at org.wisdom.orientdb.runtime.OrientDbCrudService.findOne(OrientDbCrudService.java:140)
    at org.wisdom.orientdb.object.OrientDbCrud$$Proxy.findOne(Unknown Source)
    at table.TableWampController.__M_closeCommand(TableWampController.java:134)
    at table.TableWampController.closeCommand(TableWampController.java)
    at table.TableWampController.__M_onMessage(TableWampController.java:75)
    at table.TableWampController.onMessage(TableWampController.java)
    at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.wisdom.router.DefaultWebSocketCallback.invoke(DefaultWebSocketCallback.java:206)
    at org.wisdom.router.WebSocketRouter$1.__M_call(WebSocketRouter.java:212)
    at org.wisdom.router.WebSocketRouter$1.call(WebSocketRouter.java)
    at org.wisdom.router.WebSocketRouter$1.__M_call(WebSocketRouter.java:208)
    at org.wisdom.router.WebSocketRouter$1.call(WebSocketRouter.java)
    at org.wisdom.executors.Task$EnhancedCallable.call(Task.java:251)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
``
barjo commented 9 years ago

Thanks for the feedback. It seems that we call an instance of the db that has already been released to the pool. There may be a bug in the OrientDbCrudService implementation.

hboumedane commented 9 years ago

Are you executing a transaction, or managing the transaction yourself?

 ODatabaseDocumentTx underlyingDatabase = ODatabaseDocumentPool.global().acquire(dbName, dbUser, dbPassword);

I changed to this because the first one is Deprecated and my be was the source of the problem :

ODatabaseDocumentTx underlyingDatabase = new OPartitionedDatabasePool(dbName, dbUser, dbPassword).acquire();

now i will test and let you kwon if the exception will appear again

hboumedane commented 9 years ago

Today i got the same execption and here the full stack :

13:55:17.365 489023 [vert.x-eventloop-thread-0] ERROR wisdom-error - An exception occurred while processing request POST /api/event
com.orientechnologies.orient.core.exception.ODatabaseException: Database instance has been released to the pool. Get another database instance from the pool with the right username and password
    at com.orientechnologies.orient.object.db.OObjectDatabaseTxPooled.checkOpeness(OObjectDatabaseTxPooled.java:137) ~[na:na]
    at com.orientechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:219) ~[na:na]
    at com.orientechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:211) ~[na:na]
    at com.orientechnologies.orient.object.db.OObjectDatabaseTx.browseClass(OObjectDatabaseTx.java:204) ~[na:na]
    at org.wisdom.orientdb.runtime.OrientDbCrudService.findAll(OrientDbCrudService.java:164) ~[na:na]
    at org.wisdom.orientdb.object.OrientDbCrud$$Proxy.findAll(Unknown Source) ~[na:na]
    at filters.BasicAuthFilter.__M_call(BasicAuthFilter.java:73) ~[na:na]
    at filters.BasicAuthFilter.call(BasicAuthFilter.java) ~[na:na]
    at org.wisdom.api.interception.RequestContext.proceed(RequestContext.java:124) [wisdom-api-0.9.1.jar:na]
    at org.wisdom.error.DefaultPageErrorHandler.__M_call(DefaultPageErrorHandler.java:236) [default-error-handler-0.9.1.jar:na]
    at org.wisdom.error.DefaultPageErrorHandler.call(DefaultPageErrorHandler.java) [default-error-handler-0.9.1.jar:na]
    at org.wisdom.api.interception.RequestContext.proceed(RequestContext.java:124) [wisdom-api-0.9.1.jar:na]
    at org.wisdom.monitor.extensions.dashboard.HttpMetricFilter.call(HttpMetricFilter.java:126) [org.wisdom.framework.wisdom.monitor-0.9.1.jar:na]
    at org.wisdom.api.interception.RequestContext.proceed(RequestContext.java:124) [wisdom-api-0.9.1.jar:na]
    at org.wisdom.router.RouteDelegate.invoke(RouteDelegate.java:247) [router-0.9.1.jar:na]
    at org.wisdom.framework.vertx.HttpHandler.invoke(HttpHandler.java:173) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.wisdom.framework.vertx.HttpHandler.dispatch(HttpHandler.java:146) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.wisdom.framework.vertx.HttpHandler.access$200(HttpHandler.java:51) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.wisdom.framework.vertx.HttpHandler$2.handle(HttpHandler.java:105) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:27) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.VoidHandler.handle(VoidHandler.java:24) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.DefaultHttpServerRequest.handleEnd(DefaultHttpServerRequest.java:334) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.ServerConnection.handleEnd(ServerConnection.java:209) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.ServerConnection.processMessage(ServerConnection.java:313) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.ServerConnection.handleMessage(ServerConnection.java:94) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.DefaultHttpServer$ServerHandler.doMessageReceived(DefaultHttpServer.java:710) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.DefaultHttpServer$ServerHandler.doMessageReceived(DefaultHttpServer.java:600) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:72) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at org.vertx.java.core.net.impl.VertxHandler.channelRead(VertxHandler.java:155) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at org.vertx.java.core.http.impl.cgbystrom.FlashPolicyHandler.channelRead(FlashPolicyHandler.java:53) [wisdom-vertx-engine-0.9.1.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
    at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) [netty-common-4.0.27.Final.jar:4.0.27.Final]
barjo commented 9 years ago

Sorry for the long delay, I was on business trip last week. I seems to be related to a concurrent access to findAll. If you are calling it from a thread you create yourself, can you put it in a synchronize blocked?. The implementation is not Thread safe.

hboumedane commented 9 years ago

thanks for the tips, and yes I was calling findAll from an http filter so it was not protected against concurrent access. I did manage to protect it and i will let you know if I still have this exception

barjo commented 9 years ago

Hey, does the exception still occurred, or is it alright ?

barjo commented 9 years ago

@hboumedane Any update on this issue?

hboumedane commented 9 years ago

it's seem that's the issue was corrected and right now I don't see it any more, so yes you can close this issue for now... thanks for your help

barjo commented 9 years ago

@hboumedane Thanks :smile: