Aggregating Facets leads to socket hang up (intended to use?)


Report a Dgraph Bug

What version of Dgraph are you using?

Dgraph Version
$ dgraph version
 
20.11.0

Have you tried reproducing the issue with the latest release?

Used the latest docker image
Here the data what docker gets me
dgraph/standalone IN USE latest 2 months ago 164.07 MB

What is the hardware spec (RAM, OS)?

16GB Docker

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

I used this simple data structure for test

"data": {
        "query": [
            {
                "SomePredicate": [
                    {
                        "WaldoValue": "SomeValue IDK",
                        "Index": 1,
                        "SomePredicate|TimeStamp": "2021-02-25T12:21:23.676Z"
                    },
                    {
                        "WaldoValue": "SomeValue IDK",
                        "Index": 2,
                        "SomePredicate|TimeStamp": "2021-02-25T12:21:23.676Z"
                    },
                    {
                        "WaldoValue": "SomeValue IDK",
                        "Index": 2,
                        "SomePredicate|TimeStamp": "2021-02-25T12:21:23.676Z"
                    },
                    {
                        "WaldoValue": "SomeValue IDK",
                        "Index": 3,
                        "SomePredicate|TimeStamp": "2021-02-25T12:21:23.676Z"
                    },
                    {
                        "WaldoValue": "SomeValue IDK",
                        "Index": 4,
                        "SomePredicate|TimeStamp": "2021-02-25T12:21:23.676Z"
                    }
                ]
            }
        ]
    }

Now when you group it like that

query {
 query(func: uid(0x201))
    {
        SomePredicate
        @groupby(Index)
        @facets
        {
        	count(uid)
        }    
    }
 }

It works well!

But when I add facets into the mix it is escalating rather quickly = P

query {
    query(func: uid(0x201))
    {
        SomePredicate
        @groupby(Index)
        @facets
        {
        	count(uid)
            max(TimeStamp)
        }    
    }
 }

In PostMan I get an error named socket hang up
In Ratel I get nothing
Graph View looks like this

Error Name: TypeError

Message:

Raw Error:

{}

Json View looks like this

{}

In DGraph Console Window (DGraph Dashboard) I get these logs

2021/02/25 15:20:35 http: panic serving 172.17.0.1:58012: runtime error: index out of range [1] with length 0

goroutine 166378 [running]:

net/http.(*conn).serve.func1(0xc0022f9400)

/usr/local/go/src/net/http/server.go:1801 +0x147

panic(0x1caf6c0, 0xc0046c1ac0)

/usr/local/go/src/runtime/panic.go:975 +0x47a

github.com/dgraph-io/dgraph/query.aggregateGroup(0xc0035dee10, 0xc0035e2300, 0xc0034d2a38, 0x2, 0x2, 0xc00e724530, 0xe)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:152 +0x24a

