Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ppp225 opened this issue Jun 25, 2020 · 1 comment
Closed

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

ppp225 opened this issue Jun 25, 2020 · 1 comment
Labels
area/indexes Related to indexes (indices) and their usage. kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@ppp225
Copy link

ppp225 commented Jun 25, 2020

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.

@MichelDiz MichelDiz added area/indexes Related to indexes (indices) and their usage. kind/bug Something is broken. status/accepted We accept to investigate/work on it. labels Jun 25, 2020
@martinmr
Copy link
Contributor

Fixed by #5868

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/indexes Related to indexes (indices) and their usage. kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

No branches or pull requests

3 participants