-
Notifications
You must be signed in to change notification settings - Fork 34
java.io.NotSerializableException at com.cloudbees.groovy.cps.impl.ForInLoopBlock$ContinuationImpl.itr #105
Comments
A Jenkins environment which I'm currently working on has been experiencing this issue for the last two days after upgrading from version 2.78 to version 2.80 of the workflow-cps (Pipeline: Groovy) plug-in, which upgraded the version of The behavior has been quite strange, and I haven't been able to produce a reliable repro, yet. It was most notable around any step which touches the workspace. Steps like writeFile, fileExists, etc. were affected. It seems as if an error is being thrown close to the step, but is being caught and encapsulated within other exceptions, and the real stack trace is being lost. I'll try to get a repro generated when I can. |
Feel free to post the full stack trace from the exception if either of you have it. I am not really sure what could have broken this in 1.32. Maybe it could be related to the fact that now we eagerly expand methods with default parameters so that they are CPS-transformed? |
We just ran into the problem again after downgrading, so it looks like associating it with 1.32 was premature. Restarting the Jenkins master seems to resolve the problem temporarily with no changes to the pipeline code. Here's a link to the stack trace: It seems like something might be happening prior to the CPS-transformation. Is there any way for us to get more visibility at that level? |
Got some more detail. It looks like this was being caused by running I don't necessarily believe the behavior is wrong in this case, but it would be great to get better output for troubleshooting. |
With the hint about
I haven't spent any time debugging to understand the root cause, but at least one problem is that
What Pipeline durability level are you using? If you are using |
I spent a bit of time debugging this today, and realized that the above test is actually flaky, so it makes sense that you all only see the issue intermittently. Adding a I patched groovy-cps and workflow-cps to see if The next thing I would try is to put some breakpoints in |
Apologies for the delay in response, but I did verify that we are using |
I had a little more time to debug today and was able to narrow things down by adding some breakpoints to In cases where the test in #105 (comment) passes, So, it looks like The good news though is that I am pretty sure we can add a workaround in |
I tried reproducing the nondeterminism in raw Groovy but was unable to do so. This is the test case I used, which attempts to mimic the code in import java.util.Deque;
import java.util.List;
import java.util.LinkedList;
import org.codehaus.groovy.runtime.GroovyCategorySupport;
import org.codehaus.groovy.runtime.ScriptBytecodeAdapter;
public class MyCategory {
public static <T> Iterator<T> iterator(List<T> c) {
throw new Exception("Using List category method");
}
public static <T> Iterator<T> iterator(Deque<T> c) {
throw new Exception("Using Deque category method");
}
}
def list = new LinkedList(Arrays.asList(1, 2, 3));
GroovyCategorySupport.use(MyCategory.class, { ->
println(ScriptBytecodeAdapter.invokeMethod0(null, list, "iterator"));
}); In Groovy 2.4.15 and older, this always calls the list category method, and in Groovy 2.4.16 and newer, it always calls the deque category method. I looked at the commits between those versions in Groovy and nothing really stands out. Changing the reflective call to I think I am done trying to figure out the exact root cause at this point, so I'll just file a PR to workflow-cps to add a |
Thank you for your efforts on this! |
We do regularly face above issue in one of our pipelines.
Could you please have a look at #104
The text was updated successfully, but these errors were encountered: