diff --git a/edgraph/server.go b/edgraph/server.go index b6b57e38091..06baa81051f 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -1252,6 +1252,18 @@ func (s *Server) doQuery(ctx context.Context, req *Request) ( 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 { @@ -1285,14 +1297,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