Skip to content

Commit

Permalink
worker: update log
Browse files Browse the repository at this point in the history
  • Loading branch information
peterjan committed Dec 6, 2023
1 parent cdc9060 commit 0d1301a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion worker/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ func (s *slabDownload) finish() ([][]byte, bool, error) {
}
}

return nil, s.numOverpaid > 0, fmt.Errorf("failed to download slab: completed=%d, inflight=%d, launched=%d, relaunched=%d, overpaid=%d, downloaders=%d unused=%d errors=%d %v", s.numCompleted, s.numInflight, s.numLaunched, s.numRelaunched, s.numOverpaid, s.mgr.numDownloaders(), unused, len(s.errs), s.errs)
return nil, s.numOverpaid > 0, fmt.Errorf("failed to download slab: completed=%d inflight=%d launched=%d relaunched=%d overpaid=%d downloaders=%d unused=%d errors=%d %v", s.numCompleted, s.numInflight, s.numLaunched, s.numRelaunched, s.numOverpaid, s.mgr.numDownloaders(), unused, len(s.errs), s.errs)
}
return s.sectors, s.numOverpaid > 0, nil
}
Expand Down
23 changes: 20 additions & 3 deletions worker/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,10 +778,16 @@ func (mgr *uploadManager) newUpload(ctx context.Context, totalShards int, contra
}, finishFn, nil
}

func (mgr *uploadManager) numUploaders() int {
func (mgr *uploadManager) numUploaders(u *upload) (n int) {
mgr.mu.Lock()
defer mgr.mu.Unlock()
return len(mgr.uploaders)
for _, uploader := range mgr.uploaders {
fcid, renewedFrom, _ := uploader.contractInfo()
if u.isAllowed(fcid, renewedFrom) {
n++
}
}
return
}

func (mgr *uploadManager) candidate(req *sectorUploadReq) *uploader {
Expand Down Expand Up @@ -1338,7 +1344,7 @@ func (s *slabUpload) finish() (sectors []object.Sector, _ error) {

if s.numUploaded < uint64(len(s.shards)) {
remaining := uint64(len(s.shards)) - s.numUploaded
return nil, fmt.Errorf("failed to upload slab: remaining=%d, inflight=%d, launched=%d uploaders=%d errors=%d %w", remaining, s.numInflight, s.numLaunched, s.mgr.numUploaders(), len(s.errs), s.errs)
return nil, fmt.Errorf("failed to upload slab: launched=%d uploaded=%d remaining=%d inflight=%d uploaders=%d errors=%d %w", s.numLaunched, s.numUploaded, remaining, s.numInflight, s.mgr.numUploaders(s.upload), len(s.errs), s.errs)
}

for i := 0; i < len(s.shards); i++ {
Expand Down Expand Up @@ -1541,6 +1547,17 @@ func (s *slabUpload) receive(resp sectorUploadResp) bool {
return s.numUploaded == uint64(len(s.shards))
}

func (u *upload) isAllowed(fcid ...types.FileContractID) bool {
u.mu.Lock()
defer u.mu.Unlock()
for _, c := range fcid {
if _, allowed := u.allowed[c]; allowed {
return true
}
}
return false
}

func (s *sectorUpload) numOverdriving() int {
s.mu.Lock()
defer s.mu.Unlock()
Expand Down

0 comments on commit 0d1301a

Please sign in to comment.