From ae029f0e24189fc28c1dbc0e81bfc3078d4370a1 Mon Sep 17 00:00:00 2001 From: Naman Jain Date: Wed, 5 May 2021 17:18:10 +0530 Subject: [PATCH] fix(txn): ensure that txn hash is set (#7782) We were setting the hash after completing the transaction successfully. This leads to the failure of the commit as it won't contain the hash. This PR fixes that issue. --- edgraph/server.go | 20 ++++++++++++-------- worker/server_state.go | 1 - 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/edgraph/server.go b/edgraph/server.go index c45cac8efa5..404e5148a17 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -1404,6 +1404,18 @@ func (s *Server) doQuery(ctx context.Context, req *Request) ( req.req.StartTs = worker.State.GetTimestamp(false) qc.latency.AssignTimestamp = time.Since(start) } + if x.WorkerConfig.AclEnabled { + ns, err := x.ExtractNamespace(ctx) + if err != nil { + return nil, err + } + defer func() { + if resp != nil && resp.Txn != nil { + // attach the hash, user must send this hash when further operating on this startTs. + resp.Txn.Hash = getHash(ns, resp.Txn.StartTs) + } + }() + } var gqlErrs error if resp, rerr = processQuery(ctx, qc); rerr != nil { @@ -1437,14 +1449,6 @@ func (s *Server) doQuery(ctx context.Context, req *Request) ( EncodingNs: uint64(l.Json.Nanoseconds()), TotalNs: uint64((time.Since(l.Start)).Nanoseconds()), } - if x.WorkerConfig.AclEnabled { - // attach the hash, user should send this hash when further operating on this startTs. - ns, err := x.ExtractNamespace(ctx) - if err != nil { - return nil, err - } - resp.Txn.Hash = getHash(ns, resp.Txn.StartTs) - } md := metadata.Pairs(x.DgraphCostHeader, fmt.Sprint(resp.Metrics.NumUids["_total"])) grpc.SendHeader(ctx, md) return resp, gqlErrs diff --git a/worker/server_state.go b/worker/server_state.go index a008b0606fe..7f5d0efb29d 100644 --- a/worker/server_state.go +++ b/worker/server_state.go @@ -43,7 +43,6 @@ const ( CacheDefaults = `size-mb=1024; percentage=0,65,35;` CDCDefaults = `file=; kafka=; sasl_user=; sasl_password=; ca_cert=; client_cert=; ` + `client_key=; sasl-mechanism=PLAIN;` - CloudDefaults = `disable-non-galaxy=false;` GraphQLDefaults = `introspection=true; debug=false; extensions=true; poll-interval=1s; ` + `lambda-url=;` LimitDefaults = `mutations=allow; query-edge=1000000; normalize-node=10000; ` +