Hi Team. Got a query. I've defined an edge type wi...
# nebula-users
s
Hi Team. Got a query. I've defined an edge type with four properties in it. I'm using rank to add multiple edges with same edge type, source vertex, destination vertex by using different rank values(These edges differ in properties). My flow to add an edge (Implementation in Java using nebula-jdbc) is the following 1. I query to check if an edge with the same properties exists. 2. If it doesn't exists, I query again to get the max rank of the edge type between the vertices 3. Now, after fetching the max rank, I increment it and then create a new edge with the incremented rank. My questions: 1. Suppose I do a parallel write and when I try to get the max rank, there is a possibility for the same max rank to be returned when things run in parallel. In such a case, two parallel write requests with the max rank will be executed. This doesn't create two different edges but overrides one another. How should it be handled? 2. If there is a better approach to handle this, kindly let me know.
w
1. Suppose I do a parallel write and when I try to get the max rank, there is a possibility for the same max rank to be returned when things run in parallel. In such a case, two parallel write requests with the max rank will be executed. This doesn’t create two different edges but overrides one another. How should it be handled?
wey: the slightly later write will override the early one
2. If there is a better approach to handle this, kindly let me know.
wey: there are indeed no better approaches before nebulagraph supports transactions(in the future), while for now, I think we could generate a random factor as an edge property to verify from the client side that if it’s written as expected, i.e. if the property was overridden, then the client would know in some level by reading after write, again, it cannot guarantee all the rare race cases, either.
s
Oh okay. Thanks @wey
❤️ 1