MCPcopy
hub / github.com/dgraph-io/badger / commitPrecheck

Method commitPrecheck

txn.go:615–635  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

613}
614
615func (txn *Txn) commitPrecheck() error {
616 if txn.discarded {
617 return errors.New("Trying to commit a discarded txn")
618 }
619 keepTogether := true
620 for _, e := range txn.pendingWrites {
621 if e.version != 0 {
622 keepTogether = false
623 }
624 }
625
626 // If keepTogether is True, it implies transaction markers will be added.
627 // In that case, commitTs should not be never be zero. This might happen if
628 // someone uses txn.Commit instead of txn.CommitAt in managed mode. This
629 // should happen only in managed mode. In normal mode, keepTogether will
630 // always be true.
631 if keepTogether && txn.db.opt.managedTxns && txn.commitTs == 0 {
632 return errors.New("CommitTs cannot be zero. Please use commitAt instead")
633 }
634 return nil
635}
636
637// Commit commits the transaction, following these steps:
638//

Callers 2

CommitMethod · 0.95
CommitWithMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected