Mark Tasks Unkown to Assigned Worker as Failed
This commit is contained in:
parent
c7560b2eaa
commit
971aa40615
1 changed files with 12 additions and 1 deletions
|
@ -2,6 +2,7 @@ package server
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
@ -199,7 +200,17 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
defer wg.Done()
|
||||
var ts types.TaskStatus
|
||||
_, err := rpcServer.Call(ctx, w.Conn, "task-status", tsr, &ts)
|
||||
if errors.Is(err, constants.ErrTaskDoesNotExist) {
|
||||
// Worker says it does not know of this task, mark it failed so that we don't asks the worker about it again and again
|
||||
slog.ErrorContext(ctx, "Task is unkown by worker, Failing...", "err", err)
|
||||
|
||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", ts.Task.ID, constants.TASK_STATUS_FAILED, "Task Failed because it is unkown to Assigned Worker")
|
||||
if err != nil {
|
||||
slog.ErrorContext(ctx, "Updating Failed Task Status", "err", err)
|
||||
return
|
||||
}
|
||||
|
||||
} else if err != nil {
|
||||
slog.ErrorContext(ctx, "Getting Task Status", "err", err)
|
||||
|
||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2 WHERE id = $1", ts.Task.ID, constants.TASK_STATUS_UNKNOWN)
|
||||
|
|
Loading…
Add table
Reference in a new issue