diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index 3219ab0366c8..a4346df0b62b 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-94 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 f9d81cf6434e..acd7eedd2f81 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -208,6 +208,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-94set 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 4c2aa5c05b68..a0bccb86d6a2 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -321,6 +321,15 @@ const ( // DateStyleIntervalStyleCastRewrite rewrites cast that cause inconsistencies // when DateStyle/IntervalStyle is enabled. DateStyleIntervalStyleCastRewrite + // 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. @@ -537,6 +546,16 @@ var versionsSingleton = keyedVersions{ Version: roachpb.Version{Major: 21, Minor: 2, Internal: 94}, }, + // 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 aeeabfb57c4e..9e4357ce5969 100644 --- a/pkg/clusterversion/key_string.go +++ b/pkg/clusterversion/key_string.go @@ -53,11 +53,13 @@ func _() { _ = x[PebbleFormatSplitUserKeysMarked-42] _ = x[IncrementalBackupSubdir-43] _ = x[DateStyleIntervalStyleCastRewrite-44] + _ = x[EnsurePebbleFormatVersionRangeKeys-45] + _ = x[EnablePebbleFormatVersionRangeKeys-46] } -const _Key_name = "V21_2Start22_1TargetBytesAvoidExcessAvoidDrainingNamesDrainingNamesMigrationTraceIDDoesntImplyStructuredRecordingAlterSystemTableStatisticsAddAvgSizeColAlterSystemStmtDiagReqsMVCCAddSSTableInsertPublicSchemaNamespaceEntryOnRestoreUnsplitRangesInAsyncGCJobsValidateGrantOptionPebbleFormatBlockPropertyCollectorProbeRequestSelectRPCsTakeTracingInfoInbandPreSeedTenantSpanConfigsSeedTenantSpanConfigsPublicSchemasWithDescriptorsEnsureSpanConfigReconciliationEnsureSpanConfigSubscriptionEnableSpanConfigStoreScanWholeRowsSCRAMAuthenticationUnsafeLossOfQuorumRecoveryRangeLogAlterSystemProtectedTimestampAddColumnEnableProtectedTimestampsForTenantDeleteCommentsWithDroppedIndexesRemoveIncompatibleDatabasePrivilegesAddRaftAppliedIndexTermMigrationPostAddRaftAppliedIndexTermMigrationDontProposeWriteTimestampForLeaseTransfersTenantSettingsTableEnablePebbleFormatVersionBlockPropertiesDisableSystemConfigGossipTriggerMVCCIndexBackfillerEnableLeaseHolderRemovalBackupResolutionInJobLooselyCoupledRaftLogTruncationChangefeedIdlenessBackupDoesNotOverwriteLatestAndCheckpointEnableDeclarativeSchemaChangerRowLevelTTLPebbleFormatSplitUserKeysMarkedIncrementalBackupSubdirDateStyleIntervalStyleCastRewrite" +const _Key_name = "V21_2Start22_1TargetBytesAvoidExcessAvoidDrainingNamesDrainingNamesMigrationTraceIDDoesntImplyStructuredRecordingAlterSystemTableStatisticsAddAvgSizeColAlterSystemStmtDiagReqsMVCCAddSSTableInsertPublicSchemaNamespaceEntryOnRestoreUnsplitRangesInAsyncGCJobsValidateGrantOptionPebbleFormatBlockPropertyCollectorProbeRequestSelectRPCsTakeTracingInfoInbandPreSeedTenantSpanConfigsSeedTenantSpanConfigsPublicSchemasWithDescriptorsEnsureSpanConfigReconciliationEnsureSpanConfigSubscriptionEnableSpanConfigStoreScanWholeRowsSCRAMAuthenticationUnsafeLossOfQuorumRecoveryRangeLogAlterSystemProtectedTimestampAddColumnEnableProtectedTimestampsForTenantDeleteCommentsWithDroppedIndexesRemoveIncompatibleDatabasePrivilegesAddRaftAppliedIndexTermMigrationPostAddRaftAppliedIndexTermMigrationDontProposeWriteTimestampForLeaseTransfersTenantSettingsTableEnablePebbleFormatVersionBlockPropertiesDisableSystemConfigGossipTriggerMVCCIndexBackfillerEnableLeaseHolderRemovalBackupResolutionInJobLooselyCoupledRaftLogTruncationChangefeedIdlenessBackupDoesNotOverwriteLatestAndCheckpointEnableDeclarativeSchemaChangerRowLevelTTLPebbleFormatSplitUserKeysMarkedIncrementalBackupSubdirDateStyleIntervalStyleCastRewriteEnsurePebbleFormatVersionRangeKeysEnablePebbleFormatVersionRangeKeys" -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} +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, 1227, 1261} 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