Skip to content

Commit c7a66bd

Browse files
author
Pawan Rawal
committed
Return error from Commit if startTs is zero
1 parent d6acf3c commit c7a66bd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

edgraph/server.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ import (
3333

3434
"github.com/dgraph-io/badger"
3535
"github.com/dgraph-io/badger/options"
36-
"github.com/dgraph-io/dgraph/gql"
3736
"github.com/dgraph-io/dgo/protos/api"
37+
"github.com/dgraph-io/dgo/y"
38+
"github.com/dgraph-io/dgraph/gql"
3839
"github.com/dgraph-io/dgraph/protos/intern"
3940
"github.com/dgraph-io/dgraph/query"
4041
"github.com/dgraph-io/dgraph/rdf"
4142
"github.com/dgraph-io/dgraph/schema"
4243
"github.com/dgraph-io/dgraph/types/facets"
4344
"github.com/dgraph-io/dgraph/worker"
4445
"github.com/dgraph-io/dgraph/x"
45-
"github.com/dgraph-io/dgo/y"
4646
"github.com/pkg/errors"
4747
)
4848

@@ -470,6 +470,9 @@ func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.Tx
470470

471471
tctx := &api.TxnContext{}
472472

473+
if tc.StartTs == 0 {
474+
return &api.TxnContext{}, fmt.Errorf("StartTs cannot be zero while committing a transaction.")
475+
}
473476
commitTs, err := worker.CommitOverNetwork(ctx, tc)
474477
if err == y.ErrAborted {
475478
tctx.Aborted = true

0 commit comments

Comments
 (0)