Skip to content

Commit

Permalink
storage: upgrade to pebblev2 table format
Browse files Browse the repository at this point in the history
The `Pebblev2` SSTable format adds support for range keys. Add two new
cluster versions to provide the upgrade path - the first version for
bumping the store, the second for use as a feature gate.

Release justification: None

Release note: None
  • Loading branch information
erikgrinaker committed Apr 4, 2022
1 parent a17fa63 commit 4798ae2
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/generated/settings/settings-for-tenants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <host>:<port>. If no port is specified, 4317 will be used.
trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https://<ui>/#/debug/tracez
trace.zipkin.collector string the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.
version version 21.2-104 set the active cluster version in the format '<major>.<minor>'
version version 21.2-1002 set the active cluster version in the format '<major>.<minor>'
2 changes: 1 addition & 1 deletion docs/generated/settings/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,6 @@
<tr><td><code>trace.opentelemetry.collector</code></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as <host>:<port>. If no port is specified, 4317 will be used.</td></tr>
<tr><td><code>trace.span_registry.enabled</code></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://<ui>/#/debug/tracez</td></tr>
<tr><td><code>trace.zipkin.collector</code></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.2-104</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
<tr><td><code>version</code></td><td>version</td><td><code>21.2-1002</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
20 changes: 20 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,16 @@ const (
// SuperRegions enables the usage on super regions.
SuperRegions

// 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.
Expand Down Expand Up @@ -575,6 +585,16 @@ var versionsSingleton = keyedVersions{
// Step (2): Add new versions here.
// Do not add new versions to a patch release.
// *************************************************

// 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},
},
}

// TODO(irfansharif): clusterversion.binary{,MinimumSupported}Version
Expand Down
6 changes: 4 additions & 2 deletions pkg/clusterversion/key_string.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/storage/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,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
Expand Down
7 changes: 6 additions & 1 deletion pkg/storage/sst_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand All @@ -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

Expand Down

0 comments on commit 4798ae2

Please sign in to comment.