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

fix(cdn): insert item unit on deduplication #5882

Merged
merged 1 commit into from
Jul 8, 2021
Merged
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
13 changes: 11 additions & 2 deletions engine/cdn/storage/storageunit_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@ func (x *RunningStorageUnits) runItem(ctx context.Context, db *gorp.DbMap, dest

if has {
log.Info(ctx, "item %s has been pushed to %s with deduplication", item.ID, dest.Name())
return nil
tx, err := db.Begin()
if err != nil {
return sdk.WrapError(err, "unable to start transaction")
}
defer tx.Rollback() //nolint
// Save in database that the item is complete for the storage unit
if err := InsertItemUnit(ctx, x.m, tx, iu); err != nil {
return err
}
return sdk.WrapError(tx.Commit(), "unable to commit tx")
}

t1 := time.Now()
Expand All @@ -140,7 +149,7 @@ func (x *RunningStorageUnits) runItem(ctx context.Context, db *gorp.DbMap, dest
return err
}
if writer == nil {
return nil
return sdk.NewErrorFrom(sdk.ErrNotFound, "unable to get writer")
}
rateLimitWriter := shapeio.NewWriter(writer)
rateLimitWriter.SetRateLimit(dest.SyncBandwidth())
Expand Down