cockroach: Index | Files

package kvbase

import ""

Package kvbase exports kv level interfaces to avoid dependency cycles.


Package Files

constants.go range_cache.go


const FollowerReadServingMsg = "serving via follower read"

FollowerReadServingMsg is a log message that needs to be used for tests in other packages.

type RangeCacheEntry Uses

type RangeCacheEntry struct {
    // Desc is always populated.
    Desc roachpb.RangeDescriptor
    // Lease has info on the range's lease. It can be Empty() if no lease
    // information is known. When a lease is known, it is guaranteed that the
    // lease comes from Desc's range id (i.e. we'll never put a lease from another
    // range in here). This allows UpdateLease() to use Lease.Sequence to compare
    // leases. Moreover, the lease will correspond to one of the replicas in Desc.
    Lease roachpb.Lease

RangeCacheEntry represents one cache entry.

The cache stores *RangeCacheEntry. Entries are immutable: cache lookups returns the same *RangeCacheEntry to multiple queriers for efficiency, but nobody should modify the lookup result.

func (*RangeCacheEntry) NewerThan Uses

func (e *RangeCacheEntry) NewerThan(o *RangeCacheEntry) bool

NewerThan returns true if the receiver represents newer information about the range than o. The descriptors are assumed to be overlapping.

When comparing two overlapping entries for deciding which one is stale, the descriptor's generation is checked first. For equal descriptor generations, the lease sequence number is checked second. For equal lease sequences, returns false. Note that this means that an Empty() e.Lease is considered older than any lease in o.

func (RangeCacheEntry) String Uses

func (e RangeCacheEntry) String() string

func (*RangeCacheEntry) UpdateLease Uses

func (e *RangeCacheEntry) UpdateLease(l *roachpb.Lease) (updated bool, newEntry *RangeCacheEntry)

UpdateLease returns a new RangeCacheEntry with the receiver's descriptor and a new lease. The updated retval indicates whether the passed-in lease appears to be newer than the lease the entry had before. If updated is returned true, the caller should evict the existing entry (the receiver) and replace it with newEntry. (true, nil) can be returned meaning that the existing entry should be evicted, but there's no replacement that this function can provide; this happens when the passed-in lease indicates a leaseholder that's not part of the entry's descriptor. The descriptor must be really stale, and the caller should read a new version.

If updated=false is returned, then newEntry will be the same as the receiver. This means that the passed-in lease is older than the lease already in the entry.

If the new leaseholder is not a replica in the descriptor, we assume the lease information to be more recent than the entry's descriptor, and we return true, nil. The caller should evict the receiver from the cache, but it'll have to do extra work to figure out what to insert instead.

type RangeDescriptorCache Uses

type RangeDescriptorCache interface {
    // Lookup looks up range information for the range containing key.
    Lookup(ctx context.Context, key roachpb.RKey) (*RangeCacheEntry, error)

RangeDescriptorCache is a simplified interface to the kv.RangeDescriptorCache for use at lower levels of the stack like storage.

Package kvbase imports 4 packages (graph) and is imported by 15 packages. Updated 2020-08-09. Refresh now. Tools for package owners.