Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 54 additions & 5 deletions pkg/roachpb/span_config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ option go_package = "roachpb";

import "roachpb/data.proto";
import "gogoproto/gogo.proto";

// TODO(irfansharif): We could have the proto definitions in pkg/config/zonepb
// use these messages instead of duplicating everything.
import "util/hlc/timestamp.proto";

// GCPolicy dictates the garbage collection policy to apply over a given span.
// It parallels the definition found in zonepb/zone.proto.
Expand All @@ -28,6 +26,24 @@ message GCPolicy {
// before garbage collection. A value <= 0 means older versions are never
// GC-ed.
int32 ttl_seconds = 1 [(gogoproto.customname) = "TTLSeconds"];

// ProtectionPolicies is a list of policies that dictate GC behavior for a
// range (in conjunction with the GC TTL). A ProtectionPolicy can be used
// to indicate a timestamp above which GC should not run, regardless of the
// GC TTL. The data it applies over is guaranteed to not be GC-ed provided it
// wasn't GC-ed before the config applied.
repeated ProtectionPolicy protection_policies = 2 [(gogoproto.nullable) = false];
}

// ProtectionPolicy dictates a protection policy against garbage collection that
// applies over a given span.
message ProtectionPolicy {
option (gogoproto.equal) = true;
option (gogoproto.populate) = true;

// ProtectedTimestamp is a timestamp above which GC should not run, regardless
// of the GC TTL.
util.hlc.Timestamp protected_timestamp = 1 [(gogoproto.nullable) = false];
}

// Constraint constrains the stores that a replica can be stored on. It
Expand Down Expand Up @@ -85,8 +101,8 @@ message LeasePreference {
repeated Constraint constraints = 1 [(gogoproto.nullable) = false];
}

// SpanConfig holds the configuration that applies to a given keyspan. It
// parallels the definition found in zonepb/zone.proto.
// SpanConfig holds the configuration that applies to a given keyspan. It is a
// superset of the fields found in zonepb.zone.proto.
message SpanConfig {
option (gogoproto.equal) = true;

Expand Down Expand Up @@ -151,6 +167,39 @@ message SpanConfigEntry {
SpanConfig config = 2 [(gogoproto.nullable) = false];
};

// SystemSpanConfig is a system installed configuration that may apply to
// multiple spans.
message SystemSpanConfig {
option (gogoproto.equal) = true;

// ProtectionPolicies is a list of policies which protect data from being
// GC-ed.
repeated ProtectionPolicy protection_policies = 1 [(gogoproto.nullable) = false];
}

// SystemSpanConfigTarget is used to specify the target of a SystemSpanConfig.
message SystemSpanConfigTarget {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed a bit offline, but could this perhaps be pared down to something like the following?

message SystemSpanConfigTarget {
   // TenantID indicates the tenant ID of the logical cluster being targeted.
   // For secondary tenants this field is left unset. For the host we can use
   // this field to protect a specific guest tenant. Down in KV we already have
   // access to roachpb.TenantFromContext to disambiguate where the request is
   // originating from -- precisely to avoid needing to add data to our message
   // types to encode as much. We can auth that this field is left empty if
   // originating from a secondary tenant.
   roachpb.TenantID tenant_id = 1 [(gogoproto.customname) = "TenantID", (gogoproto.nullable) = true];
 }

A relevant example (not too different from what spanconfig.KVAccessor will need to do):

tenantID, ok := roachpb.TenantFromContext(ctx)
if !ok || tenantID == roachpb.SystemTenantID {

// TenantID indicates the tenant ID of the logical cluster being targeted.
// For secondary tenants this field is left unset. For the host we can use
// this field to protect a specific secondary tenant.
//
// TODO(arul): Ensure that secondary tenants don't populate this field when
// we make use of these in the RPC.
roachpb.TenantID tenant_id = 1 [(gogoproto.customname) = "TenantID", (gogoproto.nullable) = true];
}


// SystemSpanConfigEntry is a SystemSpanConfigTarget and its corresponding
// SystemSpanConfig.
message SystemSpanConfigEntry {
// SystemSpanConfigTarget represents the target over which the config is said
// to apply.
SystemSpanConfigTarget system_span_config_target = 1 [(gogoproto.nullable) = false];

// SystemSpanConfig is the config that applies.
SystemSpanConfig system_span_config = 2 [(gogoproto.nullable) = false];
}

// GetSpanConfigsRequest is used to fetch the span configurations over the
// specified keyspans.
message GetSpanConfigsRequest {
Expand Down