cockroach: github.com/cockroachdb/cockroach/pkg/config Index | Files | Directories

package config

import "github.com/cockroachdb/cockroach/pkg/config"

Index

Package Files

keys.go provider.go system.go system.pb.go testutil.go

Variables

var (
    ErrInvalidLengthSystem = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowSystem   = fmt.Errorf("proto: integer overflow")
)
var (
    // ZoneConfigHook is a function used to lookup a zone config given a system
    // tenant table or database ID.
    // This is also used by testing to simplify fake configs.
    ZoneConfigHook zoneConfigHook
)

func MakeZoneKey Uses

func MakeZoneKey(id SystemTenantObjectID) roachpb.Key

MakeZoneKey returns the key for id's entry in the system.zones table.

func MakeZoneKeyPrefix Uses

func MakeZoneKeyPrefix(id SystemTenantObjectID) roachpb.Key

MakeZoneKeyPrefix returns the key prefix for id's row in the system.zones table.

func StaticSplits Uses

func StaticSplits() []roachpb.RKey

StaticSplits are predefined split points in the system keyspace. Corresponding ranges are created at cluster bootstrap time.

There are two reasons for a static split. First, spans that are critical to cluster stability, like the node liveness span, are split into their own ranges to ease debugging (see #17297). Second, spans in the system keyspace that can be targeted by zone configs, like the meta span and the timeseries span, are split off into their own ranges because zone configs cannot apply to fractions of a range.

Note that these are not the only splits created at cluster bootstrap; splits between various system tables are also created.

func TestingSetZoneConfig Uses

func TestingSetZoneConfig(id SystemTenantObjectID, zone zonepb.ZoneConfig)

TestingSetZoneConfig sets the zone config entry for object 'id' in the testing map.

func TestingSetupZoneConfigHook Uses

func TestingSetupZoneConfigHook(stopper *stop.Stopper)

TestingSetupZoneConfigHook initializes the zone config hook to 'testingZoneConfigHook' which uses 'testingZoneConfig'. Settings go back to their previous values when the stopper runs our closer.

type EmptySystemConfigProvider Uses

type EmptySystemConfigProvider struct{}

EmptySystemConfigProvider is an implementation of SystemConfigProvider that never provides a system config.

func (EmptySystemConfigProvider) GetSystemConfig Uses

func (EmptySystemConfigProvider) GetSystemConfig() *SystemConfig

GetSystemConfig implements the SystemConfigProvider interface.

func (EmptySystemConfigProvider) RegisterSystemConfigChannel Uses

func (EmptySystemConfigProvider) RegisterSystemConfigChannel() <-chan struct{}

RegisterSystemConfigChannel implements the SystemConfigProvider interface.

type SystemConfig Uses

type SystemConfig struct {
    SystemConfigEntries
    DefaultZoneConfig *zonepb.ZoneConfig
    // contains filtered or unexported fields
}

SystemConfig embeds a SystemConfigEntries message which contains an entry for every system descriptor (e.g. databases, tables, zone configs). It also has a map from object ID to unmarshaled zone config for caching. The shouldSplitCache caches information about the descriptor ID, saying whether or not it should be considered for splitting at all. A database descriptor or a table view descriptor are examples of IDs that should not be considered for splits.

func NewSystemConfig Uses

func NewSystemConfig(defaultZoneConfig *zonepb.ZoneConfig) *SystemConfig

NewSystemConfig returns an initialized instance of SystemConfig.

func (*SystemConfig) ComputeSplitKey Uses

func (s *SystemConfig) ComputeSplitKey(
    ctx context.Context, startKey, endKey roachpb.RKey,
) (rr roachpb.RKey)

ComputeSplitKey takes a start and end key and returns the first key at which to split the span [start, end). Returns nil if no splits are required.

Splits are required between user tables (i.e. /table/<id>) in the system tenant, at the start of the system-config tables (i.e. /table/0), and at certain points within the system ranges that come before the system tables. The system-config range is somewhat special in that it can contain multiple SQL tables (/table/0-/table/<max-system-config-desc>) within a single range.

Splits are also required between secondary tenants (i.e. /tenant/<id>). However, splits are not required between the tables of secondary tenants.

func (*SystemConfig) Equal Uses

func (s *SystemConfig) Equal(other *SystemConfigEntries) bool

Equal checks for equality.

It assumes that s.Values and other.Values are sorted in key order.

func (*SystemConfig) GetIndex Uses

func (s *SystemConfig) GetIndex(key roachpb.Key) (int, bool)

GetIndex searches the kv list for 'key' and returns its index if found.

func (*SystemConfig) GetLargestObjectID Uses

func (s *SystemConfig) GetLargestObjectID(
    maxID SystemTenantObjectID, pseudoIDs []uint32,
) (SystemTenantObjectID, error)

GetLargestObjectID returns the largest object ID found in the config which is less than or equal to maxID. The objects in the config are augmented with the provided pseudo IDs. If maxID is 0, returns the largest ID in the config (again, augmented by the pseudo IDs).

func (*SystemConfig) GetValue Uses

func (s *SystemConfig) GetValue(key roachpb.Key) *roachpb.Value

GetValue searches the kv list for 'key' and returns its roachpb.Value if found.

func (*SystemConfig) GetZoneConfigForKey Uses

func (s *SystemConfig) GetZoneConfigForKey(key roachpb.RKey) (*zonepb.ZoneConfig, error)

GetZoneConfigForKey looks up the zone config for the object (table or database, specified by key.id). It is the caller's responsibility to ensure that the range does not need to be split.

func (*SystemConfig) GetZoneConfigForObject Uses

func (s *SystemConfig) GetZoneConfigForObject(
    codec keys.SQLCodec, id uint32,
) (*zonepb.ZoneConfig, error)

GetZoneConfigForObject returns the combined zone config for the given object identifier and SQL codec. NOTE: any subzones from the zone placeholder will be automatically merged into the cached zone so the caller doesn't need special-case handling code.

func (*SystemConfig) NeedsSplit Uses

func (s *SystemConfig) NeedsSplit(ctx context.Context, startKey, endKey roachpb.RKey) bool

NeedsSplit returns whether the range [startKey, endKey) needs a split due to zone configs.

type SystemConfigEntries Uses

type SystemConfigEntries struct {
    Values []roachpb.KeyValue `protobuf:"bytes,1,rep,name=values" json:"values"`
}

func (*SystemConfigEntries) Descriptor Uses

func (*SystemConfigEntries) Descriptor() ([]byte, []int)

func (*SystemConfigEntries) Marshal Uses

func (m *SystemConfigEntries) Marshal() (dAtA []byte, err error)

func (*SystemConfigEntries) MarshalTo Uses

func (m *SystemConfigEntries) MarshalTo(dAtA []byte) (int, error)

func (*SystemConfigEntries) ProtoMessage Uses

func (*SystemConfigEntries) ProtoMessage()

func (*SystemConfigEntries) Reset Uses

func (m *SystemConfigEntries) Reset()

func (*SystemConfigEntries) Size Uses

func (m *SystemConfigEntries) Size() (n int)

func (*SystemConfigEntries) String Uses

func (m *SystemConfigEntries) String() string

func (*SystemConfigEntries) Unmarshal Uses

func (m *SystemConfigEntries) Unmarshal(dAtA []byte) error

func (*SystemConfigEntries) XXX_DiscardUnknown Uses

func (m *SystemConfigEntries) XXX_DiscardUnknown()

func (*SystemConfigEntries) XXX_Marshal Uses

func (m *SystemConfigEntries) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SystemConfigEntries) XXX_Merge Uses

