mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Add entropy to retries to prevent jobs queuing at the exact same time
This commit is contained in:
parent
82f7c376db
commit
1611f27665
@ -188,6 +188,8 @@ class NinjaMailerJob implements ShouldQueue
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Releasing immediately does not add in the backoff */
|
/* Releasing immediately does not add in the backoff */
|
||||||
|
sleep(rand(0, 3));
|
||||||
|
|
||||||
$this->release($this->backoff()[$this->attempts()-1]);
|
$this->release($this->backoff()[$this->attempts()-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class WebhookSingle implements ShouldQueue
|
|||||||
|
|
||||||
public function backoff()
|
public function backoff()
|
||||||
{
|
{
|
||||||
return [10, 30, 60, 180, 3600];
|
return [15, 35, 65, 185, 3605];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,6 +223,9 @@ class WebhookSingle implements ShouldQueue
|
|||||||
$this->company,
|
$this->company,
|
||||||
))->handle();
|
))->handle();
|
||||||
|
|
||||||
|
//add some entropy to the retry
|
||||||
|
sleep(rand(0, 3));
|
||||||
|
|
||||||
$this->release($this->backoff()[$this->attempts()-1]);
|
$this->release($this->backoff()[$this->attempts()-1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -309,6 +309,9 @@ class Email implements ShouldQueue
|
|||||||
|
|
||||||
$this->tearDown();
|
$this->tearDown();
|
||||||
/* Releasing immediately does not add in the backoff */
|
/* Releasing immediately does not add in the backoff */
|
||||||
|
|
||||||
|
sleep(rand(0, 3));
|
||||||
|
|
||||||
$this->release($this->backoff()[$this->attempts()-1]);
|
$this->release($this->backoff()[$this->attempts()-1]);
|
||||||
|
|
||||||
$message = null;
|
$message = null;
|
||||||
|
@ -136,6 +136,8 @@ class EmailMailer implements ShouldQueue
|
|||||||
|
|
||||||
|
|
||||||
/* Releasing immediately does not add in the backoff */
|
/* Releasing immediately does not add in the backoff */
|
||||||
|
sleep(rand(0, 3));
|
||||||
|
|
||||||
$this->release($this->backoff()[$this->attempts()-1]);
|
$this->release($this->backoff()[$this->attempts()-1]);
|
||||||
|
|
||||||
$message = null;
|
$message = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user