Between() in query causes alpha crash

Report a Dgraph Bug

What version of Dgraph are you using?

master@b49a30231

Have you tried reproducing the issue with the latest release?

yes, only on master

What is the hardware spec (RAM, OS)?

docker for mac

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

start docker image, load in dataset, try query including between

Expected behaviour and actual result.

obviously I expect to have the between function evaluated. Instead, it crashes the server with the following stacktrace:

2020/10/02 04:04:18 Unknown ineqType between
github.com/dgraph-io/dgraph/x.Fatalf
        /ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:120
github.com/dgraph-io/dgraph/types.CompareVals
        /ext-go/1/src/github.com/dgraph-io/dgraph/types/compare.go:44
github.com/dgraph-io/dgraph/worker.(*queryState).handleValuePostings.func1
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/task.go:454
github.com/dgraph-io/dgraph/worker.(*queryState).handleValuePostings.func2
        /ext-go/1/src/github.com/dgraph-io/dgraph/worker/task.go:504
golang.org/x/sync/errgroup.(*Group).Go.func1
        /go/pkg/mod/golang.org/x/sync@v0.0.0-20190423024810-112230192c58/errgroup/errgroup.go:57
runtime.goexit
        /usr/local/go/src/runtime/asm_amd64.s:1373

seems like the new between function was simply left out of the switch statement in CompareVals(). Let me know if you need a test schema and query to reproduce, but the query had this fragment used which caused the issue:

fragment rangeFilter {
  has_range @filter(between(hstart,$start,$end) OR between(hend, $start, $end)) {
    name
    hstart
    hend
  }
}

between is not a filter function.

I assume proper operation is not a server panic. Just wanted to bring it up in case it was not known.

Hey @iluminae,
currently between is only supported at root level and not inside filters.
I agree that it should not crash Dgraph if its used inside filters.

I am marking this as accepted, so that it can be fixed.

What?? There is a between I can use at the root level?

Hey @amaster507, we have recently added between at root level. It will be available in release 20.11.

2 Likes

I would suggest making between work in filters as well, but that is low priority for me since gt() AND lt() will do the same. Mostly it would be less confusing if you could use it everywhere.

2 Likes

Let’s keep this bug about preventing the crash. Please file a new enhancement request for using ‘between’ in filters.

Oh good, I thought I was going crazy.

Fixed by: fix(worker): fix between filter for non indexed predicates by minhaj-shakeel · Pull Request #6715 · dgraph-io/dgraph · GitHub