Skip to content

Commit

Permalink
fix(worker): Avoid panic in handleUidPostings (#6607)
Browse files Browse the repository at this point in the history
Fixes DGRAPH-2491

(cherry picked from commit f77cfe3)
  • Loading branch information
harshil-goel authored and Ibrahim Jarif committed Oct 12, 2020
1 parent a1ce240 commit 584cc16
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,18 @@ func (qs *queryState) handleUidPostings(
return nil
}

// srcFn.n should be equal to len(q.UidList.Uids) for below implementation(DivideAndRule and
// calculate) to work correctly. But we have seen some panics while forming DataKey in
// calculate(). panic is of the form "index out of range [4] with length 1". Hence return error
// from here when srcFn.n != len(q.UidList.Uids).
switch srcFn.fnType {
case notAFunction, compareScalarFn, hasFn, uidInFn:
if srcFn.n != len(q.UidList.GetUids()) {
return errors.Errorf("srcFn.n: %d is not equal to len(q.UidList.Uids): %d, srcFn: %+v in "+
"handleUidPostings", srcFn.n, len(q.UidList.GetUids()), srcFn)
}
}

// Divide the task into many goroutines.
numGo, width := x.DivideAndRule(srcFn.n)
x.AssertTrue(width > 0)
Expand Down

0 comments on commit 584cc16

Please sign in to comment.