Skip to content

Commit

Permalink
gc: add version gate to GC clear range requests
Browse files Browse the repository at this point in the history
ClearRange fields of GCRequests are ignored by earlier versions,
this feature needs to be version gated to let GC work when talking
to a previous version if GC is run from a different node.

Release note: None
  • Loading branch information
aliher1911 committed Oct 31, 2022
1 parent 9112f48 commit a4b54f8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 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 @@ -298,4 +298,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-4 set the active cluster version in the format '<major>.<minor>'
version version 1000022.2-6 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 @@ -234,6 +234,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>1000022.2-4</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>1000022.2-6</code></td><td>set the active cluster version in the format '<major>.<minor>'</td></tr>
</tbody>
</table>
9 changes: 9 additions & 0 deletions pkg/clusterversion/cockroach_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ const (
// TenantNames adds a name column to system.tenants.
V23_1TenantNames

// V23_1EnableGCClearRange allows GC to fill and send ClearRange portions of
// GC Requests to request removal of multiple keys using pebble tombstones
// when applicable.
V23_1EnableGCClearRange

// *************************************************
// Step (1): Add new versions here.
// Do not add new versions to a patch release.
Expand Down Expand Up @@ -520,6 +525,10 @@ var rawVersionsSingleton = keyedVersions{
Key: V23_1TenantNames,
Version: roachpb.Version{Major: 22, Minor: 2, Internal: 4},
},
{
Key: V23_1EnableGCClearRange,
Version: roachpb.Version{Major: 22, Minor: 2, Internal: 6},
},

// *************************************************
// Step (2): Add new versions here.
Expand Down
5 changes: 3 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.

8 changes: 6 additions & 2 deletions pkg/kv/kvserver/mvcc_gc_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"sync/atomic"
"time"

"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/gc"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/intentresolver"
Expand Down Expand Up @@ -681,7 +682,10 @@ func (mgcq *mvccGCQueue) process(
maxIntentsPerCleanupBatch := gc.MaxIntentsPerCleanupBatch.Get(&repl.store.ClusterSettings().SV)
maxIntentKeyBytesPerCleanupBatch := gc.MaxIntentKeyBytesPerCleanupBatch.Get(&repl.store.ClusterSettings().SV)
txnCleanupThreshold := gc.TxnCleanupThreshold.Get(&repl.store.ClusterSettings().SV)
minKeyNumberForClearRange := gc.ClearRangeMinKeys.Get(&repl.store.ClusterSettings().SV)
var clearRangeMinKeys int64 = 0
if repl.store.ClusterSettings().Version.IsActive(ctx, clusterversion.V23_1EnableGCClearRange) {
clearRangeMinKeys = gc.ClearRangeMinKeys.Get(&repl.store.ClusterSettings().SV)
}

info, err := gc.Run(ctx, desc, snap, gcTimestamp, newThreshold,
gc.RunOptions{
Expand All @@ -691,7 +695,7 @@ func (mgcq *mvccGCQueue) process(
TxnCleanupThreshold: txnCleanupThreshold,
MaxTxnsPerIntentCleanupBatch: intentresolver.MaxTxnsPerIntentCleanupBatch,
IntentCleanupBatchTimeout: mvccGCQueueIntentBatchTimeout,
ClearRangeMinKeys: minKeyNumberForClearRange,
ClearRangeMinKeys: clearRangeMinKeys,
},
conf.TTL(),
&replicaGCer{
Expand Down

0 comments on commit a4b54f8

Please sign in to comment.