1 #include "transaction.h"
2 #include "bus-errors.h"
4 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies);
6 static void transaction_delete_job(Transaction *tr, Job *j, bool delete_dependencies) {
10 /* Deletes one job from the transaction */
12 transaction_unlink_job(tr, j, delete_dependencies);
18 static void transaction_delete_unit(Transaction *tr, Unit *u) {
21 /* Deletes all jobs associated with a certain unit from the
24 while ((j = hashmap_get(tr->jobs, u)))
25 transaction_delete_job(tr, j, true);
28 void transaction_abort(Transaction *tr) {
33 while ((j = hashmap_first(tr->jobs)))
34 transaction_delete_job(tr, j, true);
36 assert(hashmap_isempty(tr->jobs));
39 static void transaction_find_jobs_that_matter_to_anchor(Job *j, unsigned generation) {
42 /* A recursive sweep through the graph that marks all units
43 * that matter to the anchor job, i.e. are directly or
44 * indirectly a dependency of the anchor job via paths that
45 * are fully marked as mattering. */
47 j->matters_to_anchor = true;
48 j->generation = generation;
50 LIST_FOREACH(subject, l, j->subject_list) {
52 /* This link does not matter */
56 /* This unit has already been marked */
57 if (l->object->generation == generation)
60 transaction_find_jobs_that_matter_to_anchor(l->object, generation);
64 static void transaction_merge_and_delete_job(Transaction *tr, Job *j, Job *other, JobType t) {
65 JobDependency *l, *last;
69 assert(j->unit == other->unit);
70 assert(!j->installed);
72 /* Merges 'other' into 'j' and then deletes 'other'. */
75 j->state = JOB_WAITING;
76 j->override = j->override || other->override;
78 j->matters_to_anchor = j->matters_to_anchor || other->matters_to_anchor;
80 /* Patch us in as new owner of the JobDependency objects */
82 LIST_FOREACH(subject, l, other->subject_list) {
83 assert(l->subject == other);
88 /* Merge both lists */
90 last->subject_next = j->subject_list;
92 j->subject_list->subject_prev = last;
93 j->subject_list = other->subject_list;
96 /* Patch us in as new owner of the JobDependency objects */
98 LIST_FOREACH(object, l, other->object_list) {
99 assert(l->object == other);
104 /* Merge both lists */
106 last->object_next = j->object_list;
108 j->object_list->object_prev = last;
109 j->object_list = other->object_list;
112 /* Kill the other job */
113 other->subject_list = NULL;
114 other->object_list = NULL;
115 transaction_delete_job(tr, other, true);
118 static bool job_is_conflicted_by(Job *j) {
123 /* Returns true if this job is pulled in by a least one
124 * ConflictedBy dependency. */
126 LIST_FOREACH(object, l, j->object_list)
133 static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
138 /* Tries to delete one item in the linked list
139 * j->transaction_next->transaction_next->... that conflicts
140 * with another one, in an attempt to make an inconsistent
141 * transaction work. */
143 /* We rely here on the fact that if a merged with b does not
144 * merge with c, either a or b merge with c neither */
145 LIST_FOREACH(transaction, j, j)
146 LIST_FOREACH(transaction, k, j->transaction_next) {
149 /* Is this one mergeable? Then skip it */
150 if (job_type_is_mergeable(j->type, k->type))
153 /* Ok, we found two that conflict, let's see if we can
154 * drop one of them */
155 if (!j->matters_to_anchor && !k->matters_to_anchor) {
157 /* Both jobs don't matter, so let's
158 * find the one that is smarter to
159 * remove. Let's think positive and
160 * rather remove stops then starts --
161 * except if something is being
162 * stopped because it is conflicted by
163 * another unit in which case we
164 * rather remove the start. */
166 log_debug("Looking at job %s/%s conflicted_by=%s", j->unit->id, job_type_to_string(j->type), yes_no(j->type == JOB_STOP && job_is_conflicted_by(j)));
167 log_debug("Looking at job %s/%s conflicted_by=%s", k->unit->id, job_type_to_string(k->type), yes_no(k->type == JOB_STOP && job_is_conflicted_by(k)));
169 if (j->type == JOB_STOP) {
171 if (job_is_conflicted_by(j))
176 } else if (k->type == JOB_STOP) {
178 if (job_is_conflicted_by(k))
185 } else if (!j->matters_to_anchor)
187 else if (!k->matters_to_anchor)
192 /* Ok, we can drop one, so let's do so. */
193 log_debug("Fixing conflicting jobs by deleting job %s/%s", d->unit->id, job_type_to_string(d->type));
194 transaction_delete_job(tr, d, true);
201 static int transaction_merge_jobs(Transaction *tr, DBusError *e) {
208 /* First step, check whether any of the jobs for one specific
209 * task conflict. If so, try to drop one of them. */
210 HASHMAP_FOREACH(j, tr->jobs, i) {
215 LIST_FOREACH(transaction, k, j->transaction_next) {
216 if (job_type_merge(&t, k->type) >= 0)
219 /* OK, we could not merge all jobs for this
220 * action. Let's see if we can get rid of one
223 r = delete_one_unmergeable_job(tr, j);
225 /* Ok, we managed to drop one, now
226 * let's ask our callers to call us
227 * again after garbage collecting */
230 /* We couldn't merge anything. Failure */
231 dbus_set_error(e, BUS_ERROR_TRANSACTION_JOBS_CONFLICTING, "Transaction contains conflicting jobs '%s' and '%s' for %s. Probably contradicting requirement dependencies configured.",
232 job_type_to_string(t), job_type_to_string(k->type), k->unit->id);
237 /* Second step, merge the jobs. */
238 HASHMAP_FOREACH(j, tr->jobs, i) {
242 /* Merge all transactions */
243 LIST_FOREACH(transaction, k, j->transaction_next)
244 assert_se(job_type_merge(&t, k->type) == 0);
246 /* If an active job is mergeable, merge it too */
248 job_type_merge(&t, j->unit->job->type); /* Might fail. Which is OK */
250 while ((k = j->transaction_next)) {
252 transaction_merge_and_delete_job(tr, k, j, t);
255 transaction_merge_and_delete_job(tr, j, k, t);
258 if (j->unit->job && !j->installed)
259 transaction_merge_and_delete_job(tr, j, j->unit->job, t);
261 assert(!j->transaction_next);
262 assert(!j->transaction_prev);
268 static void transaction_drop_redundant(Transaction *tr) {
273 /* Goes through the transaction and removes all jobs that are
282 HASHMAP_FOREACH(j, tr->jobs, i) {
283 bool changes_something = false;
286 LIST_FOREACH(transaction, k, j) {
288 if (tr->anchor_job != k &&
289 (k->installed || job_type_is_redundant(k->type, unit_active_state(k->unit))) &&
290 (!k->unit->job || !job_type_is_conflicting(k->type, k->unit->job->type)))
293 changes_something = true;
297 if (changes_something)
300 /* log_debug("Found redundant job %s/%s, dropping.", j->unit->id, job_type_to_string(j->type)); */
301 transaction_delete_job(tr, j, false);
309 static bool unit_matters_to_anchor(Unit *u, Job *j) {
311 assert(!j->transaction_prev);
313 /* Checks whether at least one of the jobs for this unit
314 * matters to the anchor. */
316 LIST_FOREACH(transaction, j, j)
317 if (j->matters_to_anchor)
323 static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsigned generation, DBusError *e) {
330 assert(!j->transaction_prev);
332 /* Does a recursive sweep through the ordering graph, looking
333 * for a cycle. If we find cycle we try to break it. */
335 /* Have we seen this before? */
336 if (j->generation == generation) {
339 /* If the marker is NULL we have been here already and
340 * decided the job was loop-free from here. Hence
341 * shortcut things and return right-away. */
345 /* So, the marker is not NULL and we already have been
346 * here. We have a cycle. Let's try to break it. We go
347 * backwards in our path and try to find a suitable
348 * job to remove. We use the marker to find our way
349 * back, since smart how we are we stored our way back
351 log_warning("Found ordering cycle on %s/%s", j->unit->id, job_type_to_string(j->type));
354 for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
356 log_info("Walked on cycle path to %s/%s", k->unit->id, job_type_to_string(k->type));
360 !unit_matters_to_anchor(k->unit, k)) {
361 /* Ok, we can drop this one, so let's
366 /* Check if this in fact was the beginning of
374 log_warning("Breaking ordering cycle by deleting job %s/%s", delete->unit->id, job_type_to_string(delete->type));
375 transaction_delete_unit(tr, delete->unit);
379 log_error("Unable to break cycle");
381 dbus_set_error(e, BUS_ERROR_TRANSACTION_ORDER_IS_CYCLIC, "Transaction order is cyclic. See system logs for details.");
385 /* Make the marker point to where we come from, so that we can
386 * find our way backwards if we want to break a cycle. We use
387 * a special marker for the beginning: we point to
389 j->marker = from ? from : j;
390 j->generation = generation;
392 /* We assume that the the dependencies are bidirectional, and
393 * hence can ignore UNIT_AFTER */
394 SET_FOREACH(u, j->unit->dependencies[UNIT_BEFORE], i) {
397 /* Is there a job for this unit? */
398 o = hashmap_get(tr->jobs, u);
400 /* Ok, there is no job for this in the
401 * transaction, but maybe there is already one
408 r = transaction_verify_order_one(tr, o, j, generation, e);
413 /* Ok, let's backtrack, and remember that this entry is not on
414 * our path anymore. */
420 static int transaction_verify_order(Transaction *tr, unsigned *generation, DBusError *e) {
429 /* Check if the ordering graph is cyclic. If it is, try to fix
430 * that up by dropping one of the jobs. */
434 HASHMAP_FOREACH(j, tr->jobs, i)
435 if ((r = transaction_verify_order_one(tr, j, NULL, g, e)) < 0)
441 static void transaction_collect_garbage(Transaction *tr) {
446 /* Drop jobs that are not required by any other job */
454 HASHMAP_FOREACH(j, tr->jobs, i) {
455 if (tr->anchor_job == j || j->object_list) {
456 /* log_debug("Keeping job %s/%s because of %s/%s", */
457 /* j->unit->id, job_type_to_string(j->type), */
458 /* j->object_list->subject ? j->object_list->subject->unit->id : "root", */
459 /* j->object_list->subject ? job_type_to_string(j->object_list->subject->type) : "root"); */
463 /* log_debug("Garbage collecting job %s/%s", j->unit->id, job_type_to_string(j->type)); */
464 transaction_delete_job(tr, j, true);
472 static int transaction_is_destructive(Transaction *tr, DBusError *e) {
478 /* Checks whether applying this transaction means that
479 * existing jobs would be replaced */
481 HASHMAP_FOREACH(j, tr->jobs, i) {
484 assert(!j->transaction_prev);
485 assert(!j->transaction_next);
489 !job_type_is_superset(j->type, j->unit->job->type)) {
491 dbus_set_error(e, BUS_ERROR_TRANSACTION_IS_DESTRUCTIVE, "Transaction is destructive.");
499 static void transaction_minimize_impact(Transaction *tr) {
503 /* Drops all unnecessary jobs that reverse already active jobs
504 * or that stop a running service. */
512 HASHMAP_FOREACH(j, tr->jobs, i) {
513 LIST_FOREACH(transaction, j, j) {
514 bool stops_running_service, changes_existing_job;
516 /* If it matters, we shouldn't drop it */
517 if (j->matters_to_anchor)
520 /* Would this stop a running service?
521 * Would this change an existing job?
522 * If so, let's drop this entry */
524 stops_running_service =
525 j->type == JOB_STOP && UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(j->unit));
527 changes_existing_job =
529 job_type_is_conflicting(j->type, j->unit->job->type);
531 if (!stops_running_service && !changes_existing_job)
534 if (stops_running_service)
535 log_debug("%s/%s would stop a running service.", j->unit->id, job_type_to_string(j->type));
537 if (changes_existing_job)
538 log_debug("%s/%s would change existing job.", j->unit->id, job_type_to_string(j->type));
540 /* Ok, let's get rid of this */
541 log_debug("Deleting %s/%s to minimize impact.", j->unit->id, job_type_to_string(j->type));
543 transaction_delete_job(tr, j, true);
555 static int transaction_apply(Transaction *tr, Manager *m, JobMode mode) {
560 /* Moves the transaction jobs to the set of active jobs */
562 if (mode == JOB_ISOLATE) {
564 /* When isolating first kill all installed jobs which
565 * aren't part of the new transaction */
567 HASHMAP_FOREACH(j, m->jobs, i) {
568 assert(j->installed);
570 if (hashmap_get(tr->jobs, j->unit))
573 /* 'j' itself is safe to remove, but if other jobs
574 are invalidated recursively, our iterator may become
575 invalid and we need to start over. */
576 if (job_finish_and_invalidate(j, JOB_CANCELED) > 0)
581 HASHMAP_FOREACH(j, tr->jobs, i) {
583 assert(!j->transaction_prev);
584 assert(!j->transaction_next);
589 r = hashmap_put(m->jobs, UINT32_TO_PTR(j->id), j);
594 while ((j = hashmap_steal_first(tr->jobs))) {
597 /* log_debug("Skipping already installed job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id); */
609 m->n_installed_jobs ++;
611 /* We're fully installed. Now let's free data we don't
614 assert(!j->transaction_next);
615 assert(!j->transaction_prev);
617 /* Clean the job dependencies */
618 transaction_unlink_job(tr, j, false);
620 job_add_to_run_queue(j);
621 job_add_to_dbus_queue(j);
624 log_debug("Installed new job %s/%s as %u", j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
631 HASHMAP_FOREACH(j, tr->jobs, i) {
635 hashmap_remove(m->jobs, UINT32_TO_PTR(j->id));
641 int transaction_activate(Transaction *tr, Manager *m, JobMode mode, DBusError *e) {
643 unsigned generation = 1;
647 /* This applies the changes recorded in tr->jobs to
648 * the actual list of jobs, if possible. */
650 /* First step: figure out which jobs matter */
651 transaction_find_jobs_that_matter_to_anchor(tr->anchor_job, generation++);
653 /* Second step: Try not to stop any running services if
654 * we don't have to. Don't try to reverse running
655 * jobs if we don't have to. */
656 if (mode == JOB_FAIL)
657 transaction_minimize_impact(tr);
659 /* Third step: Drop redundant jobs */
660 transaction_drop_redundant(tr);
663 /* Fourth step: Let's remove unneeded jobs that might
665 if (mode != JOB_ISOLATE)
666 transaction_collect_garbage(tr);
668 /* Fifth step: verify order makes sense and correct
669 * cycles if necessary and possible */
670 r = transaction_verify_order(tr, &generation, e);
675 log_warning("Requested transaction contains an unfixable cyclic ordering dependency: %s", bus_error(e, r));
679 /* Let's see if the resulting transaction ordering
680 * graph is still cyclic... */
684 /* Sixth step: let's drop unmergeable entries if
685 * necessary and possible, merge entries we can
687 r = transaction_merge_jobs(tr, e);
692 log_warning("Requested transaction contains unmergeable jobs: %s", bus_error(e, r));
696 /* Seventh step: an entry got dropped, let's garbage
697 * collect its dependencies. */
698 if (mode != JOB_ISOLATE)
699 transaction_collect_garbage(tr);
701 /* Let's see if the resulting transaction still has
702 * unmergeable entries ... */
705 /* Eights step: Drop redundant jobs again, if the merging now allows us to drop more. */
706 transaction_drop_redundant(tr);
708 /* Ninth step: check whether we can actually apply this */
709 if (mode == JOB_FAIL) {
710 r = transaction_is_destructive(tr, e);
712 log_notice("Requested transaction contradicts existing jobs: %s", bus_error(e, r));
717 /* Tenth step: apply changes */
718 r = transaction_apply(tr, m, mode);
720 log_warning("Failed to apply transaction: %s", strerror(-r));
724 assert(hashmap_isempty(tr->jobs));
729 static Job* transaction_add_one_job(Transaction *tr, JobType type, Unit *unit, bool override, bool *is_new) {
735 /* Looks for an existing prospective job and returns that. If
736 * it doesn't exist it is created and added to the prospective
739 f = hashmap_get(tr->jobs, unit);
741 LIST_FOREACH(transaction, j, f) {
742 assert(j->unit == unit);
744 if (j->type == type) {
751 j = job_new(unit, type);
757 j->matters_to_anchor = false;
758 j->override = override;
760 LIST_PREPEND(Job, transaction, f, j);
762 if (hashmap_replace(tr->jobs, unit, f) < 0) {
763 LIST_REMOVE(Job, transaction, f, j);
771 /* log_debug("Added job %s/%s to transaction.", unit->id, job_type_to_string(type)); */
776 static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependencies) {
780 if (j->transaction_prev)
781 j->transaction_prev->transaction_next = j->transaction_next;
782 else if (j->transaction_next)
783 hashmap_replace(tr->jobs, j->unit, j->transaction_next);
785 hashmap_remove_value(tr->jobs, j->unit, j);
787 if (j->transaction_next)
788 j->transaction_next->transaction_prev = j->transaction_prev;
790 j->transaction_prev = j->transaction_next = NULL;
792 while (j->subject_list)
793 job_dependency_free(j->subject_list);
795 while (j->object_list) {
796 Job *other = j->object_list->matters ? j->object_list->subject : NULL;
798 job_dependency_free(j->object_list);
800 if (other && delete_dependencies) {
801 log_debug("Deleting job %s/%s as dependency of job %s/%s",
802 other->unit->id, job_type_to_string(other->type),
803 j->unit->id, job_type_to_string(j->type));
804 transaction_delete_job(tr, other, delete_dependencies);
809 int transaction_add_job_and_dependencies(
817 bool ignore_requirements,
827 assert(type < _JOB_TYPE_MAX);
830 /* log_debug("Pulling in %s/%s from %s/%s", */
831 /* unit->id, job_type_to_string(type), */
832 /* by ? by->unit->id : "NA", */
833 /* by ? job_type_to_string(by->type) : "NA"); */
835 if (unit->load_state != UNIT_LOADED &&
836 unit->load_state != UNIT_ERROR &&
837 unit->load_state != UNIT_MASKED) {
838 dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s is not loaded properly.", unit->id);
842 if (type != JOB_STOP && unit->load_state == UNIT_ERROR) {
843 dbus_set_error(e, BUS_ERROR_LOAD_FAILED,
844 "Unit %s failed to load: %s. "
845 "See system logs and 'systemctl status %s' for details.",
847 strerror(-unit->load_error),
852 if (type != JOB_STOP && unit->load_state == UNIT_MASKED) {
853 dbus_set_error(e, BUS_ERROR_MASKED, "Unit %s is masked.", unit->id);
857 if (!unit_job_is_applicable(unit, type)) {
858 dbus_set_error(e, BUS_ERROR_JOB_TYPE_NOT_APPLICABLE, "Job type %s is not applicable for unit %s.", job_type_to_string(type), unit->id);
862 /* First add the job. */
863 ret = transaction_add_one_job(tr, type, unit, override, &is_new);
867 ret->ignore_order = ret->ignore_order || ignore_order;
869 /* Then, add a link to the job. */
871 if (!job_dependency_new(by, ret, matters, conflicts))
874 /* If the job has no parent job, it is the anchor job. */
875 assert(!tr->anchor_job);
876 tr->anchor_job = ret;
878 if (is_new && !ignore_requirements) {
881 /* If we are following some other unit, make sure we
882 * add all dependencies of everybody following. */
883 if (unit_following_set(ret->unit, &following) > 0) {
884 SET_FOREACH(dep, following, i) {
885 r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e);
887 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
897 /* Finally, recursively add in all dependencies. */
898 if (type == JOB_START || type == JOB_RELOAD_OR_START) {
899 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES], i) {
900 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
910 SET_FOREACH(dep, ret->unit->dependencies[UNIT_BIND_TO], i) {
911 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, true, override, false, false, ignore_order, e);
921 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) {
922 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e);
924 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
931 SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
932 r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e);
934 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
941 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE], i) {
942 r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, true, override, false, false, ignore_order, e);
952 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) {
953 r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e);
955 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
962 SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTS], i) {
963 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, true, override, true, false, ignore_order, e);
973 SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) {
974 r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e);
976 log_warning("Cannot add dependency job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
985 if (type == JOB_STOP || type == JOB_RESTART || type == JOB_TRY_RESTART) {
987 SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRED_BY], i) {
988 r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
998 SET_FOREACH(dep, ret->unit->dependencies[UNIT_BOUND_BY], i) {
999 r = transaction_add_job_and_dependencies(tr, type, dep, ret, true, override, false, false, ignore_order, e);
1010 if (type == JOB_RELOAD || type == JOB_RELOAD_OR_START) {
1012 SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATE_RELOAD_TO], i) {
1013 r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e);
1015 log_warning("Cannot add dependency reload job for unit %s, ignoring: %s", dep->id, bus_error(e, r));
1023 /* JOB_VERIFY_STARTED, JOB_RELOAD require no dependency handling */
1032 int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
1041 HASHMAP_FOREACH_KEY(u, k, m->units, i) {
1043 /* ignore aliases */
1047 if (u->ignore_on_isolate)
1050 /* No need to stop inactive jobs */
1051 if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(u)) && !u->job)
1054 /* Is there already something listed for this? */
1055 if (hashmap_get(tr->jobs, u))
1058 r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, false, NULL);
1060 log_warning("Cannot add isolate job for unit %s, ignoring: %s", u->id, strerror(-r));
1066 Transaction *transaction_new(void) {
1069 tr = new0(Transaction, 1);
1073 tr->jobs = hashmap_new(trivial_hash_func, trivial_compare_func);
1082 void transaction_free(Transaction *tr) {
1083 assert(hashmap_isempty(tr->jobs));
1084 hashmap_free(tr->jobs);