Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 12 additions & 0 deletions go/libraries/doltcore/remotestorage/chunk_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/sync/errgroup"
"google.golang.org/protobuf/types/known/timestamppb"

remotesapi "github.com/dolthub/dolt/go/gen/proto/dolt/services/remotesapi/v1alpha1"
"github.com/dolthub/dolt/go/libraries/doltcore/remotestorage/internal/reliable"
Expand Down Expand Up @@ -1228,6 +1229,17 @@ func (drtf DoltRemoteTableFile) Open(ctx context.Context) (io.ReadCloser, uint64
}

if resp.StatusCode/100 != 2 {
// XXX: If we fail to fetch, and we have the ability
// to refresh the URL, set ourselves up to refresh the
// next time we are used. This can help if the
// remoteapi endpoint gave us a URL that actually
// expires for some reason before the RefreshAfter
// timestamp. (Local clock drift, remote key rotation,
// etc.)
if drtf.info.RefreshAfter != nil {
drtf.info.RefreshAfter = timestamppb.Now()
drtf.info.RefreshAfter.Seconds -= 10
}
defer resp.Body.Close()
body := make([]byte, 4096)
n, _ := io.ReadFull(resp.Body, body)
Expand Down
29 changes: 26 additions & 3 deletions go/store/datas/pull/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,34 @@ func clone(ctx context.Context, srcTS, sinkTS chunks.TableFileStore, sinkCS chun
if failureCount >= maxAttempts {
return err
}
if _, sourceFiles, appendixFiles, err = srcTS.Sources(ctx); err != nil {
if _, refreshedSourceFiles, refreshedAppendixFiles, err := srcTS.Sources(ctx); err != nil {
return err
} else {
tblFiles = filterAppendicesFromSourceFiles(appendixFiles, sourceFiles)
_, fileIDToTF, _ = mapTableFiles(tblFiles)
refreshedTblFiles := filterAppendicesFromSourceFiles(refreshedAppendixFiles, refreshedSourceFiles)
_, refreshedFileIDToTF, _ := mapTableFiles(refreshedTblFiles)
// Sources() will refresh remote table file
// sources with new download URLs. However, it
// will only return URLs for table files which
// are in the remote manifest, which could
// have changed since the clone started. Here
// we keep around any old TableFile instances
// for any TableFiles which have been
// conjoined away or have been the victim of a
// garbage collection run on the remote.
//
// If these files are no longer accessible,
// for example because the URLs expired
// without a RefreshTableFileUrlRequest being
// provided, or because the table files
// themselves have been removed from storage,
// then continuing to use these sources will
// fail termainally eventually. But in the
// case of doltremoteapi on DoltHub, using
// these Sources() will continue to work and
// will allow the Clone to proceed.
for k, v := range refreshedFileIDToTF {
fileIDToTF[k] = v
}
}
}

Expand Down
Loading