Skip to content

Commit

Permalink
clusterversion,storage: use range tombstones unconditionally in 23.1
Browse files Browse the repository at this point in the history
Currently, MVCC range tombstones are only enabled when the
`storage.mvcc.range_tombstones.enabled` cluster setting is `true`.
Originally, the plan for 23.1 was to remove this cluster setting
entirely, which would enable the feature unconditionally. However, it
was decided that for 23.1, the setting would remain, along with the
utility methods that determine whether or not the feature is enabled.

As there is still an expectation that the feature is enabled in 23.1,
add an internal cluster version that is used as a feature gate. If the
cluster is at least of version
`V23_1_MVCCRangeTombstonesUnconditionallyEnabled`, MVCC range tombstones
are _unconditionally_ enabled, irrespective of whether the cluster
setting is enabled or not.

Fix #91147.

Release note: None.
  • Loading branch information
nicktrav committed Feb 28, 2023
1 parent f1a4c63 commit 7a6d0c1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 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 @@ -297,4 +297,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 1000022.2-56 set the active cluster version in the format '<major>.<minor>'
version version 1000022.2-58 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 @@ -238,6 +238,6 @@
<tr><td><div id="setting-trace-opentelemetry-collector" class="anchored"><code>trace.opentelemetry.collector</code></div></td><td>string</td><td><code></code></td><td>address of an OpenTelemetry trace collector to receive traces using the otel gRPC protocol, as &lt;host&gt;:&lt;port&gt;. If no port is specified, 4317 will be used.</td></tr>
<tr><td><div id="setting-trace-span-registry-enabled" class="anchored"><code>trace.span_registry.enabled</code></div></td><td>boolean</td><td><code>true</code></td><td>if set, ongoing traces can be seen at https://&lt;ui&gt;/#/debug/tracez</td></tr>
<tr><td><div id="setting-trace-zipkin-collector" class="anchored"><code>trace.zipkin.collector</code></div></td><td>string</td><td><code></code></td><td>the address of a Zipkin instance to receive traces, as &lt;host&gt;:&lt;port&gt;. If no port is specified, 9411 will be used.</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000022.2-56</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td></tr>
<tr><td><div id="setting-version" class="anchored"><code>version</code></div></td><td>version</td><td><code>1000022.2-58</code></td><td>set the active cluster version in the format &#39;&lt;major&gt;.&lt;minor&gt;&#39;</td></tr>
</tbody>
</table>
13 changes: 13 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ const (
// backfilled.
V23_1DatabaseRoleSettingsRoleIDColumnBackfilled

// V23_1_MVCCRangeTombstonesUnconditionallyEnabled is a version gate at and
// after which Cockroach will always write MVCC Range Tombstones, regardless
// of the value of the storage.mvcc.range_tombstones.enabled cluster setting.
// Prior to this version, it was possible for a cluster to be writing MVCC
// Range Tombstones, but only if the cluster had been opted in manually, under
// a specific set of circumstances (i.e. appropriate 22.2.x version, Cockroach
// Cloud cluster, etc.).
V23_1_MVCCRangeTombstonesUnconditionallyEnabled

// *************************************************
// Step (1): Add new versions here.
// Do not add new versions to a patch release.
Expand Down Expand Up @@ -769,6 +778,10 @@ var rawVersionsSingleton = keyedVersions{
Key: V23_1DatabaseRoleSettingsRoleIDColumnBackfilled,
Version: roachpb.Version{Major: 22, Minor: 2, Internal: 56},
},
{
Key: V23_1_MVCCRangeTombstonesUnconditionallyEnabled,
Version: roachpb.Version{Major: 22, Minor: 2, Internal: 58},
},

// *************************************************
// Step (2): Add new versions here.
Expand Down
18 changes: 13 additions & 5 deletions pkg/storage/mvcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"sync"
"time"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv/kvnemesis/kvnemesisutil"
"github.com/cockroachdb/cockroach/pkg/kv/kvpb"
Expand Down Expand Up @@ -83,18 +84,25 @@ var minWALSyncInterval = settings.RegisterDurationSetting(
// If disabled after being enabled, this will prevent new range tombstones from
// being written, but already written tombstones will remain until GCed. The
// above note on jobs also applies in this case.
//
// If the version of the cluster is at or beyond the version
// V23_1_MVCCRangeTombstonesUnconditionallyEnabled, the feature is
// unconditionally enabled.
var MVCCRangeTombstonesEnabled = settings.RegisterBoolSetting(
settings.TenantReadOnly,
"storage.mvcc.range_tombstones.enabled",
"enables the use of MVCC range tombstones",
true)

// CanUseMVCCRangeTombstones returns true if the caller can begin writing
// MVCC range tombstones, by setting DeleteRangeRequest.UseRangeTombstone.
// It requires the MVCCRangeTombstones version gate to be active, and the
// setting storage.mvcc.range_tombstones.enabled to be enabled.
// CanUseMVCCRangeTombstones returns true if the caller can begin writing MVCC
// range tombstones, by setting DeleteRangeRequest.UseRangeTombstone. It
// requires the storage.mvcc.range_tombstones.enabled cluster setting to be
// enabled, OR the cluster version is at or beyond the
// V23_1_MVCCRangeTombstonesUnconditionallyEnabled version (i.e. in 23.1, the
// feature is unconditionally enabled).
func CanUseMVCCRangeTombstones(ctx context.Context, st *cluster.Settings) bool {
return MVCCRangeTombstonesEnabled.Get(&st.SV)
return st.Version.IsActive(ctx, clusterversion.V23_1_MVCCRangeTombstonesUnconditionallyEnabled) ||
MVCCRangeTombstonesEnabled.Get(&st.SV)
}

// MaxIntentsPerWriteIntentError sets maximum number of intents returned in
Expand Down

0 comments on commit 7a6d0c1

Please sign in to comment.