Skip to content

Reverse index doesn't update for non-list uid predicates #5732

@ppp225

Description

@ppp225

What version of Dgraph are you using?

dgraph/dgraph:v20.07.0-beta.Jun22

Have you tried reproducing the issue with the latest release?

v20.07.0-beta.Jun22, and on master from 3 weeks ago

What is the hardware spec (RAM, OS)?

docker

Steps to reproduce the issue (command/config used to run Dgraph).

When overwriting the uid predicate, reverse index is not updated:

Schema string:
<edge>: uid @reverse .
First:

{
  set {
    <_:a> <name> "A" .
    <_:a> <edge> <_:parent> .
    <_:parent> <name> "Parent" .
  }
}

Then:

upsert {
query {
  U as var(func: has(edge))
}
mutation {
  set {
    uid(U) <edge> <_:parent2> .
    <_:parent2> <name> "Parent2" .
  }
}
}

Then run query to see results:

{
  q(func: has(edge)) {
    uid
    name
    edge {
      name
    }
  }
  q2(func: has(~edge)) {
    name
    ~edge {
      uid
      name
    }
  }
}

Expected behaviour and actual result.

q query has correct values, but q2, which shows reverse edges, has even edges that do not exist.

  "data": {
    "q": [
      {
        "uid": "0x9c4e",
        "name": "A",
        "edge": {
          "name": "Parent2"             # one node, as expected
        }
      }
    ],
    "q2": [
      {
        "name": "Parent",
        "~edge": [                  # this reverse edge does not exist.
          {
            "uid": "0x9c4e",
            "name": "A"
          }
        ]
      },
      {
        "name": "Parent2",
        "~edge": [
          {
            "uid": "0x9c4e",
            "name": "A"
          }
        ]
      }
    ]
  },

Reindexing fixes the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/indexesRelated to indexes (indices) and their usage.kind/bugSomething is broken.status/acceptedWe accept to investigate/work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions