Graphql hierarchical query hangs on version 21.03.0

Hierarchical data appears to cause the server to take 100% CPU and hang indefinitely for some queries.

Simple reproduction

Run latest version:

$ docker run --rm -it -p "8080:8080" -p "9080:9080" -p "8000:8000" -v `pwd`/dgraph:/dgraph "dgraph/standalone:v21.03.0"

Add schema:

type Org {
  id: ID!
  employees: [Employee!]! @hasInverse(field: org)
}

type Employee {
  id: ID!
  org: Org!
  manager: Employee
  reports: [Employee!] @hasInverse(field: manager)
  tags: [Tag!]
}

type Tag {
  name: String! @id
  employees: [Employee!] @hasInverse(field: tags)
}

Insert a few records:

$ curl localhost:8080/graphql -H 'Content-Type: application/json' --data-binary '{ "query": "mutation addOrg($org: [AddOrgInput!]!) { addOrg(input: $org) { org { id } } }", "variables": { "org": [ { "employees": [ { "reports": [ { "reports": [], "tags": [] }, { "reports": [], "tags": [ { "name": "Foo" }, { "name": "Bar" } ] } ], "tags": [] } ] } ] } }'

Querying example query that will now trigger the issue (does not return):

$ curl localhost:8080/graphql -H 'Content-Type: application/json' --data-binary '{"query":"query { queryOrg { id employees { id tags { name } reports { id } } } }" }'
1 Like

I ran into this and it cost me two afternoons as I was just starting with Dgraph and thought it’s me not the software.

If maintainers read this: Maybe you could push latest docker image more often? Some people including me pull down latest image hoping to get the latest and greatest. Tag master is more recent and resolved the issue above.

I personally would be a fan of latest being removed from docs/ docker hub, since it has completely undefined release semantics, and causes confusion like this.

Maybe this should the content of a new topic here.

1 Like

Hi @jtescher and @roschaefer ,

Welcome to Dgraph Community !!

We had made changes to how graphql results are encoded in Dgraph in January and the new encoding has this issue.

This issue was reported earlier and has been fixed in master and upcoming 21.03.1 release with the following PR, Fix(GraphQL): Fix GraphQL encoding in case of empty list by vmrajas · Pull Request #7726 · dgraph-io/dgraph · GitHub .

Related Post: Certain GraphQL Queries Hang

Regarding tags, we have noted down this feedback. Latest refers to the latest release branch. Maybe we can clarify this in Dgraph docs.