Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15387726
D16906.id40696.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D16906.id40696.diff
View Options
diff --git a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
--- a/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
+++ b/src/infrastructure/daemon/workers/management/PhabricatorWorkerManagementWorkflow.php
@@ -16,14 +16,20 @@
'param' => 'name',
'help' => pht('Select all tasks of a given class.'),
),
+ array(
+ 'name' => 'min-failure-count',
+ 'param' => 'int',
+ 'help' => pht('Limit to tasks with at least this many failures.'),
+ ),
);
}
protected function loadTasks(PhutilArgumentParser $args) {
$ids = $args->getArg('id');
$class = $args->getArg('class');
+ $min_failures = $args->getArg('min-failure-count');
- if (!$ids && !$class) {
+ if (!$ids && !$class && !$min_failures) {
throw new PhutilArgumentUsageException(
pht('Use --id or --class to select tasks.'));
} if ($ids && $class) {
@@ -31,6 +37,10 @@
pht('Use one of --id or --class to select tasks, but not both.'));
}
+ if (!$min_failures) {
+ $min_failures = 0;
+ }
+
if ($ids) {
$active_tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
'id IN (%Ls)',
@@ -38,12 +48,21 @@
$archive_tasks = id(new PhabricatorWorkerArchiveTaskQuery())
->withIDs($ids)
->execute();
- } else {
+ } else if ($class) {
$active_tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
- 'taskClass IN (%Ls)',
- array($class));
+ 'taskClass IN (%Ls) AND failureCount >= %d',
+ array($class),
+ $min_failures);
$archive_tasks = id(new PhabricatorWorkerArchiveTaskQuery())
->withClassNames(array($class))
+ ->withMinFailureCount($min_failures)
+ ->execute();
+ } else {
+ $active_tasks = id(new PhabricatorWorkerActiveTask())->loadAllWhere(
+ 'failureCount >= %d',
+ $min_failures);
+ $archive_tasks = id(new PhabricatorWorkerArchiveTaskQuery())
+ ->withMinFailureCount($min_failures)
->execute();
}
@@ -58,11 +77,16 @@
pht('No task exists with id "%s"!', $id));
}
}
- } else {
+ } else if ($class) {
if (!$tasks) {
throw new PhutilArgumentUsageException(
pht('No task exists with class "%s"!', $class));
}
+ } else {
+ if (!$tasks) {
+ throw new PhutilArgumentUsageException(
+ pht('No tasks exist with at least %d failures!', $min_failures));
+ }
}
// When we lock tasks properly, this gets populated as a side effect. Just
diff --git a/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php b/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
--- a/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
+++ b/src/infrastructure/daemon/workers/query/PhabricatorWorkerArchiveTaskQuery.php
@@ -9,6 +9,7 @@
private $objectPHIDs;
private $classNames;
private $limit;
+ private $minFailureCount;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -35,6 +36,11 @@
return $this;
}
+ public function withMinFailureCount($min) {
+ $this->minFailureCount = $min;
+ return $this;
+ }
+
public function setLimit($limit) {
$this->limit = $limit;
return $this;
@@ -94,6 +100,13 @@
$this->classNames);
}
+ if ($this->minFailureCount !== null) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'failureCount >= %d',
+ $this->minFailureCount);
+ }
+
return $this->formatWhereClause($where);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 16 2025, 2:49 AM (5 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7705315
Default Alt Text
D16906.id40696.diff (3 KB)
Attached To
Mode
D16906: Add a flag to ./bin/worker to select tasks based on their failureCount
Attached
Detach File
Event Timeline
Log In to Comment