Hi Vladimir, You would need in each thread instance before accessing the database to set this:
ODatabaseRecordThreadLocal.INSTANCE.set( database ); -Colin Orient Technologies The Company behind OrientDB On Monday, March 30, 2015 at 8:20:53 PM UTC-5, Vladimir Leberstein wrote: > > > Hi! > > *Short question: * > Is it save to span *ODatabaseDocumentTx* transaction across multiple > threads under the guarantee that only one thread is running simultaneously? > > *Long story:* > I'm using embedded OrientDb 2.1-SNAPSHOT server inside Akka 2.3.9 project. > Each transaction is represented as a separate Session actor and all > OrientDb interactions happen inside *scala.concurrent.Future*(because > OrientDb API is blocking) so ODatabaseDocumentTx instance is not bound to > any specific thread, but to specific actor. Moreover *ODatabaseDocumentTx* > instance method calls(including *begin()* and *commit()*) can happen from > any number of different threads(because of *scala.concurrent.Future*) but > under the guarantee that no more than one *ODatabaseDocumentTx* instance > method is executing at the same time. The documentation > <http://www.orientechnologies.com/docs/last/Java-Multi-Threading.html> > states that "OrientDB supports multi-threads access to the database. > ODatabase* and OrientGraph* instances are not thread-safe, so you've to > get *an instance per thread* and each database instance can be used *only > in one thread per time*." but I'm not sure that this also applies to > transactions because OrientDb uses ThreadLocals and all those interactions > are not very clear to me yet. > > Any help would be greatly appreciated. Thanks in advance! > -- --- You received this message because you are subscribed to the Google Groups "OrientDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
