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

Method maxLease

dgraph/cmd/zero/assign.go:48–61  ·  view source on GitHub ↗

maxLease keeps track of the various ID leases that we have already achieved quorum on. This Server can hand out IDs <= maxLease, without the need for any more quorum. If a new server becomes Zero leader, they'd renew this lease and advance maxLease before handing out new IDs.

(typ pb.NumLeaseType)

Source from the content-addressed store, hash-verified

46// more quorum. If a new server becomes Zero leader, they'd renew this lease and
47// advance maxLease before handing out new IDs.
48func (s *Server) maxLease(typ pb.NumLeaseType) uint64 {
49 s.RLock()
50 defer s.RUnlock()
51 var maxlease uint64
52 switch typ {
53 case pb.Num_UID:
54 maxlease = s.state.MaxUID
55 case pb.Num_TXN_TS:
56 maxlease = s.state.MaxTxnTs
57 case pb.Num_NS_ID:
58 maxlease = s.state.MaxNsID
59 }
60 return maxlease
61}
62
63var errServedFromMemory = errors.New("Lease was served from memory")
64

Callers 1

leaseMethod · 0.95

Calls 2

RLockMethod · 0.80
RUnlockMethod · 0.80

Tested by

no test coverage detected