Skip to content

Commit 5ffd20b

Browse files
committed
fix(server): fix some issues of the distributed scheduler
1 parent 1113520 commit 5ffd20b

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,15 @@ private <V> HugeTask<V> waitUntilTaskCompleted(Id id, long seconds,
436436
long passes = seconds * 1000 / intervalMs;
437437
HugeTask<V> task = null;
438438
for (long pass = 0; ; pass++) {
439-
HugeTask<V> previousTask = task;
440-
task = this.taskWithoutResult(id);
441-
if (task == null) {
442-
// Task not found in DB
443-
if (previousTask != null && previousTask.completed()) {
444-
// Task was completed and then deleted (ephemeral task case)
445-
assert previousTask.id().asLong() < 0L : previousTask.id();
439+
try {
440+
task = this.taskWithoutResult(id);
441+
} catch (NotFoundException e) {
442+
if (task != null && task.completed()) {
443+
assert task.id().asLong() < 0L : task.id();
446444
sleep(intervalMs);
447-
return previousTask;
445+
return task;
448446
}
449-
throw new NotFoundException("Can't find task with id '%s'", id);
447+
throw e;
450448
}
451449
if (task.completed()) {
452450
// Wait for task result being set after status is completed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ protected <V> HugeTask<V> taskWithoutResult(Id id) {
219219
return HugeTask.fromVertex(vertex);
220220
});
221221

222+
if (result == null) {
223+
throw new NotFoundException("Can't find task with id '%s'", id);
224+
}
225+
222226
return result;
223227
}
224228

0 commit comments

Comments
 (0)