github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/protectedts/ptpb/protectedts.proto (about) 1 // Copyright 2018 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 12 syntax = "proto3"; 13 package cockroach.protectedts; 14 option go_package = "ptpb"; 15 16 import "gogoproto/gogo.proto"; 17 import "google/api/annotations.proto"; 18 import "roachpb/data.proto"; 19 import "util/hlc/timestamp.proto"; 20 21 22 // TODO(ajwerner): Consider splitting up Record into two pieces. It would 23 // probably make for a cleaner Client API. Create with a ProtectedTimestamp 24 // which returns an ID. This could also be useful if we want to store present 25 // the CreatedAt timestamp inside the record itself but wanted to allow for 26 // the record to be mutated. I'm not generally in favor of letting the record 27 // become mutable but it might be nice to store the verification status 28 // on the record one day. 29 // 30 // message ProtectedTimestamp { 31 // hlc.Timestamp timetamp 32 // ProtectionMode mode 33 // repeated roachpb.Span spans 34 // } 35 // 36 // message Record 37 // uuid.UUID id = 1; 38 // string metadata_type = 2; 39 // bytes metadata = 3; 40 // ProtectedTimestamp protected_timestamp = 4; // embed 41 // } 42 43 44 // ProtectionMode defines the semantics of a Record. 45 enum ProtectionMode { 46 option (gogoproto.goproto_enum_prefix) = false; 47 48 // PROTECT_AFTER ensures that all data values live at or after the specified 49 // timestamp will be protected from GC. 50 PROTECT_AFTER = 0; 51 52 // PROTECT_AT ensures that data values which are live at the specified 53 // timestamp will be protected but newer data which is no longer live 54 // can be GC'd. 55 // 56 // TODO(ajwerner): Implement PROTECT_AT. This mode will be useful for 57 // incremental GC or for long-running queries. It adds substantial complexity 58 // to the GC heuristic and process. Until there is an understood strategy to 59 // deal with that complexity we leave it unimplemented. 60 // PROTECT_AT = 1; 61 } 62 63 // Metadata is the system metadata. The metadata is stored explicitly and all 64 // operations which create or release Records increment the version and update 65 // the metadata fields accordingly. 66 // 67 // The version provides a mechanism for cheap caching and forms the basis of 68 // the implementation of the Tracker. The Tracker needs to provide a recent 69 // view of the protectedts subsystem for GC to proceed. The protectedts 70 // state changes rarely. The timestamp of cached state can by updated by 71 // merely observing that the version has not changed. 72 message Metadata { 73 74 // Version is incremented whenever a Record is created or removed. 75 uint64 version = 1; 76 77 // NumRecords is the number of records which exist in the subsystem. 78 uint64 num_records = 2; 79 80 // NumSpans is the number of spans currently being protected by the 81 // protectedts subsystem. 82 uint64 num_spans = 3; 83 84 // TotalBytes is the number of bytes currently in use by records 85 // to store their spans and metadata. 86 uint64 total_bytes = 4; 87 } 88 89 // Record corresponds to a protected timestamp. 90 message Record { 91 92 // ID uniquely identifies this row. 93 bytes id = 1 [(gogoproto.customtype) = "github.com/cockroachdb/cockroach/pkg/util/uuid.UUID", (gogoproto.nullable) = false, (gogoproto.customname) = "ID"]; 94 95 // Timestamp is the timestamp which is protected. 96 util.hlc.Timestamp timestamp = 2 [(gogoproto.nullable) = false]; 97 98 // Mode specifies whether this record protects all values live at timestamp 99 // or all values live at or after that timestamp. 100 ProtectionMode mode = 3; 101 102 // MetaType is used to interpret the data stored in Meta. 103 // Users of Meta should set a unique value for MetaType which provides enough 104 // information to interpret the data in Meta. See the comment on Meta for how 105 // these two fields should be used in tandem. 106 string meta_type = 4; 107 108 // Meta is client-provided metadata about the record. 109 // This data allows the Record to be correlated with data from another 110 // subsystem. For example, this field may contain the ID of a job which 111 // created this record. The metadata allows an out-of-band reconciliation 112 // process to discover and remove records which no longer correspond to 113 // running jobs. Such a mechanism acts as a failsafe against unreliable 114 // jobs infrastructure. 115 bytes meta = 5; 116 117 // Verified marks that this Record is known to have successfully provided 118 // protection. It is updated after Verification. Updates to this field do not 119 // change the Version of the subsystem. 120 bool verified = 6; 121 122 // Spans are the spans which this Record protects. 123 repeated roachpb.Span spans = 7 [(gogoproto.nullable) = false]; 124 } 125 126 // State is the complete system state. 127 message State { 128 Metadata metadata = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true]; 129 repeated Record records = 2 [(gogoproto.nullable) = false]; 130 }