|
|
|
|
@@ -36,6 +36,7 @@ import (
|
|
|
|
|
"github.com/dolthub/dolt/go/libraries/utils/filesys"
|
|
|
|
|
"github.com/dolthub/dolt/go/store/chunks"
|
|
|
|
|
"github.com/dolthub/dolt/go/store/hash"
|
|
|
|
|
"github.com/dolthub/dolt/go/store/nbs"
|
|
|
|
|
"github.com/dolthub/dolt/go/store/types"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@@ -97,7 +98,7 @@ func (rs *RemoteChunkStore) HasChunks(ctx context.Context, req *remotesapi.HasCh
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -155,7 +156,7 @@ func (rs *RemoteChunkStore) GetDownloadLocations(ctx context.Context, req *remot
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -233,7 +234,7 @@ func (rs *RemoteChunkStore) StreamDownloadLocations(stream remotesapi.ChunkStore
|
|
|
|
|
"num_requested": numHashes,
|
|
|
|
|
"num_urls": numUrls,
|
|
|
|
|
"num_ranges": numRanges,
|
|
|
|
|
}).Info("finished")
|
|
|
|
|
}).Trace("finished")
|
|
|
|
|
}()
|
|
|
|
|
logger := ologger
|
|
|
|
|
|
|
|
|
|
@@ -387,7 +388,7 @@ func (rs *RemoteChunkStore) GetUploadLocations(ctx context.Context, req *remotes
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
_, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -445,7 +446,7 @@ func (rs *RemoteChunkStore) Rebase(ctx context.Context, req *remotesapi.RebaseRe
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
_, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -462,7 +463,7 @@ func (rs *RemoteChunkStore) Root(ctx context.Context, req *remotesapi.RootReques
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -485,7 +486,7 @@ func (rs *RemoteChunkStore) Commit(ctx context.Context, req *remotesapi.CommitRe
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -500,7 +501,11 @@ func (rs *RemoteChunkStore) Commit(ctx context.Context, req *remotesapi.CommitRe
|
|
|
|
|
err = cs.AddTableFilesToManifest(ctx, updates, rs.getAddrs(cs.Version()))
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.WithError(err).Error("error calling AddTableFilesToManifest")
|
|
|
|
|
return nil, status.Errorf(codes.Internal, "manifest update error: %v", err)
|
|
|
|
|
code := codes.Internal
|
|
|
|
|
if errors.Is(err, nbs.ErrDanglingRef) || errors.Is(err, nbs.ErrTableFileNotFound) {
|
|
|
|
|
code = codes.FailedPrecondition
|
|
|
|
|
}
|
|
|
|
|
return nil, status.Errorf(code, "manifest update error: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currHash := hash.New(req.Current)
|
|
|
|
|
@@ -513,7 +518,11 @@ func (rs *RemoteChunkStore) Commit(ctx context.Context, req *remotesapi.CommitRe
|
|
|
|
|
"last_hash": lastHash.String(),
|
|
|
|
|
"curr_hash": currHash.String(),
|
|
|
|
|
}).Error("error calling Commit")
|
|
|
|
|
return nil, status.Errorf(codes.Internal, "failed to commit: %v", err)
|
|
|
|
|
code := codes.Internal
|
|
|
|
|
if errors.Is(err, nbs.ErrDanglingRef) || errors.Is(err, nbs.ErrTableFileNotFound) {
|
|
|
|
|
code = codes.FailedPrecondition
|
|
|
|
|
}
|
|
|
|
|
return nil, status.Errorf(code, "failed to commit: %v", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.Tracef("Commit success; moved from %s -> %s", lastHash.String(), currHash.String())
|
|
|
|
|
@@ -528,7 +537,7 @@ func (rs *RemoteChunkStore) GetRepoMetadata(ctx context.Context, req *remotesapi
|
|
|
|
|
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getOrCreateStore(ctx, logger, repoPath, req.ClientRepoFormat.NbfVersion)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -556,7 +565,7 @@ func (rs *RemoteChunkStore) ListTableFiles(ctx context.Context, req *remotesapi.
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -634,7 +643,7 @@ func (rs *RemoteChunkStore) AddTableFiles(ctx context.Context, req *remotesapi.A
|
|
|
|
|
}
|
|
|
|
|
repoPath := getRepoPath(req)
|
|
|
|
|
logger = logger.WithField(RepoPathField, repoPath)
|
|
|
|
|
defer func() { logger.Info("finished") }()
|
|
|
|
|
defer func() { logger.Trace("finished") }()
|
|
|
|
|
|
|
|
|
|
cs, err := rs.getStore(ctx, logger, repoPath)
|
|
|
|
|
if err != nil {
|
|
|
|
|
@@ -649,7 +658,11 @@ func (rs *RemoteChunkStore) AddTableFiles(ctx context.Context, req *remotesapi.A
|
|
|
|
|
err = cs.AddTableFilesToManifest(ctx, updates, rs.getAddrs(cs.Version()))
|
|
|
|
|
if err != nil {
|
|
|
|
|
logger.WithError(err).Error("error occurred updating the manifest")
|
|
|
|
|
return nil, status.Error(codes.Internal, "manifest update error")
|
|
|
|
|
code := codes.Internal
|
|
|
|
|
if errors.Is(err, nbs.ErrDanglingRef) || errors.Is(err, nbs.ErrTableFileNotFound) {
|
|
|
|
|
code = codes.FailedPrecondition
|
|
|
|
|
}
|
|
|
|
|
return nil, status.Error(code, "manifest update error")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger = logger.WithFields(logrus.Fields{
|
|
|
|
|
@@ -707,7 +720,7 @@ func getReqLogger(lgr *logrus.Entry, method string) *logrus.Entry {
|
|
|
|
|
"method": method,
|
|
|
|
|
"request_num": strconv.Itoa(incReqId()),
|
|
|
|
|
})
|
|
|
|
|
lgr.Info("starting request")
|
|
|
|
|
lgr.Trace("starting request")
|
|
|
|
|
return lgr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|