Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: add RevertRange #38477

Merged
merged 1 commit into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
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
592 changes: 586 additions & 6 deletions c-deps/libroach/protos/roachpb/api.pb.cc

Large diffs are not rendered by default.

707 changes: 611 additions & 96 deletions c-deps/libroach/protos/roachpb/api.pb.h

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion pkg/roachpb/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ func (*DeleteRangeRequest) Method() Method { return DeleteRange }
// Method implements the Request interface.
func (*ClearRangeRequest) Method() Method { return ClearRange }

// Method implements the Request interface.
func (*RevertRangeRequest) Method() Method { return RevertRange }

// Method implements the Request interface.
func (*ScanRequest) Method() Method { return Scan }

Expand Down Expand Up @@ -630,6 +633,12 @@ func (crr *ClearRangeRequest) ShallowCopy() Request {
return &shallowCopy
}

// ShallowCopy implements the Request interface.
func (crr *RevertRangeRequest) ShallowCopy() Request {
shallowCopy := *crr
return &shallowCopy
}

// ShallowCopy implements the Request interface.
func (sr *ScanRequest) ShallowCopy() Request {
shallowCopy := *sr
Expand Down Expand Up @@ -1027,7 +1036,12 @@ func (drr *DeleteRangeRequest) flags() int {
// Note that ClearRange commands cannot be part of a transaction as
// they clear all MVCC versions.
func (*ClearRangeRequest) flags() int { return isWrite | isRange | isAlone }
func (*ScanRequest) flags() int { return isRead | isRange | isTxn | updatesReadTSCache | needsRefresh }

// Note that RevertRange commands cannot be part of a transaction as
// they clear all MVCC versions above their target time.
func (*RevertRangeRequest) flags() int { return isWrite | isRange | isAlone }

func (*ScanRequest) flags() int { return isRead | isRange | isTxn | updatesReadTSCache | needsRefresh }
func (*ReverseScanRequest) flags() int {
return isRead | isRange | isReverse | isTxn | updatesReadTSCache | needsRefresh
}
Expand Down
3,518 changes: 2,043 additions & 1,475 deletions pkg/roachpb/api.pb.go

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions pkg/roachpb/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,33 @@ message ClearRangeResponse {
ResponseHeader header = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}


// A RevertRangeRequest specifies a range of keys in which to clear all MVCC
// revisions more recent than some TargetTime from the underlying engine, thus
// reverting the range (from the perspective of an MVCC scan) to that time.
//
// Note: if a more recent MVCC revision of a key has caused an earlier revision
// to be GC'ed, it is no longer possible to revert to that earlier revision and
// instead clearing the more recent revision would simply delete that key. It is
// up to the caller to consider if this is applicable to their usage and if so,
// take steps to avoid it. Some future work could add the concept of a
// gc.revert_ttl to prevent GC until the newer revision meets an age threshold.
message RevertRangeRequest {
option (gogoproto.equal) = true;

RequestHeader header = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];

// TargetTime specifies a the time to which to "revert" the range by clearing any
// MVCC key with a strictly higher timestamp.
util.hlc.Timestamp target_time = 2 [(gogoproto.nullable) = false];
}

// A RevertRangeResponse is the return value from the RevertRange() method.
message RevertRangeResponse {
ResponseHeader header = 1 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
}


// ScanOptions is a collection of options for a batch of scans. The options
// apply to all the scans in the batch.
//
Expand Down Expand Up @@ -1549,6 +1576,7 @@ message RequestUnion {
DeleteRequest delete = 5;
DeleteRangeRequest delete_range = 6;
ClearRangeRequest clear_range = 38;
RevertRangeRequest revert_range = 48;
ScanRequest scan = 7;
BeginTransactionRequest begin_transaction = 8;
EndTransactionRequest end_transaction = 9;
Expand Down Expand Up @@ -1600,6 +1628,7 @@ message ResponseUnion {
DeleteResponse delete = 5;
DeleteRangeResponse delete_range = 6;
ClearRangeResponse clear_range = 38;
RevertRangeResponse revert_range = 48;
ScanResponse scan = 7;
BeginTransactionResponse begin_transaction = 8;
EndTransactionResponse end_transaction = 9;
Expand Down
Loading