[FIXED JENKINS-36144] Borrow the SCMTrigger's queue#126
[FIXED JENKINS-36144] Borrow the SCMTrigger's queue#126lanwen merged 6 commits intojenkinsci:masterfrom
Conversation
|
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
| maximumThreads = count; | ||
| try { | ||
| Field getQueue = SCMTrigger.DescriptorImpl.class.getDeclaredField("queue"); | ||
| getQueue.setAccessible(true); |
There was a problem hiding this comment.
of course... but after a more careful analysis I decided against that and rather just mirror the pool size... which sadly means you have two pools... but this does point that perhaps we should have an explicit pool for polling that plugins can use rather than the current status where each push notifier has to roll their own... with hillarious consequences
…er not to borrow - we will mirror the count though
|
🐝 @stephenc I assume you are going to file a issue for the generic issue
|
|
🐝 A future further improvement could perhaps also be to not schedule the polling if the same repo and branch is already in the queue. |
|
Queue skipping polling for the same project AFAIK |
Could you describe how queue works now? |
| return ALLOW_HOOKURL_OVERRIDE; | ||
| } | ||
|
|
||
| private static ThreadFactory threadFactory() { |
There was a problem hiding this comment.
it should be method that returns executors - threadPoolWithCapacity(int)
(it allows to reduce complexity of checkThreadPoolSize)
There was a problem hiding this comment.
I don't see the value, seems like change for change's sake. The other method is not too complex whereas we'd need to add a three way test to use this as an executor service factory method
There was a problem hiding this comment.
Don't think the complexity reduction in such simple way is "like change for change's sake". At minimal state it should be named as namedThreadFactory as of its simple shortcut.
|
🐛 as I think the Executor service has the potential to leak threads (at least temporarily until some GC kicks in, the point of which is non-deterministic) |
|
I think you need to look at queue.setExecutor Sent from my iPhone
|
|
Yes, my bad. 🐝 |
| if (maximumThreads != count) { | ||
| maximumThreads = count; | ||
| queue.setExecutors( | ||
| (count == 0 |
|
Btw, the same queue i'm using in other trigger plugins. Is it possible to make queue public and place configuration in global config? |
|
That is the RFE against core that I filed BTW. What I may do is add a proxy implementation into SCM-API so that people can use against earlier cores Sent from my iPhone
|
|
@reviewbybees @stephenc relogin! |
|
Nahh just depends which email I reply to! |
|
Anyway, my phone is the holder of the 2FA for that account... |
| * Update the {@link java.util.concurrent.ExecutorService} instance. | ||
| */ | ||
| /*package*/ | ||
| synchronized void checkThreadPoolSizeAndUpdateIfNecessary() { |
There was a problem hiding this comment.
it should be a test for this logic
There was a problem hiding this comment.
I have lost any energy to continue this PR any further. I want to concentrate my time on the critical root cause, i.e. https://issues.jenkins-ci.org/browse/JENKINS-36147 which once implemented will mean we can rip out this code. If you want to add tests to this code which should be removed once I implement https://issues.jenkins-ci.org/browse/JENKINS-36147, feel free. I will not be updating this PR any further at this point.
There was a problem hiding this comment.
It would require updating core that is not good for this plugin. Or we can backport your core improvements after.
There was a problem hiding this comment.
well my plan is to make the API available via scm-api without a core bump... and then on newer cores it either will revert to the core implementation (classloader priority) or the scm-api variant will use reflection to redirect to the core implementation
There was a problem hiding this comment.
However, it will take me a while to get that API right (as I don't want to end up with the same mistakes of the main Queue API and end up having to have a "big fat lock") so for now, to save users from commit storms killing their Jenkins, this fix would be good to have released.
There was a problem hiding this comment.
ookay, i'll merge this. But this is an example of permanent state "will fix that better in future releases". It can't be finished while you've start do things right everywhere


https://issues.jenkins-ci.org/browse/JENKINS-36144
@reviewbybees @jenkinsci/code-reviewers
This change is