Merge pull request #13586 from annando/defer-limit
Individual defer limits per worker task
This commit is contained in:
commit
094b219581
|
@ -1379,10 +1379,11 @@ class Worker
|
||||||
/**
|
/**
|
||||||
* Defers the current worker entry
|
* Defers the current worker entry
|
||||||
*
|
*
|
||||||
|
* @param int $worker_defer_limit Maximum defer limit
|
||||||
* @return boolean had the entry been deferred?
|
* @return boolean had the entry been deferred?
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function defer(): bool
|
public static function defer(int $worker_defer_limit = 0): bool
|
||||||
{
|
{
|
||||||
$queue = DI::app()->getQueue();
|
$queue = DI::app()->getQueue();
|
||||||
|
|
||||||
|
@ -1395,6 +1396,10 @@ class Worker
|
||||||
|
|
||||||
$max_level = DI::config()->get('system', 'worker_defer_limit');
|
$max_level = DI::config()->get('system', 'worker_defer_limit');
|
||||||
|
|
||||||
|
if ($worker_defer_limit) {
|
||||||
|
$max_level = min($worker_defer_limit, $max_level);
|
||||||
|
}
|
||||||
|
|
||||||
$new_retrial = self::getNextRetrial($queue, $max_level);
|
$new_retrial = self::getNextRetrial($queue, $max_level);
|
||||||
|
|
||||||
if ($new_retrial > $max_level) {
|
if ($new_retrial > $max_level) {
|
||||||
|
|
|
@ -29,6 +29,8 @@ use Friendica\Network\HTTPException;
|
||||||
|
|
||||||
class RevokeFollow
|
class RevokeFollow
|
||||||
{
|
{
|
||||||
|
const WORKER_DEFER_LIMIT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue asynchronous follow revocation message to remote servers.
|
* Issue asynchronous follow revocation message to remote servers.
|
||||||
* The local relationship has already been updated, so we can't use the user-specific contact
|
* The local relationship has already been updated, so we can't use the user-specific contact
|
||||||
|
@ -51,7 +53,7 @@ class RevokeFollow
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Protocol::revokeFollow($contact, $owner)) {
|
if (!Protocol::revokeFollow($contact, $owner)) {
|
||||||
Worker::defer();
|
Worker::defer(self::WORKER_DEFER_LIMIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ use Friendica\Model\User;
|
||||||
|
|
||||||
class Unfollow
|
class Unfollow
|
||||||
{
|
{
|
||||||
|
const WORKER_DEFER_LIMIT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issue asynchronous unfollow message to remote servers.
|
* Issue asynchronous unfollow message to remote servers.
|
||||||
* The local relationship has already been updated, so we can't use the user-specific contact.
|
* The local relationship has already been updated, so we can't use the user-specific contact.
|
||||||
|
@ -51,7 +53,7 @@ class Unfollow
|
||||||
|
|
||||||
$result = Protocol::unfollow($contact, $owner);
|
$result = Protocol::unfollow($contact, $owner);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
Worker::defer();
|
Worker::defer(self::WORKER_DEFER_LIMIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@ use Friendica\Protocol\ActivityPub\Receiver;
|
||||||
|
|
||||||
class FetchMissingActivity
|
class FetchMissingActivity
|
||||||
{
|
{
|
||||||
|
const WORKER_DEFER_LIMIT = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch missing activities
|
* Fetch missing activities
|
||||||
* @param string $url Contact URL
|
* @param string $url Contact URL
|
||||||
|
@ -42,7 +44,7 @@ class FetchMissingActivity
|
||||||
$result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion);
|
$result = ActivityPub\Processor::fetchMissingActivity($url, $child, $relay_actor, $completion);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
Logger::info('Successfully fetched missing activity', ['url' => $url]);
|
Logger::info('Successfully fetched missing activity', ['url' => $url]);
|
||||||
} elseif (!Worker::defer()) {
|
} elseif (!Worker::defer(self::WORKER_DEFER_LIMIT)) {
|
||||||
Logger::info('Activity could not be fetched', ['url' => $url]);
|
Logger::info('Activity could not be fetched', ['url' => $url]);
|
||||||
|
|
||||||
// recursively delete all entries that belong to this worker task
|
// recursively delete all entries that belong to this worker task
|
||||||
|
|
Loading…
Reference in New Issue
Block a user