From 84f4a0ccee2b5928cf607347cc8b166102c84a1b Mon Sep 17 00:00:00 2001 From: Martin Martinez Rivera Date: Wed, 20 Mar 2019 15:52:59 -0700 Subject: [PATCH] Fix bug for queries with @recurse and expand(_all_). (#3179) Currently this type of queries might result in an unrecoverable error in the alpha. This happens for example, while trying to expand on a node of type PASSWORD. The reason is that handleValuePostings and handleUidPostings sometimes successfully return early without setting the UidMatrix field. This change adds a fix and modifies the existing test to trigger this case. I have verified that the test crashes the alpha when the fix is absent. --- query/common_test.go | 1 + query/recurse.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/query/common_test.go b/query/common_test.go index 56512d63bcf..028ae382351 100644 --- a/query/common_test.go +++ b/query/common_test.go @@ -468,6 +468,7 @@ func populateCluster() { <36> "CA" . <1> "123456" . + <32> "123456" . <23> "654321" . <23> "4" . diff --git a/query/recurse.go b/query/recurse.go index cd4861c3bd2..ad83fe00e56 100644 --- a/query/recurse.go +++ b/query/recurse.go @@ -94,6 +94,11 @@ func (start *SubGraph) expandRecurse(ctx context.Context, maxDepth uint64) error } for _, sg := range exec { + // sg.uidMatrix can be empty. Continue if that is the case. + if len(sg.uidMatrix) == 0 { + continue + } + if sg.UnknownAttr { continue }