MCPcopy
hub / github.com/dgraph-io/dgraph / blockingAbort

Method blockingAbort

worker/draft.go:1673–1709  ·  view source on GitHub ↗
(req *pb.TxnTimestamps)

Source from the content-addressed store, hash-verified

1671var errNoConnection = errors.New("No connection exists")
1672
1673func (n *node) blockingAbort(req *pb.TxnTimestamps) error {
1674 pl := groups().Leader(0)
1675 if pl == nil {
1676 return errNoConnection
1677 }
1678 zc := pb.NewZeroClient(pl.Get())
1679 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
1680 defer cancel()
1681
1682 delta, err := zc.TryAbort(ctx, req)
1683 glog.Infof("TryAbort %d txns with start ts. Error: %v\n", len(req.Ts), err)
1684 if err != nil || len(delta.Txns) == 0 {
1685 return err
1686 }
1687
1688 // Let's propose the txn updates received from Zero. This is important because there are edge
1689 // cases where a txn status might have been missed by the group.
1690 aborted := &pb.OracleDelta{}
1691 for _, txn := range delta.Txns {
1692 // Only pick the aborts. DO NOT propose the commits. They must come in the right order via
1693 // oracle delta stream, otherwise, we'll end up losing some committed txns.
1694 if txn.CommitTs == 0 {
1695 aborted.Txns = append(aborted.Txns, txn)
1696 }
1697 }
1698 if len(aborted.Txns) == 0 {
1699 glog.Infoln("TryAbort: No aborts found. Quitting.")
1700 return nil
1701 }
1702
1703 // We choose not to store the MaxAssigned, because it would cause our Oracle to move ahead
1704 // artificially. The Oracle delta stream moves that ahead in the right order, and we shouldn't
1705 // muck with that order here.
1706 glog.Infof("TryAbort selectively proposing only aborted txns: %+v\n", aborted)
1707 proposal := &pb.Proposal{Delta: aborted}
1708 return n.proposeAndWait(n.ctx, proposal)
1709}
1710
1711// abortOldTransactions would find txns which have done pre-writes, but have been pending for a
1712// while. The time that is used is based on the last pre-write seen, so if a txn is doing a

Callers 2

abortOldTransactionsMethod · 0.95
tryAbortTransactionsFunction · 0.80

Calls 7

TryAbortMethod · 0.95
proposeAndWaitMethod · 0.95
NewZeroClientFunction · 0.92
groupsFunction · 0.85
InfofMethod · 0.80
GetMethod · 0.65
LeaderMethod · 0.45

Tested by

no test coverage detected