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

Try to diagnose why RestartingLoadStepTest.updatedBindingsOnRestart is flaky #366

Conversation

dwnusbaum
Copy link
Member

I recently received a bug report with similar symptoms as described in the @Ignore message added to RestartingLoadStepTest.updatedBindingsOnRestart in b3a6847 (from #363, same flake was also mentioned in #362 (comment)), so I want to investigate in case the flakes we've seen recently are related.

@dwnusbaum
Copy link
Member Author

dwnusbaum commented Jul 17, 2020

Perfect, worked first try! Here is the XML dump of the program:
<org.jenkinsci.plugins.workflow.cps.CpsThreadGroup>
  <threads class="java.util.concurrent.ConcurrentSkipListMap" serialization="custom">
    <unserializable-parents/>
    <java.util.concurrent.ConcurrentSkipListMap>
      <default/>
      <int>0</int>
      <org.jenkinsci.plugins.workflow.cps.CpsThread>
        <group reference="../../../.."/>
        <id>0</id>
        <program class="org.jenkinsci.plugins.workflow.cps.SandboxContinuable">
          <e class="com.cloudbees.groovy.cps.impl.FunctionCallEnv">
            <returnAddress class="com.cloudbees.groovy.cps.impl.SequenceBlock$ContinuationImpl">
              <e class="com.cloudbees.groovy.cps.impl.BlockScopeEnv">
                <parent class="com.cloudbees.groovy.cps.impl.BlockScopeEnv">
                  <parent class="com.cloudbees.groovy.cps.impl.FunctionCallEnv">
                    <returnAddress class="com.cloudbees.groovy.cps.Continuation$Halt"/>
                    <types class="empty-map"/>
                    <caller class="com.cloudbees.groovy.cps.impl.FunctionCallEnv">
                      <returnAddress class="com.cloudbees.groovy.cps.Continuation$Halt" reference="../../returnAddress"/>
                      <types class="empty-map"/>
                      <invoker class="com.cloudbees.groovy.cps.sandbox.SandboxInvoker"/>
                      <depth>1</depth>
                      <locals>
                        <entry>
                          <string>this</string>
                          <null/>
                        </entry>
                      </locals>
                    </caller>
                    <invoker class="com.cloudbees.groovy.cps.sandbox.SandboxInvoker" reference="../caller/invoker"/>
                    <depth>2</depth>
                    <locals>
                      <entry>
                        <string>this</string>
                        <WorkflowScript serialization="custom">
                          <unserializable-parents>
                            <binding>
                              <variables class="linked-hash-map">
                                <entry>
                                  <string>steps</string>
                                  <org.jenkinsci.plugins.workflow.cps.DSL>
                                    <handle class="org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner">
                                      <job>p</job>
                                      <id>1</id>
                                    </handle>
                                  </org.jenkinsci.plugins.workflow.cps.DSL>
                                </entry>
                                <entry>
                                  <string>tmp</string>
                                  <string>tmp2</string>
                                </entry>
                                <entry>
                                  <string>a</string>
                                  <org.jenkinsci.plugins.workflow.cps.CpsClosure2>
                                    <delegate class="Script1" serialization="custom">
                                      <unserializable-parents>
                                        <binding reference="../../../../../.."/>
                                      </unserializable-parents>
                                      <com.cloudbees.groovy.cps.SerializableScript>
                                        <linked-hash-map reference="../../../../.."/>
                                      </com.cloudbees.groovy.cps.SerializableScript>
                                    </delegate>
                                    <owner class="Script1" reference="../delegate"/>
                                    <thisObject class="Script1" reference="../delegate"/>
                                    <resolveStrategy>0</resolveStrategy>
                                    <directive>0</directive>
                                    <parameterTypes/>
                                    <maximumNumberOfParameters>0</maximumNumberOfParameters>
                                    <def>
                                      <body class="com.cloudbees.groovy.cps.impl.BlockScopedBlock">
                                        <exp class="com.cloudbees.groovy.cps.impl.SequenceBlock">
                                          <exp1 class="com.cloudbees.groovy.cps.impl.FunctionCallBlock">
                                            <tags class="java.util.Arrays$ArrayList">
                                              <a class="com.cloudbees.groovy.cps.sandbox.CallSiteTag-array">
                                                <com.cloudbees.groovy.cps.sandbox.Untrusted/>
                                              </a>
                                            </tags>
                                            <lhsExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                                              <value class="java-class">org.jenkinsci.plugins.workflow.cps.Safepoint</value>
                                            </lhsExp>
                                            <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                                              <value class="string">safepoint</value>
                                            </nameExp>
                                            <argExps/>
                                            <loc>
                                              <method>
                                                <declaringClass>Script1</declaringClass>
                                                <methodName>run</methodName>
                                                <fileName>Script1.groovy</fileName>
                                              </method>
                                              <lineNumber>1</lineNumber>
                                            </loc>
                                            <safe>false</safe>
                                          </exp1>
                                          <exp2 class="com.cloudbees.groovy.cps.impl.BlockScopedBlock">
                                            <exp class="com.cloudbees.groovy.cps.impl.PropertyAccessBlock">
                                              <tags class="java.util.Arrays$ArrayList" reference="../../../exp1/tags"/>
                                              <lhs class="com.cloudbees.groovy.cps.impl.JavaThisBlock"/>
                                              <property class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                                                <value class="string">tmp</value>
                                              </property>
                                              <loc>
                                                <method reference="../../../../exp1/loc/method"/>
                                                <lineNumber>1</lineNumber>
                                              </loc>
                                              <safe>false</safe>
                                            </exp>
                                          </exp2>
                                        </exp>
                                      </body>
                                      <parameters class="com.google.common.collect.EmptyImmutableList" resolves-to="com.google.common.collect.ImmutableList$SerializedForm">
                                        <elements/>
                                      </parameters>
                                      <capture class="com.cloudbees.groovy.cps.impl.BlockScopeEnv">
                                        <parent class="com.cloudbees.groovy.cps.impl.BlockScopeEnv">
                                          <parent class="com.cloudbees.groovy.cps.impl.FunctionCallEnv">
                                            <returnAddress class="org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter">
                                              <outer-class>
                                                <thread>
                                                  <group reference="../../../../../../../../../../../../../../../../../../../../../../../../.."/>
                                                  <id>4</id>
                                                  <program class="org.jenkinsci.plugins.workflow.cps.SandboxContinuable">
                                                    <k class="com.cloudbees.groovy.cps.Continuation$Halt" reference="../../../../../../../../../../../../../../../../../returnAddress"/>
                                                    <thread reference="../.."/>
                                                  </program>
                                                  <head serialization="custom">
                                                    <org.jenkinsci.plugins.workflow.cps.FlowHead>
                                                      <int>1</int>
                                                    </org.jenkinsci.plugins.workflow.cps.FlowHead>
                                                  </head>
                                                  <contextVariables>
                                                    <values>
                                                      <hudson.model.Executor>
                                                        <task class="org.jenkinsci.plugins.workflow.support.steps.ExecutorStepExecution$PlaceholderTask">
                                                          <context class="org.jenkinsci.plugins.workflow.cps.CpsStepContext">
                                                            <executionRef class="org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner" reference="../../../../../../../../../../../../../../../entry/org.jenkinsci.plugins.workflow.cps.DSL/handle"/>
                                                            <id>3</id>
                                                            <bodyHeads/>
                                                            <threadId>0</threadId>
                                                            <stepDescriptorId>org.jenkinsci.plugins.workflow.support.steps.ExecutorStep</stepDescriptorId>
                                                          </context>
                                                          <label></label>
                                                          <runId>p#1</runId>
                                                          <cookie>158e9e72-c7f5-4849-8456-948fe62b850a</cookie>
                                                        </task>
                                                        <isEphemeral>false</isEphemeral>
                                                      </hudson.model.Executor>
                                                      <hudson.model.Hudson_-MasterComputer>
                                                        <slave></slave>
                                                      </hudson.model.Hudson_-MasterComputer>
                                                      <hudson.EnvVars serialization="custom">
                                                        <unserializable-parents/>
                                                        <tree-map>
                                                          <default>
                                                            <comparator class="hudson.util.CaseInsensitiveComparator"/>
                                                          </default>
                                                          <int>49</int>
                                                          <string>BRANCH_NAME</string>
                                                          <string>PR-366</string>
                                                          <string>BUILD_DISPLAY_NAME</string>
                                                          <string>#1</string>
                                                          <string>BUILD_ID</string>
                                                          <string>1</string>
                                                          <string>BUILD_NUMBER</string>
                                                          <string>1</string>
                                                          <string>BUILD_TAG</string>
                                                          <string>jenkins-Plugins-workflow-cps-plugin-PR-366-1</string>
                                                          <string>BUILD_URL</string>
                                                          <string>https://ci.jenkins.io/job/Plugins/job/workflow-cps-plugin/job/PR-366/1/</string>
                                                          <string>CHANGE_AUTHOR</string>
                                                          <string>dwnusbaum</string>
                                                          <string>CHANGE_AUTHOR_DISPLAY_NAME</string>
                                                          <string>Devin Nusbaum</string>
                                                          <string>CHANGE_BRANCH</string>
                                                          <string>RestartingLoadStepTest.updatedBindingsOnRestart</string>
                                                          <string>CHANGE_FORK</string>
                                                          <string>dwnusbaum</string>
                                                          <string>CHANGE_ID</string>
                                                          <string>366</string>
                                                          <string>CHANGE_TARGET</string>
                                                          <string>master</string>
                                                          <string>CHANGE_TITLE</string>
                                                          <string> Try to diagnose why RestartingLoadStepTest.updatedBindingsOnRestart is flaky</string>
                                                          <string>CHANGE_URL</string>
                                                          <string>https://github.com/jenkinsci/workflow-cps-plugin/pull/366</string>
                                                          <string>EXECUTOR_NUMBER</string>
                                                          <string>0</string>
                                                          <string>HOME</string>
                                                          <string>/home/jenkins</string>
                                                          <string>HUDSON_COOKIE</string>
                                                          <string>4b2f34c0-3042-4921-a916-bec09158ec38</string>
                                                          <string>HUDSON_HOME</string>
                                                          <string>/var/jenkins_home</string>
                                                          <string>HUDSON_SERVER_COOKIE</string>
                                                          <string>cf859074e675309c</string>
                                                          <string>HUDSON_URL</string>
                                                          <string>http://localhost:41397/jenkins/</string>
                                                          <string>JAVA_HOME</string>
                                                          <string>/home/jenkins/tools/hudson.model.JDK/jdk11/jdk-11.0.6+10</string>
                                                          <string>JENKINS_HOME</string>
                                                          <string>/var/jenkins_home</string>
                                                          <string>JENKINS_NODE_COOKIE</string>
                                                          <string>158e9e72-c7f5-4849-8456-948fe62b850a</string>
                                                          <string>JENKINS_SERVER_COOKIE</string>
                                                          <string>durable-bfbbe10fb4d6d97895099c5214110de6</string>
                                                          <string>JENKINS_URL</string>
                                                          <string>http://localhost:41397/jenkins/</string>
                                                          <string>JOB_BASE_NAME</string>
                                                          <string>PR-366</string>
                                                          <string>JOB_DISPLAY_URL</string>
                                                          <string>https://ci.jenkins.io/job/Plugins/job/workflow-cps-plugin/job/PR-366/display/redirect</string>
                                                          <string>JOB_NAME</string>
                                                          <string>Plugins/workflow-cps-plugin/PR-366</string>
                                                          <string>JOB_URL</string>
                                                          <string>https://ci.jenkins.io/job/Plugins/job/workflow-cps-plugin/job/PR-366/</string>
                                                          <string>LANG</string>
                                                          <string>C.UTF-8</string>
                                                          <string>LOGNAME</string>
                                                          <string>jenkins</string>
                                                          <string>MAIL</string>
                                                          <string>/var/mail/jenkins</string>
                                                          <string>MAVEN_CMD_LINE_ARGS</string>
                                                          <string> --batch-mode --show-version --errors -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -s /home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366@tmp/settings-azure.xml --update-snapshots -Dmaven.repo.local=/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366@tmp/m2repo -Dmaven.test.failure.ignore -Dset.changelist -Djenkins.version=2.222.3 -Daccess-modifier-checker.failOnError=false -Djava.level=8 clean install</string>
                                                          <string>MAVEN_PROJECTBASEDIR</string>
                                                          <string>/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366</string>
                                                          <string>NODE_LABELS</string>
                                                          <string>master</string>
                                                          <string>NODE_NAME</string>
                                                          <string>master</string>
                                                          <string>OLDPWD</string>
                                                          <string>/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366</string>
                                                          <string>PATH</string>
                                                          <string>/home/jenkins/tools/hudson.tasks.Maven_MavenInstallation/mvn/bin:${JAVA_HOME}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games</string>
                                                          <string>PWD</string>
                                                          <string>/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366</string>
                                                          <string>RUN_CHANGES_DISPLAY_URL</string>
                                                          <string>https://ci.jenkins.io/job/Plugins/job/workflow-cps-plugin/job/PR-366/1/display/redirect?page=changes</string>
                                                          <string>RUN_DISPLAY_URL</string>
                                                          <string>https://ci.jenkins.io/job/Plugins/job/workflow-cps-plugin/job/PR-366/1/display/redirect</string>
                                                          <string>SHELL</string>
                                                          <string>/bin/sh</string>
                                                          <string>SSH_CLIENT</string>
                                                          <string>104.208.238.39 37054 22</string>
                                                          <string>SSH_CONNECTION</string>
                                                          <string>104.208.238.39 37054 172.31.18.9 22</string>
                                                          <string>STAGE_NAME</string>
                                                          <string>Build (linux-11-2.222.3)</string>
                                                          <string>USER</string>
                                                          <string>jenkins</string>
                                                          <string>WORKSPACE</string>
                                                          <string>/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366/target/tmp/j h844518178039919312/workspace/p</string>
                                                          <string>XDG_RUNTIME_DIR</string>
                                                          <string>/run/user/1000</string>
                                                          <string>XDG_SESSION_ID</string>
                                                          <string>31</string>
                                                        </tree-map>
                                                        <hudson.EnvVars>
                                                          <default>
                                                            <platform>UNIX</platform>
                                                          </default>
                                                        </hudson.EnvVars>
                                                      </hudson.EnvVars>
                                                      <org.jenkinsci.plugins.workflow.support.steps.FilePathDynamicContext_-FilePathRepresentation>
                                                        <slave></slave>
                                                        <path>/home/jenkins/workspace/ugins_workflow-cps-plugin_PR-366/target/tmp/j h844518178039919312/workspace/p</path>
                                                      </org.jenkinsci.plugins.workflow.support.steps.FilePathDynamicContext_-FilePathRepresentation>
                                                    </values>
                                                  </contextVariables>
                                                  <completionHandlers/>
                                                </thread>
                                                <callbacks>
                                                  <org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback_-Wrapper>
                                                    <v class="org.jenkinsci.plugins.workflow.cps.CpsStepContext">
                                                      <executionRef class="org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner" reference="../../../../../../../../../../../../entry/org.jenkinsci.plugins.workflow.cps.DSL/handle"/>
                                                      <id>5</id>
                                                      <bodyHeads>
                                                        <int>1</int>
                                                      </bodyHeads>
                                                      <threadId>2</threadId>
                                                      <stepDescriptorId>org.jenkinsci.plugins.workflow.cps.steps.LoadStep</stepDescriptorId>
                                                    </v>
                                                  </org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback_-Wrapper>
                                                </callbacks>
                                                <context reference="../callbacks/org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback_-Wrapper/v"/>
                                                <startNodeId>6</startNodeId>
                                                <onSuccess class="org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter" reference="../.."/>
                                                <onFailure class="org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$FailureAdapter">
                                                  <outer-class reference="../.."/>
                                                </onFailure>
                                                <outcome>
                                                  <normal class="org.jenkinsci.plugins.workflow.cps.CpsClosure2" reference="../../../../../../../.."/>
                                                </outcome>
                                                <bodyToUnexport class="org.jenkinsci.plugins.workflow.cps.StaticBodyReference" resolves-to="org.jenkinsci.plugins.workflow.cps.HandleBodyReference">
                                                  <id>3</id>
                                                </bodyToUnexport>
                                              </outer-class>
                                            </returnAddress>
                                            <types class="empty-map"/>
                                            <caller class="com.cloudbees.groovy.cps.impl.TryBlockEnv">
                                              <parent class="com.cloudbees.groovy.cps.impl.FunctionCallEnv">
                                                <returnAddress class="org.jenkinsci.plugins.workflow.cps.CpsBodyExecution$SuccessAdapter" reference="../../../returnAddress"/>
                                                <types class="empty-map"/>
                                                <invoker class="com.cloudbees.groovy.cps.sandbox.SandboxInvoker"/>
                                                <depth>1</depth>
                                                <locals>
                                                  <entry>
                                                    <string>this</string>
                                                    <null/>
                                                  </entry>
                                                </locals>
                                              </parent>
                                              <depth>1</depth>
                                              <handlers class="linked-hash-map">
                                                <entry>
                                                  <java-class>java.lang.Throwable</java-class>
                                                  <org.jenkinsci.plugins.workflow.cps.CpsBodyExecution_-FailureAdapter reference="../../../../returnAddress/outer-class/onFailure"/>
                                                </entry>
                                              </handlers>
                                            </caller>
                                            <invoker class="com.cloudbees.groovy.cps.sandbox.SandboxInvoker" reference="../caller/parent/invoker"/>
                                            <depth>2</depth>
                                            <locals>
                                              <entry>
                                                <string>this</string>
                                                <Script1 reference="../../../../../../../delegate"/>
                                              </entry>
                                            </locals>
                                          </parent>
                                          <depth>2</depth>
                                          <locals class="empty-map"/>
                                          <types class="empty-map"/>
                                        </parent>
                                        <depth>2</depth>
                                        <locals class="empty-map"/>
                                        <types class="empty-map"/>
                                      </capture>
                                      <self class="org.jenkinsci.plugins.workflow.cps.CpsClosure2" reference="../.."/>
                                    </def>
                                  </org.jenkinsci.plugins.workflow.cps.CpsClosure2>
                                </entry>
                              </variables>
                            </binding>
                          </unserializable-parents>
                          <com.cloudbees.groovy.cps.SerializableScript>
                            <linked-hash-map reference="../../unserializable-parents/binding/variables"/>
                          </com.cloudbees.groovy.cps.SerializableScript>
                        </WorkflowScript>
                      </entry>
                    </locals>
                  </parent>
                  <depth>2</depth>
                  <locals class="empty-map"/>
                  <types class="empty-map"/>
                </parent>
                <depth>2</depth>
                <locals class="empty-map"/>
                <types class="empty-map"/>
              </e>
              <k class="com.cloudbees.groovy.cps.impl.SequenceBlock$ContinuationImpl">
                <e class="com.cloudbees.groovy.cps.impl.BlockScopeEnv" reference="../../e"/>
                <k class="com.cloudbees.groovy.cps.Continuation$Halt" reference="../../e/parent/parent/returnAddress"/>
                <exp2 class="com.cloudbees.groovy.cps.impl.FunctionCallBlock">
                  <tags class="java.util.Arrays$ArrayList">
                    <a class="com.cloudbees.groovy.cps.sandbox.CallSiteTag-array">
                      <com.cloudbees.groovy.cps.sandbox.Untrusted reference="../../../../../e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/def/body/exp/exp1/tags/a/com.cloudbees.groovy.cps.sandbox.Untrusted"/>
                    </a>
                  </tags>
                  <lhsExp class="com.cloudbees.groovy.cps.impl.JavaThisBlock" reference="../../../e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/def/body/exp/exp2/exp/lhs"/>
                  <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                    <value class="string">echo</value>
                  </nameExp>
                  <argExps>
                    <com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                      <tags class="java.util.Arrays$ArrayList" reference="../../../tags"/>
                      <lhsExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                        <value class="java-class">org.codehaus.groovy.runtime.GStringImpl</value>
                      </lhsExp>
                      <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                        <value class="string">&lt;init&gt;</value>
                      </nameExp>
                      <argExps>
                        <com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                          <tags class="java.util.Arrays$ArrayList" reference="../../../../../tags"/>
                          <lhsExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                            <value class="java-class">org.codehaus.groovy.runtime.ScriptBytecodeAdapter</value>
                          </lhsExp>
                          <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                            <value class="string">asType</value>
                          </nameExp>
                          <argExps>
                            <com.cloudbees.groovy.cps.impl.ListBlock>
                              <argExps>
                                <com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                                  <tags class="java.util.Arrays$ArrayList" reference="../../../../../../../../../tags"/>
                                  <lhsExp class="com.cloudbees.groovy.cps.impl.JavaThisBlock" reference="../../../../../../../../../../../e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/def/body/exp/exp2/exp/lhs"/>
                                  <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                                    <value class="string">a</value>
                                  </nameExp>
                                  <argExps/>
                                  <loc>
                                    <method>
                                      <declaringClass>WorkflowScript</declaringClass>
                                      <methodName>run</methodName>
                                      <fileName>WorkflowScript</fileName>
                                    </method>
                                    <lineNumber>9</lineNumber>
                                  </loc>
                                  <safe>false</safe>
                                </com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                              </argExps>
                            </com.cloudbees.groovy.cps.impl.ListBlock>
                            <com.cloudbees.groovy.cps.impl.ConstantBlock>
                              <value class="java-class">[Ljava.lang.Object;</value>
                            </com.cloudbees.groovy.cps.impl.ConstantBlock>
                          </argExps>
                          <loc>
                            <method reference="../../argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                            <lineNumber>9</lineNumber>
                          </loc>
                          <safe>false</safe>
                        </com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                        <com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                          <tags class="java.util.Arrays$ArrayList" reference="../../../../../tags"/>
                          <lhsExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                            <value class="java-class">org.codehaus.groovy.runtime.ScriptBytecodeAdapter</value>
                          </lhsExp>
                          <nameExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                            <value class="string">asType</value>
                          </nameExp>
                          <argExps>
                            <com.cloudbees.groovy.cps.impl.ListBlock>
                              <argExps>
                                <com.cloudbees.groovy.cps.impl.ConstantBlock>
                                  <value class="string">after restart: </value>
                                </com.cloudbees.groovy.cps.impl.ConstantBlock>
                                <com.cloudbees.groovy.cps.impl.ConstantBlock>
                                  <value class="string"></value>
                                </com.cloudbees.groovy.cps.impl.ConstantBlock>
                              </argExps>
                            </com.cloudbees.groovy.cps.impl.ListBlock>
                            <com.cloudbees.groovy.cps.impl.ConstantBlock>
                              <value class="java-class">[Ljava.lang.String;</value>
                            </com.cloudbees.groovy.cps.impl.ConstantBlock>
                          </argExps>
                          <loc>
                            <method reference="../../../com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                            <lineNumber>9</lineNumber>
                          </loc>
                          <safe>false</safe>
                        </com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                      </argExps>
                      <loc>
                        <method reference="../../argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                        <lineNumber>9</lineNumber>
                      </loc>
                      <safe>false</safe>
                    </com.cloudbees.groovy.cps.impl.FunctionCallBlock>
                  </argExps>
                  <loc>
                    <method reference="../../argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                    <lineNumber>9</lineNumber>
                  </loc>
                  <safe>false</safe>
                </exp2>
              </k>
              <exp2 class="com.cloudbees.groovy.cps.impl.AssignmentBlock">
                <tags class="java.util.Arrays$ArrayList" reference="../../k/exp2/tags"/>
                <lhsExp class="com.cloudbees.groovy.cps.LValueBlock$BlockImpl">
                  <outer-class class="com.cloudbees.groovy.cps.impl.PropertyAccessBlock">
                    <tags class="java.util.Arrays$ArrayList" reference="../../../../k/exp2/tags"/>
                    <lhs class="com.cloudbees.groovy.cps.impl.JavaThisBlock" reference="../../../../e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/def/body/exp/exp2/exp/lhs"/>
                    <property class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                      <value class="string">tmp</value>
                    </property>
                    <loc>
                      <method reference="../../../../../k/exp2/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                      <lineNumber>8</lineNumber>
                    </loc>
                    <safe>false</safe>
                  </outer-class>
                </lhsExp>
                <rhsExp class="com.cloudbees.groovy.cps.impl.ConstantBlock">
                  <value class="string">tmp3</value>
                </rhsExp>
                <loc>
                  <method reference="../../../k/exp2/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
                  <lineNumber>8</lineNumber>
                </loc>
              </exp2>
            </returnAddress>
            <types>
              <entry>
                <string>suspendValue</string>
                <java-class>java.lang.Object</java-class>
              </entry>
            </types>
            <caller class="com.cloudbees.groovy.cps.impl.BlockScopeEnv" reference="../returnAddress/e"/>
            <callSiteLoc>
              <method reference="../../returnAddress/k/exp2/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/argExps/com.cloudbees.groovy.cps.impl.ListBlock/argExps/com.cloudbees.groovy.cps.impl.FunctionCallBlock/loc/method"/>
              <lineNumber>7</lineNumber>
            </callSiteLoc>
            <invoker class="com.cloudbees.groovy.cps.sandbox.SandboxInvoker" reference="../returnAddress/e/parent/parent/caller/invoker"/>
            <depth>3</depth>
            <locals>
              <entry>
                <string>this</string>
                <null/>
              </entry>
              <entry>
                <string>suspendValue</string>
                <null/>
              </entry>
            </locals>
          </e>
          <k class="com.cloudbees.groovy.cps.impl.SequenceBlock$ContinuationImpl" reference="../e/returnAddress"/>
          <thread reference="../.."/>
        </program>
        <head reference="../program/e/returnAddress/e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/def/capture/parent/parent/returnAddress/outer-class/thread/head"/>
        <step class="org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep$Execution">
          <context class="org.jenkinsci.plugins.workflow.cps.CpsStepContext">
            <executionRef class="org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner" reference="../../../program/e/returnAddress/e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry/org.jenkinsci.plugins.workflow.cps.DSL/handle"/>
            <id>13</id>
            <bodyHeads/>
            <threadId>0</threadId>
            <stepDescriptorId>org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep</stepDescriptorId>
          </context>
          <step>
            <id>wait</id>
            <number>1</number>
          </step>
          <k>wait/1</k>
        </step>
        <completionHandlers/>
      </org.jenkinsci.plugins.workflow.cps.CpsThread>
      <null/>
    </java.util.concurrent.ConcurrentSkipListMap>
  </threads>
  <iota>5</iota>
  <paused>
    <value>0</value>
  </paused>
  <closures/>
  <scripts>
    <WorkflowScript reference="../../threads/java.util.concurrent.ConcurrentSkipListMap/org.jenkinsci.plugins.workflow.cps.CpsThread/program/e/returnAddress/e/parent/parent/locals/entry/WorkflowScript"/>
    <Script1 reference="../../threads/java.util.concurrent.ConcurrentSkipListMap/org.jenkinsci.plugins.workflow.cps.CpsThread/program/e/returnAddress/e/parent/parent/locals/entry/WorkflowScript/unserializable-parents/binding/variables/entry[3]/org.jenkinsci.plugins.workflow.cps.CpsClosure2/delegate"/>
  </scripts>
</org.jenkinsci.plugins.workflow.cps.CpsThreadGroup>

IIUC, the problem is that a, which is a closure stored in the script's binding, has captured the current CpsThread, and CpsThread.contextVariables still contains the ExecutorStepExecution that should have already completed. At first glance the issue seems highly related to #279 and #245.

One thing that is confusing to me is that I have not been able to reproduce this flake locally; I have only seen it on ci.jenkins.io. Perhaps it is specific to Java 11??

@dwnusbaum dwnusbaum marked this pull request as draft July 17, 2020 21:42
@dwnusbaum dwnusbaum requested a review from olamy July 17, 2020 21:47
@dwnusbaum
Copy link
Member Author

dwnusbaum commented Jul 22, 2020

I have been looking into this. The minimal reproducer is something like this:

def closure = null
node {
  closure = { -> "This closure captures the CpsBodyExecution" }
}
// node step is complete, but its execution is reachable via the closure's captured variables.
// Agent is rehydrated if you restart Jenkins here.
echo(closure())

I'll file a JENKINS ticket and a separate PR with a potential fix (not really sure about the best approach), and then I'll close this PR.

@dwnusbaum
Copy link
Member Author

See #367 for the fix.

@dwnusbaum dwnusbaum closed this Jul 22, 2020
@dwnusbaum dwnusbaum deleted the RestartingLoadStepTest.updatedBindingsOnRestart branch July 22, 2020 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant