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

kvserver: avoid engine bypass in sideload storage #59134

Merged
merged 1 commit into from
Jan 21, 2021
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
1 change: 0 additions & 1 deletion pkg/kv/kvserver/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ go_library(
"replica_send.go",
"replica_sideload.go",
"replica_sideload_disk.go",
"replica_sideload_inmem.go",
"replica_split_load.go",
"replica_sst_snapshot_storage.go",
"replica_stats.go",
Expand Down
20 changes: 16 additions & 4 deletions pkg/kv/kvserver/replica_sideload_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/errors/oserror"
"golang.org/x/time/rate"
Expand Down Expand Up @@ -238,7 +239,8 @@ func (ss *diskSideloadStorage) TruncateTo(
// Not worth trying to figure out which one, just try to delete.
err := ss.eng.RemoveDir(ss.dir)
if err != nil && !oserror.IsNotExist(err) {
return bytesFreed, 0, errors.Wrapf(err, "while purging %q", ss.dir)
log.Infof(ctx, "unable to remove sideloaded dir %s: %v", ss.dir, err)
err = nil // handled
}
}
return bytesFreed, bytesRetained, nil
Expand All @@ -247,23 +249,33 @@ func (ss *diskSideloadStorage) TruncateTo(
func (ss *diskSideloadStorage) forEach(
ctx context.Context, visit func(index uint64, filename string) error,
) error {
matches, err := filepath.Glob(filepath.Join(ss.dir, "i*.t*"))
matches, err := ss.eng.List(ss.dir)
if oserror.IsNotExist(err) {
// Nothing to do.
return nil
}
if err != nil {
return err
}
for _, match := range matches {
// List returns a relative path, but we want to deal in absolute paths
// because we may pass this back to `eng.{Delete,Stat}`, etc, and those
// expect absolute paths.
match = filepath.Join(ss.dir, match)
base := filepath.Base(match)
// Extract `i<log-index>` prefix from file.
if len(base) < 1 || base[0] != 'i' {
continue
}
base = base[1:]
upToDot := strings.SplitN(base, ".", 2)
logIdx, err := strconv.ParseUint(upToDot[0], 10, 64)
if err != nil {
return errors.Wrapf(err, "while parsing %q during TruncateTo", match)
log.Infof(ctx, "unexpected file %s in sideloaded directory %s", match, ss.dir)
continue
}
if err := visit(logIdx, match); err != nil {
return errors.Wrapf(err, "matching pattern %q", match)
return errors.Wrapf(err, "matching pattern %q on dir %s", match, ss.dir)
}
}
return nil
Expand Down
112 changes: 0 additions & 112 deletions pkg/kv/kvserver/replica_sideload_inmem.go

This file was deleted.

Loading