Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NamanJain8 committed Mar 18, 2021
1 parent f413372 commit 37b65cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 4 additions & 5 deletions dgraph/cmd/alpha/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

"github.com/dgraph-io/dgraph/graphql/admin"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgraph/edgraph"
"github.com/dgraph-io/dgraph/gql"
Expand Down Expand Up @@ -503,14 +502,14 @@ func handleAbort(ctx context.Context, startTs uint64) (map[string]interface{}, e
Aborted: true,
}

_, err := (&edgraph.Server{}).CommitOrAbort(ctx, tc)
switch err {
case dgo.ErrAborted:
tctx, err := (&edgraph.Server{}).CommitOrAbort(ctx, tc)
switch {
case tctx.Aborted == true:
return map[string]interface{}{
"code": x.Success,
"message": "Done",
}, nil
case nil:
case err == nil:
return nil, errors.Errorf("transaction could not be aborted")
default:
return nil, err
Expand Down
1 change: 0 additions & 1 deletion dgraph/cmd/live/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func (l *loader) infinitelyRetry(req *request) {

func (l *loader) mutate(req *request) error {
txn := l.dc.NewTxn()
defer txn.Commit(l.opts.Ctx)
req.CommitNow = true
request := &api.Request{
CommitNow: true,
Expand Down
6 changes: 3 additions & 3 deletions edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ func authorizeRequest(ctx context.Context, qc *queryContext) error {
return nil
}

func checkPermissions(ctx context.Context, startTs uint64) error {
func validateNamespace(ctx context.Context, startTs uint64) error {
ns, err := x.ExtractJWTNamespace(ctx)
if err != nil {
return err
Expand All @@ -1487,7 +1487,7 @@ func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.Tx
}

if x.WorkerConfig.AclEnabled {
if err := checkPermissions(ctx, tc.StartTs); err != nil {
if err := validateNamespace(ctx, tc.StartTs); err != nil {
return &api.TxnContext{}, err
}
}
Expand All @@ -1504,11 +1504,11 @@ func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.Tx
if err == dgo.ErrAborted {
// If err returned is dgo.ErrAborted and tc.Aborted was set, that means the client has
// aborted the transaction by calling txn.Discard(). Hence return a nil error.
tctx.Aborted = true
if tc.Aborted {
return tctx, nil
}

tctx.Aborted = true
return tctx, status.Errorf(codes.Aborted, err.Error())
}
tctx.StartTs = tc.StartTs
Expand Down

0 comments on commit 37b65cf

Please sign in to comment.