2d46fe6
From 38012e20ada9a6d0eef38ce4abe6e18403c1e9dc Mon Sep 17 00:00:00 2001
2d46fe6
From: Michal Schmidt <mschmidt@redhat.com>
2d46fe6
Date: Thu, 25 Oct 2012 02:31:49 +0200
2d46fe6
Subject: [PATCH] job: avoid recursion into transaction code from job
2d46fe6
 cancelation
2d46fe6
2d46fe6
I hit an "assert(j->installed)" failure in transaction_apply(). Looking
2d46fe6
into the backtrace I saw what happened:
2d46fe6
1. The system was booting. var.mount/start was an installed job.
2d46fe6
2. I pressed Ctrl+Alt+Del.
2d46fe6
3. reboot.target was going to be isolated.
2d46fe6
4. transaction_apply() proceeded to install a var.mount/stop job.
2d46fe6
5. job_install() canceled the conflicting start job.
2d46fe6
6. Depending jobs ended recursively with JOB_DEPENDENCY, among them was
2d46fe6
   local-fs.target/start.
2d46fe6
7. Its OnFailure action triggered - emergency.target was now going to be
2d46fe6
   isolated.
2d46fe6
8. We recursed back into transaction_apply() where the half-installed
2d46fe6
   var.mount/stop job confused us.
2d46fe6
2d46fe6
Recursing from job installation back into the transaction code cannot be
2d46fe6
a good idea. Avoid the problem by canceling the conflicting job
2d46fe6
non-recursively in job_install(). I don't think we'll miss anything by
2d46fe6
not recursing here. After all, we are called from transaction_apply().
2d46fe6
We will not be installing just this one job, but all jobs from a
2d46fe6
transaction. All requirement dependencies will be included in it and
2d46fe6
will be installed separately. Every transaction job will get a chance
2d46fe6
to cancel its own conflicting installed job.
2d46fe6
(cherry picked from commit 1abc85b8d026a2d72442b0edaee5213d0ee73c1f)
2d46fe6
---
2d46fe6
 src/core/job.c | 2 +-
2d46fe6
 1 file changed, 1 insertion(+), 1 deletion(-)
2d46fe6
2d46fe6
diff --git a/src/core/job.c b/src/core/job.c
2d46fe6
index 020fe4d..1fff653 100644
2d46fe6
--- a/src/core/job.c
2d46fe6
+++ b/src/core/job.c
2d46fe6
@@ -178,7 +178,7 @@ Job* job_install(Job *j) {
2d46fe6
 
2d46fe6
         if (uj) {
2d46fe6
                 if (j->type != JOB_NOP && job_type_is_conflicting(uj->type, j->type))
2d46fe6
-                        job_finish_and_invalidate(uj, JOB_CANCELED, true);
2d46fe6
+                        job_finish_and_invalidate(uj, JOB_CANCELED, false);
2d46fe6
                 else {
2d46fe6
                         /* not conflicting, i.e. mergeable */
2d46fe6