aleph

2017-07-14T22:12:21.258366Z

I have been wrestling with some kind of memory/reference leak using Aleph and JanusGraph in tandem

2017-07-14T22:12:33.261296Z

It looks like Aleph works fine on its own, and Janus works fine on its own

2017-07-14T22:12:55.266723Z

but when combined, memory increases without bounds

2017-07-14T22:13:11.270977Z

I have done some research and it looks like part of the problem is that Janus transactions are thread specific

2017-07-14T22:13:28.275301Z

So, if a transaction is opened on a thread, it must be closed on that same thread

2017-07-14T22:15:03.298937Z

I'm wondering how do I even debug this problem?

2017-07-14T22:16:04.314175Z

For instance, I am doing this

(stream/on-drained
     source
     (fn []
       (log/debug "query complete")
       (db/commit graph)
       (db/rollback graph)))

2017-07-14T22:16:33.321596Z

But how do I guarantee this function is being called on the same thread that the transaction was opened on?

2017-07-14T22:17:05.329304Z

Do the on-drained callbacks always get called from the same thread that the handler is using?

2017-07-14T22:17:25.333814Z

If not, how do I ensure they do?

danielcompton 2017-07-14T23:10:32.042739Z

@spangler I'm not exactly sure, but http://aleph.io/manifold/execution.html might be helpful

danielcompton 2017-07-14T23:11:17.051068Z

http://docs.janusgraph.org/latest/tx.html

danielcompton 2017-07-14T23:11:37.054879Z

> Almost all interaction with JanusGraph is associated with a transaction. JanusGraph transactions are safe for concurrent use by multiple threads. Methods on a JanusGraph instance like graph.v(...) and graph.commit() perform a ThreadLocal lookup to retrieve or create a transaction associated with the calling thread. Callers can alternatively forego ThreadLocal transaction management in favor of calling graph.newTransaction(), which returns a reference to a transaction object with methods to read/write graph data and commit or rollback. I think that might be what you need to do?

2017-07-14T23:18:41.131768Z

@danielcompton Thank you! I now have some leads to follow. I will report back work how it turns out.

2017-07-14T23:29:16.242683Z

So do you know if in general the ondrained callback is called in the same thread as the handler?

2017-07-14T23:29:36.245806Z

I sort of assume not