Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid holding locks from croak when calling notifyListeners #944

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 14, 2024

Trying to fix

Found one Java-level deadlock:
=============================
"Handling GET /…/job/main/ from … : Jetty (winstone)-17 Job/index.jelly WorkflowJob/sidepanel.jelly HistoryWidget/index.jelly":
  waiting to lock monitor 0x00007f2714a7b680 (object 0x0000000672800000, a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution),
    which is held by "jenkins.util.Timer [#5]"
    
    "jenkins.util.Timer [#5]":
      waiting to lock monitor 0x00007f26a0200300 (object 0x00000006728000a0, a java.lang.Object),
        which is held by "Handling GET /…/job/main/ from … : Jetty (winstone)-17 Job/index.jelly WorkflowJob/sidepanel.jelly HistoryWidget/index.jelly"
	
	Java stack information for the threads listed above:
	===================================================
	"Handling GET /…/job/main/ from … : Jetty (winstone)-17 Job/index.jelly WorkflowJob/sidepanel.jelly HistoryWidget/index.jelly":
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.isComplete(CpsFlowExecution.java:1323)
	- waiting to lock <0x0000000672800000> (a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.getCurrentExecutions(CpsFlowExecution.java:1057)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ResumeStepExecutionListener.onResumed(FlowExecutionList.java:309)
	at org.jenkinsci.plugins.workflow.flow.FlowExecutionListener.fireResumed(FlowExecutionListener.java:85)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:589)
	- locked <0x00000006728000a0> (a java.lang.Object)
	at hudson.model.RunMap.retrieve(RunMap.java:273)
	at hudson.model.RunMap.retrieve(RunMap.java:65)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:703)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.load(AbstractLazyLoadRunMap.java:685)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.getByNumber(AbstractLazyLoadRunMap.java:579)
	- locked <0x00000005e55ca3f0> (a hudson.model.RunMap)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.search(AbstractLazyLoadRunMap.java:537)
	at jenkins.model.lazy.AbstractLazyLoadRunMap.newestBuild(AbstractLazyLoadRunMap.java:470)
	at jenkins.model.lazy.LazyBuildMixIn.getLastBuild(LazyBuildMixIn.java:254)
	at org.jenkinsci.plugins.workflow.job.WorkflowJob.getLastBuild(WorkflowJob.java:242)
	at org.jenkinsci.plugins.workflow.job.WorkflowJob.getLastBuild(WorkflowJob.java:105)
	at hudson.model.Job.getBuildHealthReports(Job.java:1215)
	at …
	"jenkins.util.Timer [#5]":
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:629)
	- waiting to lock <0x00000006728000a0> (a java.lang.Object)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1068)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1565)
	at org.jenkinsci.plugins.workflow.cps.FlowHead.setNewHead(FlowHead.java:164)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.onProgramEnd(CpsFlowExecution.java:1342)
	- locked <0x0000000672800000> (a org.jenkinsci.plugins.workflow.cps.CpsFlowExecution)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.croak(CpsFlowExecution.java:919)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.loadProgramFailed(CpsFlowExecution.java:902)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onFailure(CpsFlowExecution.java:879)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:867)
	at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$2.onSuccess(CpsFlowExecution.java:855)
	at …
	at org.jenkinsci.plugins.workflow.support.pickles.TryRepeatedly.access$000(TryRepeatedly.java:48)
	at org.jenkinsci.plugins.workflow.support.pickles.TryRepeatedly$1.run(TryRepeatedly.java:114)
	at …

@jglick jglick requested a review from a team as a code owner October 14, 2024 22:25
@jglick jglick added the bug label Oct 14, 2024
execution.notifyListeners(List.of(head), true);
execution.notifyListeners(List.of(head), false);
};
if (asynchIfOutsideProgram) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only be true for croakonProgramHeadsetNewHead, the case observed to cause a problem.

@jglick jglick requested a review from dwnusbaum October 15, 2024 12:25
@jglick jglick merged commit 79cf4fd into jenkinsci:master Oct 15, 2024
17 checks passed
@jglick jglick deleted the croak branch October 15, 2024 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants