From b9ed6b5033d13d77a623f3ee87714a89a3e49090 Mon Sep 17 00:00:00 2001 From: Daniel Mai Date: Fri, 15 Feb 2019 11:52:48 -0800 Subject: [PATCH] Update query_edge_limit config option info and error message. (#2979) --- dgraph/cmd/alpha/run.go | 2 +- query/query3_test.go | 1 - query/recurse.go | 5 +++-- query/shortest.go | 14 +++++--------- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/dgraph/cmd/alpha/run.go b/dgraph/cmd/alpha/run.go index 0b58b7081c2..749f782131f 100644 --- a/dgraph/cmd/alpha/run.go +++ b/dgraph/cmd/alpha/run.go @@ -153,7 +153,7 @@ they form a Raft group and provide synchronous replication. flag.Uint64("query_edge_limit", 1e6, "Limit for the maximum number of edges that can be returned in a query."+ - " This is only useful for shortest path queries.") + " This applies to shortest path and recursive queries.") // TLS configurations x.RegisterTLSFlags(flag) diff --git a/query/query3_test.go b/query/query3_test.go index eee9a574ec8..3658428da1d 100644 --- a/query/query3_test.go +++ b/query/query3_test.go @@ -26,7 +26,6 @@ import ( ) func TestRecurseError(t *testing.T) { - query := ` { me(func: uid(0x01)) @recurse(loop: true) { diff --git a/query/recurse.go b/query/recurse.go index 2842fa7e39e..a06b6bb3557 100644 --- a/query/recurse.go +++ b/query/recurse.go @@ -136,8 +136,9 @@ func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error } if numEdges > x.Config.QueryEdgeLimit { - // If we've seen too many nodes, stop the query. - return ErrTooBig + // If we've seen too many edges, stop the query. + return x.Errorf("Exceeded query edge limit = %v. Found %v edges.", + x.Config.QueryEdgeLimit, numEdges) } if len(out) == 0 { diff --git a/query/shortest.go b/query/shortest.go index 900eca4d94f..d8f436d5ddc 100644 --- a/query/shortest.go +++ b/query/shortest.go @@ -54,7 +54,6 @@ var pathPool = sync.Pool{ } var ErrStop = x.Errorf("STOP") -var ErrTooBig = x.Errorf("Query exceeded memory limit. Please modify the query") var ErrFacet = x.Errorf("Skip the edge") type priorityQueue []*Item @@ -203,8 +202,9 @@ func (sg *SubGraph) expandOut(ctx context.Context, } if numEdges > x.Config.QueryEdgeLimit { - // If we've seen too many nodes, stop the query. - rch <- ErrTooBig + // If we've seen too many edges, stop the query. + rch <- x.Errorf("Exceeded query edge limit = %v. Found %v edges.", + x.Config.QueryEdgeLimit, numEdges) return } @@ -315,9 +315,7 @@ func KShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { select { case err = <-expandErr: if err != nil { - if err == ErrTooBig { - return nil, err - } else if err == ErrStop { + if err == ErrStop { stopExpansion = true } else { return nil, err @@ -474,9 +472,7 @@ func ShortestPath(ctx context.Context, sg *SubGraph) ([]*SubGraph, error) { select { case err = <-expandErr: if err != nil { - if err == ErrTooBig { - return nil, err - } else if err == ErrStop { + if err == ErrStop { stopExpansion = true } else { return nil, err