Skip to content

Commit

Permalink
Add comment to explain the txn proposal race condition.
Browse files Browse the repository at this point in the history
  • Loading branch information
manishrjain committed May 15, 2018
1 parent e896c17 commit eccc939
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dgraph/cmd/zero/oracle.go
Expand Up @@ -297,9 +297,11 @@ func (s *Server) commit(ctx context.Context, src *api.TxnContext) error {
}
// Propose txn should be used to set watermark as done.
err = s.proposeTxn(ctx, src)
// TODO: Ideally proposal should throw error if it was already aborted due to race.
// There might be race between this proposal trying to commit and predicate
// move aborting it.
// move aborting it. A predicate move, triggered by Zero, would abort all pending transactions.
// At the same time, a client which has already done mutations, can proceed to commit it. A race
// condition can happen here, with both proposing their respective states, only one can succeed
// after the proposal is done. So, check again to see the fate of the transaction here.
if s.orc.aborted(src.StartTs) {
src.Aborted = true
}
Expand Down

0 comments on commit eccc939

Please sign in to comment.