Search code examples
javaarcadedb

One Thread Using Multiple RemoteDatabase Object


I use OrientDD and exploring ArcadeDB. I have gone through Java APi (Remote) and understand that that a RemoteDatabase object is not thread safe.

Also as I understand from the source code of RemoteDatabase, a session is initialized when the begin() is called and closed when the commit() is called.

Also I understand that ArcadeDB uses thread local for some purpose but could not find any documentation related to that.

My question is if a thread used more than one RemoteDatabase and calls the begin/commit separately, is there any implication from thread local perspective.

In OrientDB if a thread uses more than one ODatabaseSession, then activateOnCutrrent() thread needs to be called before again using the first session due to thread local reference setting. I didn't find any method equivalent to activateOnCurrent thread.

Is there any thread local level implication in ArcadeDB to use more than one RemoteDatabase in one thread.


Solution

  • In ArcadeDB the RemoteDatabase is not threadsafe. It's designed to be used by one thread only. You can have N RemoteDatabase objects, one per thread, or you can pool them.

    The RemoteDatabase API doesn't use ThreadLocal. That's used only in the LocalDatabase implementation.

    I understand probably it would be better to have one uniform API, namely making RemoteDatabase thread-safe by using ThreadLocal like with the LocalDatabase API. If this is the case for you, please open a new issue on ArcadeDB GitHub. For now, using one instance per thread is the right way to go.