Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v21.03: fix(txn): ensure that txn hash is set (#7782) #7784

Merged
merged 1 commit into from
May 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down