Identical query execution has inconsistent response

I believe this bug is related to this issue: Query sometimes randomly fails in specific way

Given a query like this one

query {
  ... do stuff to put in variable "t"

  data(func: uid(t), first: 50, offset: 0, orderasc: sortOrder) {
    xid sortOrder

where the nodes in “t” do not have the sortOrder predicate defined.
The expected dgraph response should be

  data: []

However when running this query multiple times, it only sometime returns empty as expected, and sometimes returns an array of nodes. It appears completely random.

This has been observed both when running from code but also when spamming the “run” button in the playground.

Tested on v20.07.0, on a fresh db.

why would you expect

{ data: [] }

I’m having a hard time imagining why

I expect it to be empty because when sorting, it seems that it is dgraph’s behavior to filter out items that not posses the predicate you sorting on.
Regardless, the issue here is that response is inconsistent.

I agree. This seems to be an issue. @ahsan can we file this as a bug?

@paulrostorp do you have a query+sample dataset that we can use to reproduce this bug

If there is inconsistency then this is definitely a bug. I tried replicating the issue, but I got consistent results for 1000 iterations. It would be really helpful if @paulrostorp can provide us with the steps (and the sample data) to replicate this issue.

@paulrostorp, I was able to replicate the issue with the data that you have provided. We’ll look into the cause of this inconsistency and will update you once we get this fixed. Thanks again for reporting this and helping us to replicate. :slight_smile:

1 Like