@upsert directive is important to detect conflicts

i found it doesn’t work.

i tried:

schema:
“name:string @index(hash) @upsert .\n”

mutate data like

{
  set {
    
    _:p1 <name> "p1" .
    _:p2 <name> "p2" .
 }
}

and then mutate then same:

{
  set {
    
    _:p1 <name> "p1" .
    _:p2 <name> "p2" .
 }
}

it cannot detect the conflicts of name?

what do i miss in using this directive?

Here p1 is assigned 2 different uid’s and p2 is also assigned 2 different uid’s.
For @upsert, if u need to update a node p1 or p2, you should use its uid assigned to p1 or p2 to update accordingly

https://docs.dgraph.io/master/howto/#upsert-procedure

i misunderstand the @upsert, it should work in this situation:
As such, it’s possible that two concurrently running operations could try to add the same node at the same time

Two concurrently running operations could try to add the same node at the same time. In this case, similar nodes will be assigned different uid’s so there would be no conflict.
@upsert can be done using uid only.
Hope it clears your doubt.

ok, i found a situation:
i set replica=3,
i have three dgraph server, i insert data to one server, and i can get results from this server, but i cannot get any results in another two server, why?

@shanghai-Jerry Can you share your docker-compose.yml file.

i am not using docker

server one:
zero

{
    "idx": 1,
    "my": "172.20.0.8:5080",
    "replicas": 3,
    "wal": "/data/dgraph/zero"
}

server config:

{
    "my": "172.20.0.8:7080",
    "zero": "172.20.0.8:5080",
    "lru_mb": 21440,
    "badger.vlog":"disk"
}

server two:

zero:

{
    "idx": 2,
    "my": "172.20.0.9:5080",
    "peer": "172.20.0.8:5080",
    "replicas": 3,
    "wal": "/data/dgraph/zero",
    "bindall": true
}

server config:

{
    "my": "172.20.0.9:7080",
    "zero": "172.20.0.8:5080",
    "lru_mb": 21440,
    "badger.vlog":"disk"
}

server three:
zero:

{
    "idx": 3,
    "my": "172.20.0.10:5080",
    "peer": "172.20.0.8:5080",
    "replicas": 3,
    "wal": "/data/dgraph/zero"
}

server config:

{
    "my": "172.20.0.10:7080",
    "zero": "172.20.0.8:5080",
    "lru_mb": 21440,
    "badger.vlog":"disk"
}

1 Like