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/gc: create gc pkg, reverse iteration in rditer, paginate versions during GC #43862

Merged
merged 6 commits into from Jan 21, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/cli/debug.go
Expand Up @@ -40,6 +40,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/storage/engine"
"github.com/cockroachdb/cockroach/pkg/storage/engine/enginepb"
"github.com/cockroachdb/cockroach/pkg/storage/gc"
"github.com/cockroachdb/cockroach/pkg/storage/rditer"
"github.com/cockroachdb/cockroach/pkg/storage/stateloader"
"github.com/cockroachdb/cockroach/pkg/storage/storagepb"
Expand Down Expand Up @@ -286,7 +287,7 @@ func runDebugRangeData(cmd *cobra.Command, args []string) error {
return err
}

iter := rditer.NewReplicaDataIterator(&desc, db, debugCtx.replicated)
iter := rditer.NewReplicaDataIterator(&desc, db, debugCtx.replicated, false /* seekEnd */)
defer iter.Close()
for ; ; iter.Next() {
if ok, err := iter.Valid(); err != nil {
Expand Down Expand Up @@ -555,13 +556,13 @@ func runDebugGCCmd(cmd *cobra.Command, args []string) error {
for _, desc := range descs {
snap := db.NewSnapshot()
defer snap.Close()
info, err := storage.RunGC(
info, err := gc.Run(
context.Background(),
&desc,
snap,
hlc.Timestamp{WallTime: timeutil.Now().UnixNano()},
zonepb.GCPolicy{TTLSeconds: int32(gcTTLInSeconds)},
storage.NoopGCer{},
gc.NoopGCer{},
func(_ context.Context, _ []roachpb.Intent) error { return nil },
func(_ context.Context, _ *roachpb.Transaction, _ []roachpb.Intent) error { return nil },
)
Expand Down
10 changes: 9 additions & 1 deletion pkg/storage/batch_spanset_test.go
Expand Up @@ -184,11 +184,19 @@ func TestSpanSetBatchBoundaries(t *testing.T) {
} else if err != nil {
t.Errorf("unexpected error on iterator: %+v", err)
}

// Seeking back in bounds restores validity.
iter.SeekLT(insideKey)
iter.SeekLT(insideKey2)
if ok, err := iter.Valid(); !ok {
t.Fatalf("expected valid iterator, err=%v", err)
}
// SeekLT to the lower bound is invalid.
iter.SeekLT(insideKey)
if ok, err := iter.Valid(); ok {
t.Fatalf("expected invalid iterator; found valid at key %s", iter.Key())
} else if !isReadSpanErr(err) {
t.Fatalf("SeekLT: unexpected error %v", err)
}
}

func TestSpanSetBatchTimestamps(t *testing.T) {
Expand Down
85 changes: 0 additions & 85 deletions pkg/storage/engine/gc.go

This file was deleted.

86 changes: 0 additions & 86 deletions pkg/storage/engine/gc_test.go

This file was deleted.

4 changes: 4 additions & 0 deletions pkg/storage/engine/mvcc_test.go
Expand Up @@ -106,6 +106,10 @@ func makeTxn(baseTxn roachpb.Transaction, ts hlc.Timestamp) *roachpb.Transaction
return txn
}

func mvccVersionKey(key roachpb.Key, ts hlc.Timestamp) MVCCKey {
return MVCCKey{Key: key, Timestamp: ts}
}

type mvccKeys []MVCCKey

func (n mvccKeys) Len() int { return len(n) }
Expand Down