-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ type Service struct { | |
networkID uint64 | ||
storer storage.Storer | ||
pushSyncer pushsync.PushSyncer | ||
depther topology.NeighborhoodDepther | ||
logger logging.Logger | ||
tag *tags.Tags | ||
tracer *tracing.Tracer | ||
|
@@ -45,15 +46,20 @@ type Service struct { | |
var ( | ||
retryInterval = 5 * time.Second // time interval between retries | ||
concurrentJobs = 10 // how many chunks to push simultaneously | ||
retryCount = 3 | ||
) | ||
|
||
var ErrInvalidAddress = errors.New("invalid address") | ||
var ( | ||
ErrInvalidAddress = errors.New("invalid address") | ||
ErrShallowReceipt = errors.New("shallow recipt") | ||
This comment has been minimized.
Sorry, something went wrong. |
||
) | ||
|
||
func New(networkID uint64, storer storage.Storer, peerSuggester topology.ClosestPeerer, pushSyncer pushsync.PushSyncer, tagger *tags.Tags, logger logging.Logger, tracer *tracing.Tracer) *Service { | ||
func New(networkID uint64, storer storage.Storer, depther topology.NeighborhoodDepther, pushSyncer pushsync.PushSyncer, tagger *tags.Tags, logger logging.Logger, tracer *tracing.Tracer) *Service { | ||
service := &Service{ | ||
networkID: networkID, | ||
storer: storer, | ||
pushSyncer: pushSyncer, | ||
depther: depther, | ||
tag: tagger, | ||
logger: logger, | ||
tracer: tracer, | ||
|
@@ -80,6 +86,7 @@ func (s *Service) chunksWorker() { | |
mtx sync.Mutex | ||
span opentracing.Span | ||
logger *logrus.Entry | ||
retryCounter = make(map[string]int) | ||
) | ||
defer timer.Stop() | ||
defer close(s.chunksWorkerQuitC) | ||
|
@@ -151,6 +158,7 @@ LOOP: | |
logger.Tracef("pusher: pushed chunk %s to node %s", ch.Address().String(), storerPeer.String()) | ||
po := swarm.Proximity(ch.Address().Bytes(), storerPeer.Bytes()) | ||
s.metrics.ReceiptDepth.WithLabelValues(strconv.Itoa(int(po))).Inc() | ||
delete(retryCounter, ch.Address().ByteString()) | ||
} else { | ||
s.metrics.TotalErrors.Inc() | ||
s.metrics.ErrorTime.Observe(time.Since(startTime).Seconds()) | ||
|
@@ -190,6 +198,21 @@ LOOP: | |
err = fmt.Errorf("pusher: receipt storer address: %w", err) | ||
return | ||
} | ||
|
||
po := swarm.Proximity(ch.Address().Bytes(), storerPeer.Bytes()) | ||
d := s.depther.NeighborhoodDepth() | ||
if po < d { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
mtx.Lock() | ||
retryCounter[ch.Address().ByteString()]++ | ||
if retryCounter[ch.Address().ByteString()] < retryCount { | ||
mtx.Unlock() | ||
err = fmt.Errorf("pusher: shallow receipt depth %d, want at least %d", po, d) | ||
po := swarm.Proximity(ch.Address().Bytes(), storerPeer.Bytes()) | ||
s.metrics.ReceiptDepth.WithLabelValues(strconv.Itoa(int(po))).Inc() | ||
This comment has been minimized.
Sorry, something went wrong.
Eknir
Contributor
|
||
return | ||
} | ||
mtx.Unlock() | ||
} | ||
} | ||
|
||
if err = s.storer.Set(ctx, storage.ModeSetSync, ch.Address()); err != nil { | ||
|
3 comments
on commit 24121ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it guaranteed or likely that a retry is going via another route, not hitting a similar peer that might give us troubles?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a chunk is retried, is it retried immediately, or does it happen later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am asking these questions, because ultimately retrying only helps if we know that the situation in the network is different. This is either when we try via a different route or when the peer with a shallow depth increased it's own depth.
typo