Issue when running in parallel requests on version 2.2.33

#1
       ODatabaseDocumentTx oDatabaseDocumentTx = new ODatabaseDocumentTx(String.format("remote:%s:32360/%s", host, dbName));
        oDatabaseDocumentTx.setProperty("minPool", 2);
        oDatabaseDocumentTx.setProperty("maxPool", 10);
        oDatabaseDocumentTx.open(user, pass);

This is the exception retrieved:

>     com.orientechnologies.orient.core.exception.ODatabaseException: Cannot execute the request because an asynchronous operation is in progress. Please use a different connection
>     	DB name="staging"
>     	at com.orientechnologies.orient.client.remote.OStorageRemote.baseNetworkOperation(OStorageRemote.java:220)
>     	at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperationRetry(OStorageRemote.java:203)
>     	at com.orientechnologies.orient.client.remote.OStorageRemote.networkOperation(OStorageRemote.java:214)
>     	at com.orientechnologies.orient.client.remote.OStorageRemote.command(OStorageRemote.java:1185)
>     	at com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(OCommandRequestTextAbstract.java:69)

When I run in sequential mode all the requests it works as expected.

#2

Hi @blidiselalin

ODatabaseDocumentTx it’s not thread safe. It can be used only in 1 thread at time.

You should use a pool of databases instead

See here for 3.0.3

https://orientdb.com/docs/3.0.x/java/Document-API-Database.html

and also here

http://orientdb.com/docs/2.2.x/Java-Multi-Threading.html

#3

Hi @wolf4ood,

Thanks for the input, right now we are doing the transition to latest stable version of orientdb 3.0.18 and in this case we will use the connection pool like it is defined in the documentation steps.

OrientDB orientDB = new OrientDB("remote:localhost","root","root_passwd",OrientDBConfig.defaultConfig());
ODatabasePool pool = new ODatabasePool(orientDB,"test","admin","admin");
// OPEN DATABASE
try (ODatabaseSession db = pool.acquire()) {
   // YOUR CODE
   ...
}
pool.close();
orientDB.close();

Thanks, Alin