0
votes

I'm using Clojure/Ogre to interact with Janusgraph DB from my clojure api application. Since I'm very new to this technologies I think I might have missed something. Below are the problems I'm facing,

  • When I add a new vertex via from my clojure application, my janusgraph DB is showing the vertex and it is expected. But when I tried to update the vertex properties from application, DB is not showing the updated result. I need to explicitly open the "janusgraph-cql.properties" file from gremlin shell, then only its showing the updated result in the DB.
  • When I query the vertex from my application using clojure/ogre syntax I'm getting old stale data even after updating the vertex property values via clojure/ogre syntax from application. The cache is storing the previously queried results. When I execute the same query statement multiple times (5th time) it is showing the updated result.

I'm so highly confused as on how to stop or update the cache when any of vertex properties are being updated.

Please find the details below, The below query is used to update the existing vertex.

(og/traverse g (og/V)
              (og/has :name "xyz") 
              (og/property :age 32)
              (og/next!))(.commit (.tx graph))

After executing the above statement, when I open the gremlin shell, I'm not seeing the updated vertex but old vertex only. I need to explicitly open the properties file using

graph = JanusGraphFactory.open('config/dev/janusgraph-cql.properties')

and then when I query in gremlin shell its displaying new data.

The below statement is used from clojure application to retrieve the data,

(og/traverse g (og/V) (og/has :name "xyz")
  (og/value-map) (og/into-list!))

Even after updating the vertex properties, when I execute the above statement from my clojure application I'm getting old data only. When I execute fifth time then only I'm getting new data and if I execute again same results being repeated. Cache is storing five previously queried results it seems.

My properties file,

gremlin.graph=org.janusgraph.core.JanusGraphFactory
storage.backend=cql
storage.hostname=127.0.0.1
storage.cql.keyspace=mygraph
cache.db-cache = true
cache.db-cache-clean-wait = 20
cache.db-cache-time = 180000
cache.db-cache-size = 0.5
index.search.backend=elasticsearch
index.search.hostname=127.0.0.1

Please help me out here on how to overcome this stale data retrieval issue and also how to reflect the updates immediately into janusgraph DB after updating from clojure application without explicitly opening the properties instance each and every time. Thanks a lot for your time and help.

1

1 Answers

1
votes

If I understand your order of operations properly, I believe that you are doing:

  1. Queried a vertex in Gremlin Console
  2. Updated that same vertex in Ogre
  3. Queried that vertex again in Gremlin Console and saw stale data

If that is so, I believe that is to be expected because the vertex in the console is using cached data from the current transaction. If you do the following I imagine things would work:

  1. Queried a vertex in Gremlin Console
  2. Updated that same vertex in Ogre
  3. Issue g.tx().rollback() in Gremlin Console to start a new transaction
  4. Queried that vertex again in Gremlin Console and view the update