clojurewerkz / titanium

Clojure graph library built on top of Titan

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot access element because its enclosing transaction is closed and unbound

rrichardson opened this issue · comments

What am I doing wrong?

(def home (first (tg/transact! (tv/upsert! :roomname {:roomname "Home"
                                                :shortdesc "You find yourself in a bizarre town square"}}))))

(def users (first (tg/transact! (tv/upsert! :username {:username "Root" :type "root"}))))
(def connection (first (tg/transact! (te/upconnect! (tv/refresh users) :in (tv/refresh home)))))

clojuremud.core> connection
#<StandardEdge e[1h-8-2F0LaTPQBM][8-in->4]>
clojuremud.core> home
#<StandardVertex v[4]>
clojuremud.core> users
#<StandardVertex v[8]>

clojuremud.core> (tg/transact! (te/get-all-edges))
IllegalStateException Cannot access element because its enclosing transaction is closed and unbound  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.getNextTx (StandardTitanTx.java:176)

clojuremud.core> (tg/transact! (tv/all-connected-vertices (tv/refresh users) :in))
IllegalStateException Cannot access element because its enclosing transaction is closed and unbound  com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.getNextTx (StandardTitanTx.java:176)

FWIW I have just run into this problem as well with

          (tg/open (System/getProperty "java.io.tmpdir"))
          (tg/transact!
            (let [ex (first edges)
                  p1 (tv/create! {:name (:a ex)})
                  p2 (tv/create! {:name (:b ex)})
                  {:keys [color cost]} ex]
              (te/connect! p1 :route p2 {:color color :cost cost})))

          (tg/transact!
            (te/get-all-edges))

This is directly from the docs so I'm not sure what the deal is.

If I had to guess I'd say all the operations must be completed in a single transaction, maybe this is a by-product using the java.io.tmpdir disk persistence.

This issue won't be relevant with the next release which no longer relies on dynamic vars to store a graph: there will be no implicit state you may trip over between transactions (in the library).

I see. I just realized you're the same guy who responded to my comment on the Neocons page. I actually started using Neocons/neo4j after this bug appeared. I went to google for it and saw a remark on the mailing list from February that Titanium was unmaintained. Is that not the case now?

@mattdeboard @ray1729 is working on updating it for Titan 0.4.x. This will include some long overdue public API changes. I suspect at least a few more weeks will be necessary to get Titanium, Archimedes and Orge in good shape on the new Tinkerpop stack version, so if you can't wait that long, use Neocons.

Any update on that ?

The latest Titanium release (1.0.0-beta2) has the new API Michael mentioned, but the documentation is lagging behind the API changes. In the mean time, check out the tests (particularly graph_test and integration_test) for examples.

Thank you for your quick feedback I will check it out !