Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update query_edge_limit config option info and error message. #2979

Merged
merged 9 commits into from
Feb 15, 2019
2 changes: 1 addition & 1 deletion dgraph/cmd/alpha/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion query/query3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
)

func TestRecurseError(t *testing.T) {

query := `
{
me(func: uid(0x01)) @recurse(loop: true) {
Expand Down
5 changes: 3 additions & 2 deletions query/recurse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
14 changes: 5 additions & 9 deletions query/shortest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down