-
Notifications
You must be signed in to change notification settings - Fork 242
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
chore_: optimise publish envelope #5172
Conversation
Jenkins BuildsClick to see older builds (16)
|
Hi @richard-ramos, appreciate your feedback. The initial motivation behind creating this PR was to address the potential issue of encountering the error "not enough peers to publish" multiple times in quick succession. This could lead to a situation where With your insights, things are clearer now. I believe the best approach to prevent |
This approach sounds good to me as well. |
7d84d30
to
cb96c84
Compare
cb96c84
to
3e982d9
Compare
3e982d9
to
dc41a41
Compare
dc41a41
to
29f7948
Compare
When the
publishEnvelope
function encounters the error "not enough peers to publish," it's advisable not to increment theenvelope.attempts
counter within theEnvelopesMonitor.handleEnvelopeFailure
method.Summary of Changes
New Fields in
EnvelopesMonitor
:retryQueue
field of type[]*monitoredEnvelope
to manage envelopes that need to be retried.New Methods:
backoffDuration(attempts int) time.Duration
: Calculates the backoff duration based on the number of attempts.retryLoop()
: Handles the retry logic in a loop, triggered by a ticker every 500 milliseconds.retryOnce()
: Retries sending an envelope once, adhering to backoff logic.removeFromRetryQueue(envelopeID types.Hash)
: Removes the specified envelope from the retry queue.Modified Methods:
Start()
: Added a new goroutine to handle the retry logic usingretryLoop()
.Stop()
: Now waits for both goroutines to finish usingWaitGroup
.Add()
: Now setslastAttemptTime
for new envelopes.handleEnvelopeFailure(hash types.Hash, err error)
: Envelopes that need to be retried are now added to theretryQueue
instead of being retried immediately.Miscellaneous:
lastAttemptTime
field inmonitoredEnvelope
during creation and update.These changes add a retry mechanism with exponential backoff to the
EnvelopesMonitor
, ensuring that envelopes are retried a limited number of times before being marked as expired. This should improve the reliability and robustness of the envelope handling process.