func (dst *SystemConfigEntries) XXX_Merge(src proto.Message)

func (*SystemConfigEntries) XXX_Size Uses

func (m *SystemConfigEntries) XXX_Size() int

func (*SystemConfigEntries) XXX_Unmarshal Uses

func (m *SystemConfigEntries) XXX_Unmarshal(b []byte) error

type SystemConfigProvider Uses

type SystemConfigProvider interface {
    // GetSystemConfig returns the local unmarshaled version of the system
    // config. Returns nil if the system config hasn't been set yet.
    GetSystemConfig() *SystemConfig

    // RegisterSystemConfigChannel registers a channel to signify updates for
    // the system config. It is notified after registration (if a system config
    // is already set), and whenever a new system config is successfully
    // unmarshaled.
    RegisterSystemConfigChannel() <-chan struct{}
}

SystemConfigProvider is capable of providing the SystemConfig, as well as notifying clients of updates to the SystemConfig.

type SystemTenantObjectID Uses

type SystemTenantObjectID uint32

SystemTenantObjectID is an identifier for an object (e.g. database or table) in the system tenant. Each object in the system tenant is capable of being associated with a zone configuration, which describes how and where the object's data is stored in KV. Some objects in the system tenant also serve as Range split point boundaries, see ShouldSplitAtDesc.

Identifiers for objects in secondary tenants are treated differently for the purposes of the system configuration. An individual object in a secondary tenant cannot be associated with a zone configuration. Instead, all secondary tenant data is associated with the "tenants" zone which is accessible only to the system tenant. Additionally, individual objects in secondary tenants do not serve as Range split boundaries. However, each tenant is guaranteed to be split off into its own range.

func DecodeKeyIntoZoneIDAndSuffix Uses

func DecodeKeyIntoZoneIDAndSuffix(key roachpb.RKey) (id SystemTenantObjectID, keySuffix []byte)

DecodeKeyIntoZoneIDAndSuffix figures out the zone that the key belongs to.

func DecodeSystemTenantObjectID Uses

func DecodeSystemTenantObjectID(key roachpb.RKey) (SystemTenantObjectID, []byte, bool)

DecodeSystemTenantObjectID decodes the object ID for the system-tenant from the front of key. It returns the decoded object ID, the remainder of the key, and whether the result is valid (i.e., whether the key was within the system tenant's structured key space).

Directories

PathSynopsis
zonepb

Package config imports 14 packages (graph) and is imported by 429 packages. Updated 2020-08-05. Refresh now. Tools for package owners.