Open remi-parain opened 8 years ago
Hi, Thanks for the notice. This is definitively a bug of wisdom-orientdb, that's probably due to some change that has been made in the Orientdb threading and pool model (about 6 month ago... sorry) . I will have to refactor, it is also related to #33 Thanks for having try with different Orientdb version, the current snapshot is based on orientdb 2.1.3 and the release 0.3.0 on 2.1.2, however both should work with at least any version of Orientdb > 2.1.0 and < 2.2.0 (according to their versioning scheme)
For anyone concerned, we found a temporary workaround by removing the @Async annotation from Controllers. It seems to fix the issue.
In the current implementation, the db instance is attached to the thread that execute the controller. So when accessing a db instance in an Asynch block, the orientdb engine failed because the thread running the Asynch block is difference of the Thread on which the db instance has been attached.
This is kind of annoying because it blocks the threads. In the new version, this is critical (never ever blocks the event loop).
@cescoffier so they change this behavior since 2.1, and their previous pool implementation is now deprecated. So, for now, each time we call the crudservice, it will acquire a new instance from the pool and attached the instance to the current thread (as required by orientdb), at the end of the call, the db instance is closed and normally released to the pool. If you are in a transaction, it does the acquire on the first call and the close and release at the end of the transaction. So you cannot create thread that call this instance, within a transaction, that does sound fair :P So it's very important to configure well your db pool depending on your app. Now, orientdb provides a partitioned database pool with lock free capability.It is very important, because with such implementation if the connection pool is exhausted it won't wait, but throw an exception, you can even finely tune it to have a minimum connection number, a max connection number, and a max under high load number, so it will adapt up to this point. I will move to the new pool implementation and refactor what needs to be.
@barjo : the refactor sounds great ^^ when you say : "it's very important to configure well your db pool depending on your app" , where can i find those settings ? in the orientDB config file (I found : db.pool.min and db.pool.max properties) or elsewhere?
@remi-parain yes it is those properties.
I start to move to the PartitionPool, but I encounter some problems https://github.com/orientechnologies/orientdb/issues/4953 https://github.com/orientechnologies/orientdb/issues/5231
Basically, when the db has been closed we cannot call the proxy properly. Since the implementation of the CrudService required to open and close the db for each call (excepted if we are in a transaction) that cause trouble.
One workaround could be to refactor the Orientdb crud service and add a method close and a method open, that will be call by the dev.
Orientdb made an hotfix for this issue, I am half way through the refactoring. Everything should come together next week.
It's really good news! Thank you @barjo. And thanks to orientDB community's reactivity as well
Despite the bug fix from orientdb there is still some issue with the new pool. Once the db has been closed, we cannot get the Id of the previously retrieved object. This can cause an issue if for exemple you call getId()
after the db has been closed. In the current implementation of the OrientDBCrudService, we close the db after each call to it.
One workaround, could be not to close/release the db in each call, and add a method release to OrientdbCrudService contract. We could also have an Interceptor that automatically release the db at the end of each method (route) call.
WDYT?
I'm facing a recurrent issue using OrientDB in remote mode (not embedded ). I don't understand what happens, some queries just fails : one time it works, one time it doesn't, it seems to be random. I happens using OrientDbCrud built-in functions or custom queries.
There is only one instance of Wisdom server which access the DB. Both are on the same host. Each webservice use the @Async wisdom annotation.
I tested with orientDB version 2.1.0, 2.1.3 , 2.1.5 with the current (github) version of the wisdom-orientdb service.
Here is a stacktrace sample :
java code :
stacktrace :
Have anyone faced the same issue ?