diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index fce0b5a63f44..718dd80e9e2b 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -193,4 +193,4 @@ trace.jaeger.agent string the address of a Jaeger agent to receive traces using trace.opentelemetry.collector string address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as :. If no port is specified, 4317 will be used. trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https:///#/debug/tracez trace.zipkin.collector string the address of a Zipkin instance to receive traces, as :. If no port is specified, 9411 will be used. -version version 21.2-100 set the active cluster version in the format '.' +version version 21.2-1002 set the active cluster version in the format '.' diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index f69603aed773..78049028f164 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -209,6 +209,6 @@ trace.opentelemetry.collectorstringaddress of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as :. If no port is specified, 4317 will be used. trace.span_registry.enabledbooleantrueif set, ongoing traces can be seen at https:///#/debug/tracez trace.zipkin.collectorstringthe address of a Zipkin instance to receive traces, as :. If no port is specified, 9411 will be used. -versionversion21.2-100set the active cluster version in the format '.' +versionversion21.2-1002set the active cluster version in the format '.' diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index 00958028d461..b6808a5d35fa 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -332,6 +332,16 @@ const ( // table settings. AutoStatsTableSettings + // EnsurePebbleFormatVersionRangeKeys is the first step of a two-part + // migration that bumps Pebble's format major version to a version that + // supports range keys. + EnsurePebbleFormatVersionRangeKeys + // EnablePebbleFormatVersionRangeKeys is the second of a two-part migration + // and is used as the feature gate for use of range keys. Any node at this + // version is guaranteed to reside in a cluster where all nodes support range + // keys at the Pebble layer. + EnablePebbleFormatVersionRangeKeys + // ************************************************* // Step (1): Add new versions here. // Do not add new versions to a patch release. @@ -558,6 +568,17 @@ var versionsSingleton = keyedVersions{ Key: AutoStatsTableSettings, Version: roachpb.Version{Major: 21, Minor: 2, Internal: 100}, }, + + // TODO(erikgrinaker): These must be moved to 22.1 when the version exists. + { + Key: EnsurePebbleFormatVersionRangeKeys, + Version: roachpb.Version{Major: 21, Minor: 2, Internal: 1000}, + }, + { + Key: EnablePebbleFormatVersionRangeKeys, + Version: roachpb.Version{Major: 21, Minor: 2, Internal: 1002}, + }, + // ************************************************* // Step (2): Add new versions here. // Do not add new versions to a patch release. diff --git a/pkg/clusterversion/key_string.go b/pkg/clusterversion/key_string.go index cb80ab332c58..06d8738c8784 100644 --- a/pkg/clusterversion/key_string.go +++ b/pkg/clusterversion/key_string.go @@ -56,11 +56,13 @@ func _() { _ = x[EnableNewStoreRebalancer-45] _ = x[ClusterLocksVirtualTable-46] _ = x[AutoStatsTableSettings-47] + _ = x[EnsurePebbleFormatVersionRangeKeys-48] + _ = x[EnablePebbleFormatVersionRangeKeys-49] } -const _Key_name = "V21_2Start22_1TargetBytesAvoidExcessAvoidDrainingNamesDrainingNamesMigrationTraceIDDoesntImplyStructuredRecordingAlterSystemTableStatisticsAddAvgSizeColAlterSystemStmtDiagReqsMVCCAddSSTableInsertPublicSchemaNamespaceEntryOnRestoreUnsplitRangesInAsyncGCJobsValidateGrantOptionPebbleFormatBlockPropertyCollectorProbeRequestSelectRPCsTakeTracingInfoInbandPreSeedTenantSpanConfigsSeedTenantSpanConfigsPublicSchemasWithDescriptorsEnsureSpanConfigReconciliationEnsureSpanConfigSubscriptionEnableSpanConfigStoreScanWholeRowsSCRAMAuthenticationUnsafeLossOfQuorumRecoveryRangeLogAlterSystemProtectedTimestampAddColumnEnableProtectedTimestampsForTenantDeleteCommentsWithDroppedIndexesRemoveIncompatibleDatabasePrivilegesAddRaftAppliedIndexTermMigrationPostAddRaftAppliedIndexTermMigrationDontProposeWriteTimestampForLeaseTransfersTenantSettingsTableEnablePebbleFormatVersionBlockPropertiesDisableSystemConfigGossipTriggerMVCCIndexBackfillerEnableLeaseHolderRemovalBackupResolutionInJobLooselyCoupledRaftLogTruncationChangefeedIdlenessBackupDoesNotOverwriteLatestAndCheckpointEnableDeclarativeSchemaChangerRowLevelTTLPebbleFormatSplitUserKeysMarkedIncrementalBackupSubdirDateStyleIntervalStyleCastRewriteEnableNewStoreRebalancerClusterLocksVirtualTableAutoStatsTableSettings" +const _Key_name = "V21_2Start22_1TargetBytesAvoidExcessAvoidDrainingNamesDrainingNamesMigrationTraceIDDoesntImplyStructuredRecordingAlterSystemTableStatisticsAddAvgSizeColAlterSystemStmtDiagReqsMVCCAddSSTableInsertPublicSchemaNamespaceEntryOnRestoreUnsplitRangesInAsyncGCJobsValidateGrantOptionPebbleFormatBlockPropertyCollectorProbeRequestSelectRPCsTakeTracingInfoInbandPreSeedTenantSpanConfigsSeedTenantSpanConfigsPublicSchemasWithDescriptorsEnsureSpanConfigReconciliationEnsureSpanConfigSubscriptionEnableSpanConfigStoreScanWholeRowsSCRAMAuthenticationUnsafeLossOfQuorumRecoveryRangeLogAlterSystemProtectedTimestampAddColumnEnableProtectedTimestampsForTenantDeleteCommentsWithDroppedIndexesRemoveIncompatibleDatabasePrivilegesAddRaftAppliedIndexTermMigrationPostAddRaftAppliedIndexTermMigrationDontProposeWriteTimestampForLeaseTransfersTenantSettingsTableEnablePebbleFormatVersionBlockPropertiesDisableSystemConfigGossipTriggerMVCCIndexBackfillerEnableLeaseHolderRemovalBackupResolutionInJobLooselyCoupledRaftLogTruncationChangefeedIdlenessBackupDoesNotOverwriteLatestAndCheckpointEnableDeclarativeSchemaChangerRowLevelTTLPebbleFormatSplitUserKeysMarkedIncrementalBackupSubdirDateStyleIntervalStyleCastRewriteEnableNewStoreRebalancerClusterLocksVirtualTableAutoStatsTableSettingsEnsurePebbleFormatVersionRangeKeysEnablePebbleFormatVersionRangeKeys" -var _Key_index = [...]uint16{0, 5, 14, 36, 54, 76, 113, 152, 175, 189, 230, 256, 275, 309, 321, 352, 376, 397, 425, 455, 483, 504, 517, 536, 570, 608, 642, 674, 710, 742, 778, 820, 839, 879, 911, 930, 954, 975, 1006, 1024, 1065, 1095, 1106, 1137, 1160, 1193, 1217, 1241, 1263} +var _Key_index = [...]uint16{0, 5, 14, 36, 54, 76, 113, 152, 175, 189, 230, 256, 275, 309, 321, 352, 376, 397, 425, 455, 483, 504, 517, 536, 570, 608, 642, 674, 710, 742, 778, 820, 839, 879, 911, 930, 954, 975, 1006, 1024, 1065, 1095, 1106, 1137, 1160, 1193, 1217, 1241, 1263, 1297, 1331} func (i Key) String() string { if i < 0 || i >= Key(len(_Key_index)-1) { diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index 2457a6798697..7ba54339f305 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -1630,6 +1630,10 @@ func (p *Pebble) SetMinVersion(version roachpb.Version) error { formatVers := pebble.FormatMostCompatible // Cases are ordered from newer to older versions. switch { + case !version.Less(clusterversion.ByKey(clusterversion.EnsurePebbleFormatVersionRangeKeys)): + if formatVers < pebble.FormatRangeKeys { + formatVers = pebble.FormatRangeKeys + } case !version.Less(clusterversion.ByKey(clusterversion.PebbleFormatSplitUserKeysMarked)): if formatVers < pebble.FormatSplitUserKeysMarked { formatVers = pebble.FormatSplitUserKeysMarked diff --git a/pkg/storage/sst_writer.go b/pkg/storage/sst_writer.go index 0cff9a55897a..779767b26c1a 100644 --- a/pkg/storage/sst_writer.go +++ b/pkg/storage/sst_writer.go @@ -63,6 +63,8 @@ func MakeIngestionWriterOptions(ctx context.Context, cs *cluster.Settings) sstab format := sstable.TableFormatRocksDBv2 // Cases are ordered from newer to older versions. switch { + case cs.Version.IsActive(ctx, clusterversion.EnablePebbleFormatVersionRangeKeys): + format = sstable.TableFormatPebblev2 // Range keys. case cs.Version.IsActive(ctx, clusterversion.EnablePebbleFormatVersionBlockProperties): format = sstable.TableFormatPebblev1 // Block properties. } @@ -77,11 +79,14 @@ func MakeIngestionWriterOptions(ctx context.Context, cs *cluster.Settings) sstab // MakeBackupSSTWriter creates a new SSTWriter tailored for backup SSTs which // are typically only ever iterated in their entirety. -func MakeBackupSSTWriter(_ context.Context, _ *cluster.Settings, f io.Writer) SSTWriter { +func MakeBackupSSTWriter(ctx context.Context, cs *cluster.Settings, f io.Writer) SSTWriter { // By default, take a conservative approach and assume we don't have newer // table features available. Upgrade to an appropriate version only if the // cluster supports it. opts := DefaultPebbleOptions().MakeWriterOptions(0, sstable.TableFormatRocksDBv2) + if cs.Version.IsActive(ctx, clusterversion.EnablePebbleFormatVersionRangeKeys) { + opts.TableFormat = sstable.TableFormatPebblev2 // Range keys. + } // Don't need BlockPropertyCollectors for backups. opts.BlockPropertyCollectors = nil