Skip to content

Commit

Permalink
Avoid panic in handleValuePostings (dgraph-io#5652)
Browse files Browse the repository at this point in the history
Fixes: DGRAPH-1608

srcFn.n should be equal to len(q.UidList.Uids) for 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". We have tried to
reproduce this but couldn't find any edge case which will result in this panic. So for now
we are just logging when srcFn.n != len(q.UidList.Uids) and returning error when this
happens.
  • Loading branch information
ashish-goswami authored and dna2github committed Jul 18, 2020
1 parent a6ca67a commit 8551200
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions worker/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,15 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
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).
if srcFn.n != len(q.UidList.Uids) {
return errors.Errorf("srcFn.n: %d is not equal to len(q.UidList.Uids): %d, srcFn: %+v in "+
"handleValuePostings", srcFn.n, len(q.UidList.GetUids()), srcFn)
}

// This function has small boilerplate as handleUidPostings, around how the code gets
// concurrently executed. I didn't see much value in trying to separate it out, because the core
// logic constitutes most of the code volume here.
Expand Down

0 comments on commit 8551200

Please sign in to comment.