Query results are flaky and inconsistent with filter usage

Moved from GitHub dgraph/5046

Posted by dhagrow:

What version of Dgraph are you using?

v1.2.0

Have you tried reproducing the issue with the latest release?

Yes, v1.2.2 has the same issue.

What is the hardware spec (RAM, OS)?

DigitalOcean droplets
4 core Intel Xeon
8GB RAM
Ubuntu 18.04.3

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

We have a query that looks like this:

{
  q(func: type(process)) @filter(gt(process.started_at, "2020-03-25T00:00:00")) {
    count(uid)
    process.started_at
  }
}

And data with process.started_at values beginning as early as 2020-03-19.

Expected behaviour and actual result.

The query should return all “process” nodes with process.started_at values greater than 2020-03-25T00:00:00. Instead the earliest date value it is returning is 2020-03-26T18:00:10.766802Z.

Removing the filter returns “process” nodes that should match the filter value, such as 2020-03-25T15:48:07.346116Z.

Additional context here.

dhagrow commented :

It occurred to me that the index definition would be useful, though it seems correct to me:

process.started_at: datetime @index(hour) .

dhagrow commented :

I thought this issue might be specific to datetime types, but it looks to be more general. For example, the following queries give me a result:

{
  q(func: eq(process.pid, 812)) {
    uid
  }
}

{
  q(func: eq(process.pid, 812)) @filter(eq(process.pid, 812)) {
    uid
  }
}

However, these do not:

{
  q(func: type(process)) @filter(eq(process.pid, 4)) {
    uid
  }
}

{
  q(func: has(process.pid)) @filter(eq(process.pid, 4)) {
    uid
  }
}

Here is another example when filtering an edge. This works:

{
  q(func: eq(path.name, "process.exe")) @cascade {
    ~process.path @filter(eq(process.pid, 5200)) {
      uid
    }
  }
}

And this does not:

{
  q(func: has(path.name)) @cascade {
    ~process.path @filter(eq(process.pid, 5200)) {
      uid
    }
  }
}

josh-mercarto commented :

Any update on when this will be fixed?