Skip to content

Commit

Permalink
[FIXED JENKINS-19446]
Browse files Browse the repository at this point in the history
Defer the notification to avoid deadlock.
  • Loading branch information
kohsuke committed Dec 3, 2013
1 parent 7c711ac commit a5755cb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -63,6 +63,9 @@
<div id="rc" style="display:none;"><!--=BEGIN=-->
<h3><a name=v1.543>What's new in 1.543</a> <!--=DATE=--></h3>
<ul class=image>
<li class=bug>
Fixed a possible dead lock problem in deleting projects.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-19446">issue 19446</a>)
<li class=bug>
HTML metacharacters not escaped in log messages.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-20800">issue 20800</a>)
Expand Down
31 changes: 17 additions & 14 deletions core/src/main/java/hudson/model/AbstractItem.java
Expand Up @@ -42,6 +42,7 @@
import hudson.util.AtomicFileWriter;
import hudson.util.IOUtils;
import jenkins.model.Jenkins;
import jenkins.model.Jenkins.MasterComputer;
import org.apache.tools.ant.taskdefs.Copy;
import org.apache.tools.ant.types.FileSet;
import org.kohsuke.stapler.WebMethod;
Expand Down Expand Up @@ -510,21 +511,23 @@ public synchronized void delete() throws IOException, InterruptedException {
checkPermission(DELETE);
performDelete();

try {
invokeOnDeleted();
} catch (AbstractMethodError e) {
// ignore
}

Jenkins.getInstance().rebuildDependencyGraphAsync();
}
// defer the notification to avoid the lock ordering problem. See JENKINS-19446.
MasterComputer.threadPoolForRemoting.submit(new java.util.concurrent.Callable<Void>() {
@Override
public Void call() throws Exception {
invokeOnDeleted();

This comment has been minimized.

Copy link
@jglick

jglick Dec 6, 2013

Member

This could make tests fail nondeterministically. Does it not suffice to use a synchronized block for the earlier part of the method, but then call onDeleted synchronously (without the lock) before returning from delete?

This comment has been minimized.

Copy link
@jglick

jglick Dec 19, 2013

Member

This is making my tests fail nondeterministically.

This comment has been minimized.

Copy link
@jglick

jglick Feb 28, 2014

Member
Jenkins.getInstance().rebuildDependencyGraphAsync();
return null;
}

/**
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
* on BugParade for more details.
*/
private void invokeOnDeleted() throws IOException {
getParent().onDeleted(this);
/**
* A pointless function to work around what appears to be a HotSpot problem. See JENKINS-5756 and bug 6933067
* on BugParade for more details.
*/
private void invokeOnDeleted() throws IOException {
getParent().onDeleted(AbstractItem.this);
}
});
}

/**
Expand Down

0 comments on commit a5755cb

Please sign in to comment.