0

Gremlin API in Azure Cosmos DB allows us to create vertices in different partitions(p1, p2) with same id(v1). When I created a self edge(e1) for a vertex(v1) in one partition(p1), two edges are getting created for vertices in both the partitions(v1 of p1 and v2 of p2). But actually only one edge must be created for the vertex(v1) of p1. I am using the gremlin version 3.4.10 for edge creation. The same behavior of creating duplicate edges was observed, when added the source and target for a vertex in Azure Portal. Find the JSON for the vertices created below.

[
  {
    "id": "v1",
    "label": "v1",
    "type": "vertex",
    "properties": {
      "_partitionKey": [
        {
          "id": "v1|_partitionKey",
          "value": "v1"
        }
      ]
    }
  },
  {
    "id": "v1",
    "label": "v1",
    "type": "vertex",
    "properties": {
      "_partitionKey": [
        {
          "id": "v1|_partitionKey",
          "value": "p2"
        }
      ]
    }
  }
]

Find the JSON for the edges created below

[
  {
    "id": "1bea8dea-6f10-49f5-bf7a-400894a92aae",
    "label": "edge1",
    "type": "edge",
    "inVLabel": "v1",
    "outVLabel": "v1",
    "inV": "v1",
    "outV": "v1"
  },
  {
    "id": "92c72e30-0bea-4ef9-b3c4-9c3879fb5a42",
    "label": "edge1",
    "type": "edge",
    "inVLabel": "v1",
    "outVLabel": "v1",
    "inV": "v1",
    "outV": "v1"
  }
]

I have two problems here

  1. Only one edge must be created. Whereas two edges are getting created when there are vertices with same id in different partitions.
  2. When I create an edge(e1) between two vertices(v1 of p1 and v2 of p1), the JSON for the edge doesn't have the partition key of the in and out vertices. It only has the id and label of the in and out vertices.In this case, I am not able to guess whether this edge(e1) belongs to which vertex(v1 of p1 or v1 of p2). This is because I have both the vertices with same id(v1) and same label(v1) in different partitions(p1 and p2). It will be helpful if I can get the inVertexPartition and outVertexPartition along with inV and outV for the edge JSON.
Ranjith Eswaran
  • 333
  • 2
  • 12
  • To help me understand #1 in details, please add the gremlin you are using to create edge and I will edit my answer. – mannu2050 Feb 18 '21 at 07:06
  • I am using gremlin version 3.4.10 - @mannu2050. The problem is when I have vertices with the same id(v1) in different partitions(p1 and p2). When I add an edge from v1 in p1 to v2 in p1, two edges are created. i.e v1(p1)--e1-->v2(p1) and v1(p2)-->e1-->v2(p2). I hope this makes the question clear. I see the same behaviour in Azure Portal also. – Ranjith Eswaran Feb 26 '21 at 03:58

1 Answers1

0

Out Edge will get stored along with the vertex. If I have created

v1(p1) --e1--> v2(p2), 

then e1 will get stored in the same partition of v1 which is p1. Refer for more information on how partition works in Gremlin API, https://learn.microsoft.com/en-us/azure/cosmos-db/graph-partitioning

mannu2050
  • 403
  • 3
  • 11