Record jobs as failed when they are killed
So that they aren't retried again and again.
This commit is contained in:
parent
3dfa9212f1
commit
6904547bf2
2 changed files with 30 additions and 2 deletions
|
|
@ -13,8 +13,17 @@
|
||||||
"guix-data-service-process-job"
|
"guix-data-service-process-job"
|
||||||
job-id))
|
job-id))
|
||||||
|
|
||||||
|
(define (handle-job-failure job-id)
|
||||||
|
(record-job-event conn job-id "failure")
|
||||||
|
(display (simple-format #f "recording failure for job ~A\n" job-id)
|
||||||
|
(current-error-port))
|
||||||
|
(when (> (count-log-parts conn job-id)
|
||||||
|
0)
|
||||||
|
(combine-log-parts! conn job-id)))
|
||||||
|
|
||||||
(process-jobs-concurrently fetch-new-jobs
|
(process-jobs-concurrently fetch-new-jobs
|
||||||
process-job))
|
process-job
|
||||||
|
handle-job-failure))
|
||||||
|
|
||||||
(define default-max-processes
|
(define default-max-processes
|
||||||
(max (round (/ (current-processor-count)
|
(max (round (/ (current-processor-count)
|
||||||
|
|
@ -27,6 +36,7 @@
|
||||||
|
|
||||||
(define* (process-jobs-concurrently fetch-new-jobs
|
(define* (process-jobs-concurrently fetch-new-jobs
|
||||||
process-job
|
process-job
|
||||||
|
handle-job-failure
|
||||||
#:key (max-processes
|
#:key (max-processes
|
||||||
default-max-processes)
|
default-max-processes)
|
||||||
(timeout default-timeout))
|
(timeout default-timeout))
|
||||||
|
|
@ -88,7 +98,11 @@
|
||||||
#f "sending SIGTERM to pid ~A started at ~A, now running for ~A\n"
|
#f "sending SIGTERM to pid ~A started at ~A, now running for ~A\n"
|
||||||
pid start-time running-for)
|
pid start-time running-for)
|
||||||
(current-error-port))
|
(current-error-port))
|
||||||
(kill pid SIGTERM)))))
|
(kill pid SIGTERM)
|
||||||
|
|
||||||
|
(match job-args
|
||||||
|
((id)
|
||||||
|
(handle-job-failure id)))))))
|
||||||
processes))
|
processes))
|
||||||
|
|
||||||
(define (fork-and-process-job job-args)
|
(define (fork-and-process-job job-args)
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,13 @@
|
||||||
#:use-module (guix-data-service model package-metadata)
|
#:use-module (guix-data-service model package-metadata)
|
||||||
#:use-module (guix-data-service model derivation)
|
#:use-module (guix-data-service model derivation)
|
||||||
#:export (log-for-job
|
#:export (log-for-job
|
||||||
|
count-log-parts
|
||||||
|
combine-log-parts!
|
||||||
fetch-unlocked-jobs
|
fetch-unlocked-jobs
|
||||||
process-load-new-guix-revision-job
|
process-load-new-guix-revision-job
|
||||||
select-job-for-commit
|
select-job-for-commit
|
||||||
select-jobs-and-events
|
select-jobs-and-events
|
||||||
|
record-job-event
|
||||||
enqueue-load-new-guix-revision-job
|
enqueue-load-new-guix-revision-job
|
||||||
most-recent-n-load-new-guix-revision-jobs))
|
most-recent-n-load-new-guix-revision-jobs))
|
||||||
|
|
||||||
|
|
@ -122,6 +125,17 @@
|
||||||
($1, NULL) ON CONFLICT DO NOTHING"
|
($1, NULL) ON CONFLICT DO NOTHING"
|
||||||
(list job-id)))
|
(list job-id)))
|
||||||
|
|
||||||
|
(define (count-log-parts conn job-id)
|
||||||
|
(match (exec-query
|
||||||
|
conn
|
||||||
|
"
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM load_new_guix_revision_job_log_parts
|
||||||
|
WHERE job_id = $1"
|
||||||
|
(list job-id))
|
||||||
|
(((id))
|
||||||
|
(string->number id))))
|
||||||
|
|
||||||
(define (combine-log-parts! conn job-id)
|
(define (combine-log-parts! conn job-id)
|
||||||
(with-postgresql-transaction
|
(with-postgresql-transaction
|
||||||
conn
|
conn
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue