Skip to content

Commit

Permalink
clusterversion: move version comments next to definition
Browse files Browse the repository at this point in the history
Jump to symbol for a given version tag will now group together the
intent of the version itself (instead of expecting readers to know to
grep for the same version in the block below).

Release note: None
  • Loading branch information
irfansharif committed Nov 27, 2020
1 parent d98aa66 commit a506329
Showing 1 changed file with 96 additions and 75 deletions.
171 changes: 96 additions & 75 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type VersionKey int
//
// func someRPC(req) {
// if !req.NewFeatureFlag {
// // Legacy behaviour...
// // Legacy behavior...
// }
// // There's no need to even check if the specific-version is active.
// // If the flag is enabled, the specific-version must have been
Expand Down Expand Up @@ -114,35 +114,126 @@ type VersionKey int
//go:generate stringer -type=VersionKey
const (
_ VersionKey = iota - 1 // want first named one to start at zero

// Version19_1 is CockroachDB v19.1. It's used for all v19.1.x patch
// releases.
Version19_1

// v20.1 versions.
//
// VersionContainsEstimatesCounter is
// https://github.com/cockroachdb/cockroach/pull/37583.
//
// MVCCStats.ContainsEstimates has been migrated from boolean to a
// counter so that the consistency checker and splits can reset it by
// returning -ContainsEstimates, avoiding racing with other operations
// that want to also change it.
//
// The migration maintains the invariant that raft commands with
// ContainsEstimates zero or one want the bool behavior (i.e. 1+1=1).
// Before the cluster version is active, at proposal time we'll refuse
// any negative ContainsEstimates plus we clamp all others to {0,1}.
// When the version is active, and ContainsEstimates is positive, we
// multiply it by 2 (i.e. we avoid 1). Downstream of raft, we use old
// behavior for ContainsEstimates=1 and the additive behavior for
// anything else.
VersionContainsEstimatesCounter
// VersionNamespaceTableWithSchemas is
// https://github.com/cockroachdb/cockroach/pull/41977
//
// It represents the migration to a new system.namespace table that has an
// added parentSchemaID column. In addition to the new column, the table is
// no longer in the system config range -- implying it is no longer gossiped.
VersionNamespaceTableWithSchemas
// VersionAuthLocalAndTrustRejectMethods introduces the HBA rule
// prefix 'local' and auth methods 'trust' and 'reject', for use
// in server.host_based_authentication.configuration.
//
// A separate cluster version ensures the new syntax is not
// introduced while previous-version nodes are still running, as
// this would block any new SQL client.
VersionAuthLocalAndTrustRejectMethods

// TODO(irfansharif): The versions above can/should all be removed. They
// were orinally introduced in v20.1. There are inflight PRs to do so
// (#57155, #57156, #57158).

// v20.2 versions.
//
// VersionStart20_2 demarcates work towards CockroachDB v20.2.
VersionStart20_2
// VersionGeospatialType enables the use of Geospatial features.
VersionGeospatialType
// VersionEnums enables the use of ENUM types.
VersionEnums
// VersionRangefeedLeases is the enablement of leases uses rangefeeds. All
// nodes with this versions will have rangefeeds enabled on all system
// ranges. Once this version is finalized, gossip is not needed in the
// schema lease subsystem. Nodes which start with this version finalized
// will not pass gossip to the SQL layer.
VersionRangefeedLeases
// VersionAlterColumnTypeGeneral enables the use of alter column type for
// conversions that require the column data to be rewritten.
VersionAlterColumnTypeGeneral
// VersionAlterSystemJobsTable is a version which modified system.jobs
// table.
VersionAlterSystemJobsAddCreatedByColumns
// VersionAddScheduledJobsTable is a version which adds
// system.scheduled_jobs table.
VersionAddScheduledJobsTable
// VersionUserDefinedSchemas enables the creation of user defined schemas.
VersionUserDefinedSchemas
// VersionNoOriginFKIndexes allows for foreign keys to no longer need
// indexes on the origin side of the relationship.
VersionNoOriginFKIndexes
// VersionClientRangeInfosOnBatchResponse moves the response RangeInfos from
// individual response headers to the batch header.
VersionClientRangeInfosOnBatchResponse
// VersionNodeMembershipStatus gates the usage of the MembershipStatus enum
// in the Liveness proto. See comment on proto definition for more details.
VersionNodeMembershipStatus
// VersionRangeStatsRespHasDesc adds the RangeStatsResponse.RangeInfo field.
VersionRangeStatsRespHasDesc
// VersionMinPasswordLength adds the server.user_login.min_password_length
// setting.
VersionMinPasswordLength
// VersionAbortSpanBytes adds a field to MVCCStats
// (MVCCStats.AbortSpanBytes) that tracks the size of a range's abort span.
VersionAbortSpanBytes
// VersionAlterSystemJobsTableAddLeaseColumn is a version which modified
// system.jobs table.
VersionAlterSystemJobsAddSqllivenessColumnsAddNewSystemSqllivenessTable
// VersionMaterializedViews enables the use of materialized views.
VersionMaterializedViews
// VersionBox2DType enables the use of the box2d type.
VersionBox2DType
// VersionLeasedDatabasedDescriptors enables leased database descriptors.
// Now that we unconditionally use leased descriptors in 21.1 and the main
// usages of this version gate have been removed, this version remains to
// gate a few miscellaneous database descriptor changes.
VersionLeasedDatabaseDescriptors
// VersionUpdateScheduledJobsSchema drops schedule_changes and adds
// schedule_status.
VersionUpdateScheduledJobsSchema
// VersionCreateLoginPrivilege is when CREATELOGIN/NOCREATELOGIN are
// introduced.
//
// It represents adding authn principal management via CREATELOGIN role
// option.
VersionCreateLoginPrivilege
// VersionHBAForNonTLS is when the 'hostssl' and 'hostnossl' HBA configs are
// introduced.
VersionHBAForNonTLS
// Version20_2 is CockroachDB v20.2. It's used for all v20.2.x patch
// releases.
Version20_2

// v21.1 versions.
//
// VersionStart21_1 demarcates work towards CockroachDB v21.1.
VersionStart21_1
// VersionEmptyArraysInInvertedIndexes is when empty arrays are added to
// array inverted indexes.
VersionEmptyArraysInInvertedIndexes

// Step (1): Add new versions here.
Expand All @@ -167,188 +258,118 @@ const (
// to be added (i.e., when cutting the final release candidate).
var versionsSingleton = keyedVersions([]keyedVersion{
{
// Version19_1 is CockroachDB v19.1. It's used for all v19.1.x patch releases.
Key: Version19_1,
Version: roachpb.Version{Major: 19, Minor: 1},
},
{
// VersionContainsEstimatesCounter is https://github.com/cockroachdb/cockroach/pull/37583.
//
// MVCCStats.ContainsEstimates has been migrated from boolean to a
// counter so that the consistency checker and splits can reset it by
// returning -ContainsEstimates, avoiding racing with other operations
// that want to also change it.
//
// The migration maintains the invariant that raft commands with
// ContainsEstimates zero or one want the bool behavior (i.e. 1+1=1).
// Before the cluster version is active, at proposal time we'll refuse
// any negative ContainsEstimates plus we clamp all others to {0,1}.
// When the version is active, and ContainsEstimates is positive, we
// multiply it by 2 (i.e. we avoid 1). Downstream of raft, we use old
// behavior for ContainsEstimates=1 and the additive behavior for
// anything else.
Key: VersionContainsEstimatesCounter,
Version: roachpb.Version{Major: 19, Minor: 2, Internal: 2},
},
{
// VersionNamespaceTableWithSchemas is https://github.com/cockroachdb/cockroach/pull/41977
//
// It represents the migration to a new system.namespace table that has an
// added parentSchemaID column. In addition to the new column, the table is
// no longer in the system config range -- implying it is no longer gossiped.
Key: VersionNamespaceTableWithSchemas,
Version: roachpb.Version{Major: 19, Minor: 2, Internal: 5},
},
{
// VersionAuthLocalAndTrustRejectMethods introduces the HBA rule
// prefix 'local' and auth methods 'trust' and 'reject', for use
// in server.host_based_authentication.configuration.
//
// A separate cluster version ensures the new syntax is not
// introduced while previous-version nodes are still running, as
// this would block any new SQL client.
Key: VersionAuthLocalAndTrustRejectMethods,
Version: roachpb.Version{Major: 19, Minor: 2, Internal: 8},
},

// v20.2 versions.
{
// VersionStart20_2 demarcates work towards CockroachDB v20.2.
Key: VersionStart20_2,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 1},
},
{

// VersionGeospatialType enables the use of Geospatial features.
Key: VersionGeospatialType,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 2},
},
{
// VersionEnums enables the use of ENUM types.
Key: VersionEnums,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 3},
},
{

// VersionRangefeedLeases is the enablement of leases uses rangefeeds.
// All nodes with this versions will have rangefeeds enabled on all system
// ranges. Once this version is finalized, gossip is not needed in the
// schema lease subsystem. Nodes which start with this version finalized
// will not pass gossip to the SQL layer.
Key: VersionRangefeedLeases,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 4},
},
{
// VersionAlterColumnTypeGeneral enables the use of alter column type for
// conversions that require the column data to be rewritten.
Key: VersionAlterColumnTypeGeneral,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 5},
},
{
// VersionAlterSystemJobsTable is a version which modified system.jobs table.
Key: VersionAlterSystemJobsAddCreatedByColumns,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 6},
},
{
// VersionAddScheduledJobsTable is a version which adds system.scheduled_jobs table.
Key: VersionAddScheduledJobsTable,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 7},
},
{
// VersionUserDefinedSchemas enables the creation of user defined schemas.
Key: VersionUserDefinedSchemas,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 8},
},
{
// VersionNoOriginFKIndexes allows for foreign keys to no longer need
// indexes on the origin side of the relationship.
Key: VersionNoOriginFKIndexes,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 9},
},
{
// VersionClientRangeInfosOnBatchResponse moves the response RangeInfos from
// individual response headers to the batch header.
Key: VersionClientRangeInfosOnBatchResponse,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 10},
},
{
// VersionNodeMembershipStatus gates the usage of the MembershipStatus
// enum in the Liveness proto. See comment on proto definition for more
// details.
Key: VersionNodeMembershipStatus,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 11},
},
{
// VersionRangeStatsRespHasDesc adds the RangeStatsResponse.RangeInfo field.
Key: VersionRangeStatsRespHasDesc,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 12},
},
{
// VersionMinPasswordLength adds the server.user_login.min_password_length setting.
Key: VersionMinPasswordLength,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 13},
},
{
// VersionAbortSpanBytes adds a field to MVCCStats
// (MVCCStats.AbortSpanBytes) that tracks the size of a
// range's abort span.
Key: VersionAbortSpanBytes,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 14},
},
{
// VersionAlterSystemJobsTableAddLeaseColumn is a version which modified system.jobs table.
Key: VersionAlterSystemJobsAddSqllivenessColumnsAddNewSystemSqllivenessTable,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 15},
},
{
// VersionMaterializedViews enables the use of materialized views.
Key: VersionMaterializedViews,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 16},
},
{
// VersionBox2DType enables the use of the box2d type.
Key: VersionBox2DType,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 17},
},
{
// VersionLeasedDatabasedDescriptors enables leased database descriptors.
// Now that we unconditionally use leased descriptors in 21.1 and the main
// usages of this version gate have been removed, this version remains to
// gate a few miscellaneous database descriptor changes.
Key: VersionLeasedDatabaseDescriptors,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 18},
},
{
// VersionUpdateScheduledJobsSchema drops schedule_changes and adds schedule_status.
Key: VersionUpdateScheduledJobsSchema,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 19},
},
{
// VersionCreateLoginPrivilege is when CREATELOGIN/NOCREATELOGIN
// are introduced.
//
// It represents adding authn principal management via CREATELOGIN
// role option.
Key: VersionCreateLoginPrivilege,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 20},
},
{
// VersionHBAForNonTLS is when the 'hostssl' and 'hostnossl' HBA
// configs are introduced.
Key: VersionHBAForNonTLS,
Version: roachpb.Version{Major: 20, Minor: 1, Internal: 21},
},
{
// Version20_2 is CockroachDB v20.2. It's used for all v20.2.x patch releases.
Key: Version20_2,
Version: roachpb.Version{Major: 20, Minor: 2},
},

// v21.1 versions.
{
// VersionStart21_1 demarcates work towards CockroachDB v21.1.
Key: VersionStart21_1,
Version: roachpb.Version{Major: 20, Minor: 2, Internal: 1},
},
{
// VersionEmptyArraysInInvertedIndexes is when empty arrays are added to
// array inverted indexes.
Key: VersionEmptyArraysInInvertedIndexes,
Version: roachpb.Version{Major: 20, Minor: 2, Internal: 2},
},
Expand Down

0 comments on commit a506329

Please sign in to comment.