core: add debug log when a job in the activation queue is not runnable
authorLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 21 Apr 2020 16:28:01 +0000 (17:28 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 30 May 2020 17:59:29 +0000 (19:59 +0200)
When a job is skipped due its dependencies not being ready, log
a debug message saying what is holding it back.
This was very useful with transient units timing out to figure
out where the problem was.

(cherry picked from commit c03fbd37d662a1cb8b63f505b1dd29389eba1d2e)

src/core/job.c

index 9fe30359df36dfa4e367bb318f7d0099c19cf089..bcfdb9d371be5d9d5c4af7b92bba7226a03b1d2a 100644 (file)
@@ -516,12 +516,20 @@ static bool job_is_runnable(Job *j) {
                 return true;
 
         HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_AFTER], i)
-                if (other->job && job_compare(j, other->job, UNIT_AFTER) > 0)
+                if (other->job && job_compare(j, other->job, UNIT_AFTER) > 0) {
+                        log_unit_debug(j->unit,
+                                       "starting held back, waiting for: %s",
+                                       other->id);
                         return false;
+                }
 
         HASHMAP_FOREACH_KEY(v, other, j->unit->dependencies[UNIT_BEFORE], i)
-                if (other->job && job_compare(j, other->job, UNIT_BEFORE) > 0)
+                if (other->job && job_compare(j, other->job, UNIT_BEFORE) > 0) {
+                        log_unit_debug(j->unit,
+                                       "stopping held back, waiting for: %s",
+                                       other->id);
                         return false;
+                }
 
         return true;
 }