Panic in GraphQL server when sorting on multiple fields, using query variables


Since I moved from DGraph v20.11.0 to the latest v20.11.1, I started experiencing a panic causing the server to exit!

It happens systematically when I execute a query with a sort criteria on multiple fields.
The same query with a single sorted field works just fine, and it used to work perfectly with the previous version.
I also, recreated a brand new database in order to verify that it was not caused by the upgrade but the crash happened in both cases.

Here’s the query:

query($first: Int, $workloadOrder: KubeWorkloadOrder) {
  queryKubeWorkload(first: $first, order: $workloadOrder) {

with the following variables:

    "first": 10,
    "workloadOrder": {
      "asc": "_namespaceName",
      "then": {
        "asc": "_type"

And here’s the log of the server:

I0208 05:33:39.690260      41 admin.go:709] Successfully loaded GraphQL schema.  Serving GraphQL API.
I0208 05:34:07.399370      41 admin.go:509] Updating GraphQL schema from subscription.
I0208 05:34:07.399570      41 admin.go:539] Skipping GraphQL schema update, new badger key version is 19, the old version was 0.
I0208 05:34:29.437018      33 raft.go:719] Skipping creating a snapshot. Num groups: 1, Num checkpoints: 0
2021/02/08 05:38:06 Assert failed

Note that when I remove the “first: $first,” argument it will work just fine.
Also, if I remove the variables like this:

query {
  queryKubeWorkload(offset: 10, order: {
      asc: _namespaceName,
      then: {
        asc: _type
      }}) {

it works perfectly too!

Hey @livetocode, welcome to the forums! It would appear this might be a bug (or at least this should not happen).

pinging @ibrahim for more info

@pawan is our query expert. I wonder why this

would fail.

Duplicate of Sorting on multiple predicates broken on 20.11.1

Looks like this was fixed via

@livetocode please try out this PR. This will be part of the next release of dgraph.

1 Like