Locking parent vertex while child is being updated.
BO XUAN LI <libo...@...>
Hi Timon,
toggle quoted message
Show quoted text
If I am understanding correctly, your code logic is like this: start_transaction(); read_vertex(type_v); read_vertex(version_v); // type_v ——hasVersion—> version_v if (version_v.published == true) then abort(); update_vertex(type_v); update_vertex(version_v); // set version_v.published = true commit(); Then I think setting ConsistencyModifier.LOCK for “published” property is sufficient. Using more locks make your transactions run slower. I would also suggest turning cache.db-cache off. Using database level cache might lead to stale read. If everything works well, you can again try turning db-cache on and tune the configs to see if you can still make data locking work. However, if you are changing “type” vertex and “version” vertex in different transactions, then I think you need to rethink about your data modeling, or change your application logic to make the locking work. Best regards, Boxuan
|
|
HadoopMarc <bi...@...>
Oops, that was a bit too quick, you did mention ConsistencyModifier.LOCK. The linked section reads: " When updating an element that is guarded by a uniqueness constraint, JanusGraph uses the following protocol at the end of a transaction when calling tx.commit():
Your problem seems that you required locking scope is larger than what you modify in a transaction. This means you should rethink your data model (do you really need this complexity?) or maybe you have to artificially broaden the transaction scope by dropping all properties and re-adding them. Best wishes, Marc Op donderdag 7 januari 2021 om 17:21:06 UTC+1 schreef HadoopMarc:
|
|
HadoopMarc <bi...@...>
Hi Timon You did not state whether you studied https://docs.janusgraph.org/advanced-topics/eventual-consistency/#data-consistency and whether that would fullfil your needs. Best wishes, Marc Op donderdag 7 januari 2021 om 16:18:55 UTC+1 schreef Timon Schneider: Hi all, |
|
Timon Schneider <timons...@...>
Hi all,
I have a question about locking data through Janusgraph. Here’s the problem: * We have a vertex with the label “type” with several properties * Types have one edge “hasVersion” to a vertex with a label “version” * This version vertex has a boolean property “published”. * The type’s properties should not be allowed to be changed if the version’s published property is true. We’re dealing with many concurrent user’s who might changes the type’s properties and set the version’s published property to true at the same time. And we need to be sure that the type’s properties are not change once it’s published. Is there a way to lock the version vertex once the type is being changed in a transaction? This would make sure that the type is not published by a concurrent user while it is being changed. We’re using the following configuration. Also we’re setting all relevant elements to ConsistencyModifier.LOCK through graph.openManagement().setConsistency. JanusGraphFactory.build() .set("storage.backend", "hbase") .set("storage.hbase.table", "testGraph") .set("storage.hostname", "localhost") .set("cache.db-cache", true) .set("cache.db-cache-clean-wait", 20) .set("cache.db-cache-time", 180000) .set("cache.db-cache-size", 0.5) .set("schema.constraints", true) .set("schema.default", "none") .open(); Thanks in advance, Timon |
|