diff --git a/management/server/store/sql_store.go b/management/server/store/sql_store.go index a3b48093e..181c212d3 100644 --- a/management/server/store/sql_store.go +++ b/management/server/store/sql_store.go @@ -142,11 +142,11 @@ func (s *SqlStore) SaveJob(ctx context.Context, job *types.Job) error { // job was pending for too long and has been cancelled // todo call it when we first start the jobChannel to make sure no stuck jobs -func (s *SqlStore) MarkPendingJobsAsFailed(ctx context.Context) error { +func (s *SqlStore) MarkPendingJobsAsFailed(ctx context.Context, peerID string) error { now := time.Now().UTC() return s.db.WithContext(ctx). Model(&types.Job{}). - Where("status = ?", types.JobStatusPending). + Where("peer_id = ? AND status = ?", types.JobStatusPending, peerID). Updates(map[string]any{ "status": types.JobStatusFailed, "failed_reason": "Pending job cleanup: marked as failed automatically due to being stuck too long", diff --git a/management/server/store/store.go b/management/server/store/store.go index f87a10a4e..38e7d7c6f 100644 --- a/management/server/store/store.go +++ b/management/server/store/store.go @@ -209,7 +209,7 @@ type Store interface { GetJobByID(ctx context.Context, accountID, jobID string) (*types.Job, error) GetJobs(ctx context.Context, accountID, peerID string) ([]*types.Job, error) CompleteJob(ctx context.Context, accountID, jobID, result string, failedReason string) error - MarkPendingJobsAsFailed(ctx context.Context) error + MarkPendingJobsAsFailed(ctx context.Context, peerID string) error } const (