Skip to content

Commit 9b50797

Browse files
committed
alpha: limit #edges using LimitMutationsNquad config and add logs
1 parent 3d0e8fa commit 9b50797

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

edgraph/server.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,12 @@ func (s *Server) doMutate(ctx context.Context, qc *queryContext, resp *api.Respo
594594
if err != nil {
595595
return err
596596
}
597+
598+
if len(edges) > x.Config.LimitMutationsNquad {
599+
return errors.Errorf("NQuad count in the request: %d, is more that threshold: %d",
600+
len(edges), int(x.Config.LimitMutationsNquad))
601+
}
602+
597603
ns, err := x.ExtractNamespace(ctx)
598604
if err != nil {
599605
return errors.Wrapf(err, "While doing mutations:")
@@ -953,7 +959,6 @@ func updateValInMutations(gmu *dql.Mutation, qc *queryContext) error {
953959
// updateUIDInMutations does following transformations:
954960
// - uid(v) -> 0x123 -- If v is defined in query block
955961
// - uid(v) -> _:uid(v) -- Otherwise
956-
957962
func updateUIDInMutations(gmu *dql.Mutation, qc *queryContext) error {
958963
// usedMutationVars keeps track of variables that are used in mutations.
959964
getNewVals := func(s string) []string {

query/shortest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ func (sg *SubGraph) expandOut(ctx context.Context,
242242
if numEdges > x.Config.LimitQueryEdge {
243243
// If we've seen too many edges, stop the query.
244244
rch <- errors.Errorf("Exceeded query edge limit = %v. Found %v edges.",
245-
x.Config.LimitMutationsNquad, numEdges)
245+
x.Config.LimitQueryEdge, numEdges)
246246
return
247247
}
248248

worker/proposal.go

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"sync/atomic"
2424
"time"
2525

26+
"github.com/golang/glog"
2627
"github.com/pkg/errors"
2728
ostats "go.opencensus.io/stats"
2829
tag "go.opencensus.io/tag"
@@ -249,6 +250,7 @@ func (n *node) proposeAndWait(ctx context.Context, proposal *pb.Proposal) (perr
249250
// We arrived here by a call to n.Proposals.Done().
250251
return err
251252
case <-ctx.Done():
253+
glog.Warningf("Context expired while processing proposal %v", ctx.Err())
252254
return ctx.Err()
253255
case <-timer.C:
254256
if atomic.LoadUint32(&pctx.Found) > 0 {
@@ -258,6 +260,7 @@ func (n *node) proposeAndWait(ctx context.Context, proposal *pb.Proposal) (perr
258260
cancel()
259261
}
260262
case <-cctx.Done():
263+
glog.Warningf("Internal context expired while processing proposal %v", cctx.Err())
261264
return errInternalRetry
262265
}
263266
}

0 commit comments

Comments
 (0)