Vertex TTL update doesn't apply to prior vertexes
http://docs.janusgraph.org/latest/advanced-schema.html
Vertex TTL is defined on a per-vertex label basis, meaning that all vertices of that label have the same time-to-live. [...]
Note, that the TTL of a vertex label can be modified but it might take some time for this change to propagate [...]
I read that as: if the TTL is updated then the new TTL would apply to any and all existing vertexes. It makes sense that it wouldn't propagate to existing vertexes because some process would have to iterate over all vertexes of that label and update the TTL. The documentation should make that clarification.
The documentation should also WARN that static vertexes created without TTL are immutable and will remain forever.
Ideally, there should be a way to unshoot one's foot if a vertex is made and ttl never set (never expires).
Create vertex with no TTL (forever)
gremlin> g.tx().rollback()
gremlin> mgmt = graph.openManagement()
gremlin> tweet = mgmt.makeVertexLabel('tweet').setStatic().make()
gremlin> mgmt.commit()
gremlin> g.addV('tweet')
==>v[4164]
gremlin> g.tx().commit()
gremlin> g.V().hasLabel('tweet')
==>v[4164]
Modify TTL to 5s and add new vertex:
gremlin> g.tx().rollback()
gremlin> mgmt = graph.openManagement()
gremlin> tweet = mgmt.getVertexLabel("tweet")
gremlin> mgmt.setTTL(tweet, Duration.ofSeconds(5L))
gremlin> mgmt.commit()
gremlin> g.addV('tweet')
==>v[4292]
gremlin> g.tx().commit()
gremlin> g.V().hasLabel('tweet')
==>v[4164]
==>v[4292]
Wait 6 seconds:
gremlin> g.tx().rollback()
gremlin> g.V().hasLabel('tweet')
==>v[4164]
Original vertex remains (forever)
Verify current TTL on label:
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@6046fba0
gremlin> tweet = mgmt.getVertexLabel("tweet")
==>tweet
gremlin> mgmt.getTTL(tweet)
==>PT5S
gremlin> mgmt.commit()
==>null
Hi Robert,
Why there is a transaction rollback after wait 6 seconds? it should expire automatically instead of rollback.
Thanks
@adamyxliu The expiration is automatic. The rollback doesn't have anything to do with the expiration itself. But because the transaction is open, the expiration might not be visible in the current transaction. So the transaction is closed (rollback or commit, doesn't matter) so that the next call opens a new transaction in which the expiration should be visible.
I have tried commit, it doesn't work with HBase backend storage. I use JanusGraph 0.2.0 with HBase 1.2.6
Please see the latest the comments on #663 regarding TTL against HBase.