Skip to content

Commit a31e937

Browse files
committed
fix(server): fix some issues of the distributed scheduler
1 parent a110112 commit a31e937

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/task/DistributedTaskScheduler.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,11 @@ public <V> void cancel(HugeTask<V> task) {
315315

316316
// Task not running locally, update status to CANCELLING
317317
// for cronSchedule() or other nodes to handle
318-
this.updateStatus(task.id(), null, TaskStatus.CANCELLING);
318+
TaskStatus currentStatus = task.status();
319+
if (!this.updateStatus(task.id(), currentStatus, TaskStatus.CANCELLING)) {
320+
LOG.info("Failed to cancel task '{}', status may have changed from {}",
321+
task.id(), currentStatus);
322+
}
319323
}
320324

321325
@Override
@@ -340,9 +344,6 @@ protected <V> HugeTask<V> deleteFromDB(Id id) {
340344
@Override
341345
public <V> HugeTask<V> delete(Id id, boolean force) {
342346
HugeTask<?> task = this.taskWithoutResult(id);
343-
if (task == null) {
344-
return null;
345-
}
346347

347348
if (!force) {
348349
// Check task status: can't delete running tasks without force
@@ -515,11 +516,6 @@ private <V> V call(Callable<V> callable, ExecutorService executor) {
515516
protected boolean updateStatus(Id id, TaskStatus prestatus,
516517
TaskStatus status) {
517518
HugeTask<Object> task = this.taskWithoutResult(id);
518-
if (task == null) {
519-
// Task was already deleted by cronSchedule or another thread
520-
LOG.info("Task '{}' not found, may have been deleted", id);
521-
return false;
522-
}
523519
initTaskParams(task);
524520
if (prestatus == null || task.status() == prestatus) {
525521
task.overwriteStatus(status);

0 commit comments

Comments
 (0)