Skip to content

Commit 9e303a8

Browse files
Avoid panic in handleValuePostings (#5652) (#5678)
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. (cherry picked from commit 2184268)
1 parent 9df5963 commit 9e303a8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

worker/task.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,15 @@ func (qs *queryState) handleValuePostings(ctx context.Context, args funcArgs) er
357357
return nil
358358
}
359359

360+
// srcFn.n should be equal to len(q.UidList.Uids) for below implementation(DivideAndRule and
361+
// calculate) to work correctly. But we have seen some panics while forming DataKey in
362+
// calculate(). panic is of the form "index out of range [4] with length 1". Hence return error
363+
// from here when srcFn.n != len(q.UidList.Uids).
364+
if srcFn.n != len(q.UidList.Uids) {
365+
return errors.Errorf("srcFn.n: %d is not equal to len(q.UidList.Uids): %d, srcFn: %+v in "+
366+
"handleValuePostings", srcFn.n, len(q.UidList.GetUids()), srcFn)
367+
}
368+
360369
// This function has small boilerplate as handleUidPostings, around how the code gets
361370
// concurrently executed. I didn't see much value in trying to separate it out, because the core
362371
// logic constitutes most of the code volume here.

0 commit comments

Comments
 (0)