github.com/dgraph-io/dgraph/query.(*groupResult).aggregateChild(0xc0035dee10, 0xc0035e2300, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:63 +0x29d

github.com/dgraph-io/dgraph/query.(*SubGraph).formResult(0xc002fa7b00, 0xc0023dc400, 0x8, 0xc0034d2c90, 0xa765a5)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:256 +0x645

github.com/dgraph-io/dgraph/query.(*SubGraph).processGroupBy(0xc002fa7b00, 0xc00c4e8f30, 0xc00d1ad610, 0x1, 0x2, 0x1, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:376 +0x75

github.com/dgraph-io/dgraph/query.(*SubGraph).valueVarAggregation(0xc002fa7b00, 0xc00c4e8f30, 0xc00d1ad610, 0x1, 0x2, 0xc002fa7800, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1162 +0xe45

github.com/dgraph-io/dgraph/query.(*SubGraph).populatePostAggregation(0xc002fa7b00, 0xc00c4e8f30, 0xc00d1ad610, 0x2, 0x2, 0xc002fa7800, 0x0, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1267 +0x1b6

github.com/dgraph-io/dgraph/query.(*SubGraph).populatePostAggregation(0xc002fa7800, 0xc00c4e8f30, 0xc0067345a8, 0x1, 0x1, 0x0, 0x0, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1261 +0xd7

github.com/dgraph-io/dgraph/query.(*Request).ProcessQuery(0xc0034d3488, 0x1f89ae0, 0xc006791c20, 0x0, 0xc005a00400)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:2780 +0xe48

github.com/dgraph-io/dgraph/query.(*Request).Process(0xc0034d3488, 0x1f89ae0, 0xc006791c20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:2811 +0x7e

github.com/dgraph-io/dgraph/edgraph.processQuery(0x1f89ae0, 0xc006791c20, 0xc002640320, 0x0, 0x0, 0x14)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:1158 +0x329

github.com/dgraph-io/dgraph/edgraph.(*Server).doQuery(0xc0034d39e6, 0x1f89ae0, 0xc001794e10, 0xc00369caf0, 0x0, 0x0, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:1084 +0x50e

github.com/dgraph-io/dgraph/edgraph.(*Server).Query(0xc0062ff9e6, 0x1f89aa0, 0xc00d2d0de0, 0xc00369caf0, 0x0, 0x0, 0x1f89ae0)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:992 +0xa6

github.com/dgraph-io/dgraph/dgraph/cmd/alpha.queryHandler(0x1f832e0, 0xc00258a620, 0xc00283bd00)

/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/http.go:248 +0x4b6

net/http.HandlerFunc.ServeHTTP(0x1dfc1a0, 0x1f832e0, 0xc00258a620, 0xc00283bd00)

/usr/local/go/src/net/http/server.go:2042 +0x44

net/http.(*ServeMux).ServeHTTP(0x2ba8b80, 0x1f832e0, 0xc00258a620, 0xc00283bd00)

/usr/local/go/src/net/http/server.go:2417 +0x1ad

net/http.serverHandler.ServeHTTP(0xc000124000, 0x1f832e0, 0xc00258a620, 0xc00283bd00)

/usr/local/go/src/net/http/server.go:2843 +0xa3

net/http.(*conn).serve(0xc0022f9400, 0x1f89a20, 0xc0063fb9c0)

/usr/local/go/src/net/http/server.go:1925 +0x8ad

created by net/http.(*Server).Serve

/usr/local/go/src/net/http/server.go:2969 +0x36c

2021/02/25 15:22:10 http: panic serving 172.17.0.1:58096: runtime error: index out of range [1] with length 0

goroutine 166466 [running]:

net/http.(*conn).serve.func1(0xc0011503c0)

/usr/local/go/src/net/http/server.go:1801 +0x147

panic(0x1caf6c0, 0xc003101a20)

/usr/local/go/src/runtime/panic.go:975 +0x47a

github.com/dgraph-io/dgraph/query.aggregateGroup(0xc0026f86e0, 0xc0020ce000, 0xc0003eca38, 0x2, 0x2, 0xc00df7d120, 0xe)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:152 +0x24a

github.com/dgraph-io/dgraph/query.(*groupResult).aggregateChild(0xc0026f86e0, 0xc0020ce000, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:63 +0x29d

github.com/dgraph-io/dgraph/query.(*SubGraph).formResult(0xc000333800, 0xc0019f4c00, 0x8, 0xc0003ecc90, 0xa765a5)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:256 +0x645

github.com/dgraph-io/dgraph/query.(*SubGraph).processGroupBy(0xc000333800, 0xc003a043c0, 0xc002b885a0, 0x1, 0x2, 0x1, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/groupby.go:376 +0x75

github.com/dgraph-io/dgraph/query.(*SubGraph).valueVarAggregation(0xc000333800, 0xc003a043c0, 0xc002b885a0, 0x1, 0x2, 0xc000333500, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1162 +0xe45

github.com/dgraph-io/dgraph/query.(*SubGraph).populatePostAggregation(0xc000333800, 0xc003a043c0, 0xc002b885a0, 0x2, 0x2, 0xc000333500, 0x0, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1267 +0x1b6

github.com/dgraph-io/dgraph/query.(*SubGraph).populatePostAggregation(0xc000333500, 0xc003a043c0, 0xc00558c2d0, 0x1, 0x1, 0x0, 0x0, 0x1)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:1261 +0xd7

github.com/dgraph-io/dgraph/query.(*Request).ProcessQuery(0xc0003ed488, 0x1f89ae0, 0xc003cba5a0, 0x0, 0xc005b00400)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:2780 +0xe48

github.com/dgraph-io/dgraph/query.(*Request).Process(0xc0003ed488, 0x1f89ae0, 0xc003cba5a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)

/ext-go/1/src/github.com/dgraph-io/dgraph/query/query.go:2811 +0x7e

github.com/dgraph-io/dgraph/edgraph.processQuery(0x1f89ae0, 0xc003cba5a0, 0xc001150820, 0x0, 0x0, 0x14)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:1158 +0x329

github.com/dgraph-io/dgraph/edgraph.(*Server).doQuery(0xc0003ed9e6, 0x1f89ae0, 0xc003a05c20, 0xc000499ce0, 0x0, 0x0, 0x0, 0x0)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:1084 +0x50e

github.com/dgraph-io/dgraph/edgraph.(*Server).Query(0xc00006a9e6, 0x1f89ae0, 0xc003cba330, 0xc000499ce0, 0x0, 0x0, 0x1f89ae0)

/ext-go/1/src/github.com/dgraph-io/dgraph/edgraph/server.go:992 +0xa6

github.com/dgraph-io/dgraph/dgraph/cmd/alpha.queryHandler(0x1f832e0, 0xc000124460, 0xc002239f00)

/ext-go/1/src/github.com/dgraph-io/dgraph/dgraph/cmd/alpha/http.go:248 +0x4b6

net/http.HandlerFunc.ServeHTTP(0x1dfc1a0, 0x1f832e0, 0xc000124460, 0xc002239f00)

/usr/local/go/src/net/http/server.go:2042 +0x44

net/http.(*ServeMux).ServeHTTP(0x2ba8b80, 0x1f832e0, 0xc000124460, 0xc002239f00)

/usr/local/go/src/net/http/server.go:2417 +0x1ad

net/http.serverHandler.ServeHTTP(0xc000124000, 0x1f832e0, 0xc000124460, 0xc002239f00)

/usr/local/go/src/net/http/server.go:2843 +0xa3

net/http.(*conn).serve(0xc0011503c0, 0x1f89a20, 0xc0032ce340)

/usr/local/go/src/net/http/server.go:1925 +0x8ad

created by net/http.(*Server).Serve

/usr/local/go/src/net/http/server.go:2969 +0x36c

Expected behaviour and actual result.

What I expect it to work or that the error gets definied in the response.
That the user know whats happening!

I dont know if that is intended but it kills the socket, so for me this is a bug and not handled properly

Have a nice day!
Greetings

I tested with the master docker image!
It doesn’t work as expected but I get an result
Empty result

Version is now

20.11.0-rc1-398-ge53f9668

This is a bug cuz this Only aggregator/count functions allowed inside @groupby.
The input max(TimeStamp) is invalid in group by blocks.

It should throw the right error.