Skip to content

Commit

Permalink
GC Txn entries through GC queue
Browse files Browse the repository at this point in the history
see cockroachdb#2062.

on each run of the GC queue for a given range, the transaction
and sequence prefixes are scanned and the following actions taken:

* old pending transactions are pushed (which will succeed), effectively
  aborting them
* old aborted transactions are added to the GC request.
* aborted and committed transactions will have the intents referenced
  in their record resolved synchronously and are GCed (on success)
* sequence cache entries which are "old" and belong to "old" (or
  nonexistent) transactions are deleted.
  • Loading branch information
tbg committed Nov 24, 2015
1 parent f3d42a5 commit d9a10ea
Show file tree
Hide file tree
Showing 10 changed files with 372 additions and 235 deletions.
13 changes: 11 additions & 2 deletions roachpb/data.go
Expand Up @@ -666,8 +666,7 @@ func (t Transaction) Short() string {
// nanoseconds since the Unix epoch.
func NewGCMetadata(nowNanos int64) *GCMetadata {
return &GCMetadata{
LastScanNanos: nowNanos,
OldestIntentNanos: proto.Int64(nowNanos),
LastScanNanos: nowNanos,
}
}

Expand Down Expand Up @@ -713,6 +712,16 @@ func (l Lease) OwnedBy(storeID StoreID) bool {
return l.Replica.StoreID == storeID
}

// AsIntents takes a slice of spans and returns it as a slice of intents for
// the given transaction.
func AsIntents(spans []Span, txn *Transaction) []Intent {
ret := make([]Intent, len(spans))
for i := range spans {
ret[i].Span, ret[i].Txn = spans[i], *txn
}
return ret
}

// RSpan is a key range with an inclusive start RKey and an exclusive end RKey.
type RSpan struct {
Key, EndKey RKey
Expand Down
33 changes: 2 additions & 31 deletions roachpb/data.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions roachpb/data.proto
Expand Up @@ -295,12 +295,11 @@ message Lease {

// GCMetadata holds information about the last complete key/value
// garbage collection scan of a range.
// TODO(tschottdorf): can avoid an extra message unless we're planning
// to add more content.
message GCMetadata {
// The last GC scan timestamp in nanoseconds since the Unix epoch.
optional int64 last_scan_nanos = 1 [(gogoproto.nullable) = false];
// The oldest unresolved write intent in nanoseconds since epoch.
// Null if there are no unresolved write intents.
optional int64 oldest_intent_nanos = 2;
}

// SequenceCacheEntry holds information which together with the key at which
Expand Down
117 changes: 20 additions & 97 deletions storage/engine/rocksdb/cockroach/roachpb/data.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 0 additions & 34 deletions storage/engine/rocksdb/cockroach/roachpb/data.pb.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d9a10ea

Please sign in to comment.