Commit 01856bb7 authored by Nathan VanBenschoten's avatar Nathan VanBenschoten

config: more minor cleanups

Mostly cleaning up comments. Noticed while re-familiarizing
myself with this package.
parent 7be718ae
......@@ -516,11 +516,11 @@ func (s *SystemConfig) NeedsSplit(startKey, endKey roachpb.RKey) bool {
// shouldSplit checks if the ID is eligible for a split at all.
// It uses the internal cache to find a value, and tries to find
// it using the hook if ID isn't found in the cache.
func (s *SystemConfig) shouldSplit(ID uint32) bool {
func (s *SystemConfig) shouldSplit(id uint32) bool {
// Check the cache.
{
s.mu.RLock()
shouldSplit, ok := s.mu.shouldSplitCache[ID]
shouldSplit, ok := s.mu.shouldSplitCache[id]
s.mu.RUnlock()
if ok {
return shouldSplit
......@@ -528,17 +528,17 @@ func (s *SystemConfig) shouldSplit(ID uint32) bool {
}
var shouldSplit bool
if ID < keys.MinUserDescID {
if id < keys.MinUserDescID {
// The ID might be one of the reserved IDs that refer to ranges but not any
// actual descriptors.
shouldSplit = true
} else {
desc := s.GetDesc(keys.TODOSQLCodec.DescMetadataKey(ID))
desc := s.GetDesc(keys.TODOSQLCodec.DescMetadataKey(id))
shouldSplit = desc != nil && sqlbase.ShouldSplitAtDesc(desc)
}
// Populate the cache.
s.mu.Lock()
s.mu.shouldSplitCache[ID] = shouldSplit
s.mu.shouldSplitCache[id] = shouldSplit
s.mu.Unlock()
return shouldSplit
}
This diff was suppressed by a .gitattributes entry.
......@@ -26,11 +26,11 @@ message GCPolicy {
// TTLSeconds specifies the maximum age of a value before it's
// garbage collected. Only older versions of values are garbage
// collected. Specifying <=0 mean older versions are never GC'd.
// collected. Specifying <= 0 mean older versions are never GC'd.
optional int32 ttl_seconds = 1 [(gogoproto.nullable) = false, (gogoproto.customname) = "TTLSeconds"];
}
// Constraint constrains the stores a replica can be stored on.
// Constraint constrains the stores that a replica can be stored on.
message Constraint {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
......@@ -82,7 +82,7 @@ message LeasePreference {
// ZoneConfig holds configuration that applies to one or more ranges.
//
// Note: when adding.removing fields here, be sure to update
// Note: when adding/removing fields here, be sure to update
// supportedZoneConfigOptions in the sql package, to synchronize
// with the code for ALTER ... CONFIGURE ZONE.
message ZoneConfig {
......@@ -92,11 +92,14 @@ message ZoneConfig {
reserved 1;
optional int64 range_min_bytes = 2 [(gogoproto.moretags) = "yaml:\"range_min_bytes\""];
optional int64 range_max_bytes = 3 [(gogoproto.moretags) = "yaml:\"range_max_bytes\""];
// If GC policy is not set, uses the next highest, non-null policy
// in the zone config hierarchy, up to the default policy if necessary.
optional GCPolicy gc = 4 [(gogoproto.customname) = "GC"];
// NumReplicas specifies the desired number of replicas
optional int32 num_replicas = 5 [(gogoproto.moretags) = "yaml:\"num_replicas\""];
// Constraints constrains which stores the replicas can be stored on. The
// order in which the constraints are stored is arbitrary and may change.
// https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20160706_expressive_zone_config.md#constraint-system
......
......@@ -49,7 +49,7 @@ var zoneConfigCodec = keys.TODOSQLCodec
//
// This function must be kept in sync with ascendZoneSpecifier.
//
// if getInheritedDefault is true, the direct zone configuration, if it exists, is
// If getInheritedDefault is true, the direct zone configuration, if it exists, is
// ignored, and the default that would apply if it did not exist is returned instead.
func getZoneConfig(
id uint32, getKey func(roachpb.Key) (*roachpb.Value, error), getInheritedDefault bool,
......@@ -151,10 +151,13 @@ func completeZoneConfig(
return nil
}
// ZoneConfigHook returns the zone config for the object with id using the
// cached system config. If keySuffix is within a subzone, the subzone's config
// is returned instead. The bool is set to true when the value returned is
// cached.
// ZoneConfigHook returns the zone config and optional placeholder config for
// the object with id using the cached system config. The returned boolean is
// set to true when the zone config returned can be cached.
//
// ZoneConfigHook is a pure function whose only inputs are a system config and
// an object ID. It does not make any external KV calls to look up additional
// state.
func ZoneConfigHook(
cfg *config.SystemConfig, id uint32,
) (*zonepb.ZoneConfig, *zonepb.ZoneConfig, bool, error) {
......@@ -174,8 +177,13 @@ func ZoneConfigHook(
return zone, placeholder, true, nil
}
// GetZoneConfigInTxn looks up the zone and subzone for the specified
// object ID, index, and partition.
// GetZoneConfigInTxn looks up the zone and subzone for the specified object ID,
// index, and partition. See the documentation on getZoneConfig for information
// about the getInheritedDefault parameter.
//
// Unlike ZoneConfigHook, GetZoneConfigInTxn does not used a cached system
// config. Instead, it uses the provided txn to make transactionally consistent
// KV lookups.
func GetZoneConfigInTxn(
ctx context.Context,
txn *kv.Txn,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment