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

Log a warning in CpsVmExecutorService when tasks start long after they were submitted #892

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import hudson.util.DaemonThreadFactory;
import hudson.util.ExceptionCatchingThreadFactory;
import hudson.util.NamingThreadFactory;
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
Expand Down Expand Up @@ -77,9 +79,18 @@

@Override
protected Runnable wrap(final Runnable r) {
Instant submitted = Instant.now();
Copy link
Member Author

Choose a reason for hiding this comment

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

Would need to be copied to the wrap(Callable) overload as well.

return () -> {
ThreadContext context = setUp();
try {
Duration sinceSubmission = Duration.between(submitted, Instant.now());
// TODO: It would be nice to have access to the size of SingleLaneExecutorService.tasks to be able to

Check warning on line 87 in plugin/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsVmExecutorService.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

TODO

NORMAL: It would be nice to have access to the size of SingleLaneExecutorService.tasks to be able to
// report it and use it to adjust the trigger, but that would require API changes in remoting.
// We could also try using Timeout to hard-kill tasks that take too long and then call
// CpsFlowExecution.croak, but that seems pretty severe and would need to be tested carefully.
if (sinceSubmission.toMinutes() > 5) {
LOGGER.log(Level.WARNING, () -> "CPS VM thread for " + cpsThreadGroup.getExecution() + " took " + sinceSubmission + " to start executing a task after it was submitted");
}
r.run();
} catch (final Throwable t) {
reportProblem(t);
Expand Down
Loading