Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10709

multiple builds are triggered for one change in Gerrit

      With Gerrit Trigger 2.3.0 we observe that sometimes there are multiple builds triggered for one change in Gerrit.

      Lets say in Jenkins build #25 is triggered by the Gerrit Trigger Plugin. Then we see for this build job the following message in Jenkins:
      Triggered by Gerrit: http://gerrit:8080/27060
      Other triggered builds for this event.
      myjob #25

      The strange thing is that the build job #25 says that there is another build job for the same event which actually itself (again build job #25).

      On the change in Gerrit we then get the following comments:
      1. Build Started http://jenkins:8080/jenkins/job/myjob/25/ (1/2)
      2. Build Started http://jenkins:8080/jenkins/job/myjob/25/ (2/2)
      3. Build Failed
      http://jenkins:8080/jenkins/job/myjob/25/ : FAILURE
      http://jenkins:8080/jenkins/job/myjob/25/ : FAILURE

      In Jenkins it looks like the build job is indeed triggered twice. At least we saw the build job #25 two times in the list of current builds. Normally our tests are failing if they are executed two times in parallel since they need exclusive access to certain resources.

      For the failed build job I have then the possibility to retirgger it by clicking on 'Retrigger' or 'Retrigger All'.
      'Retrigger' starts another build #26, but for the voting still the result of build #25 is taken into account:
      1. Build Started http://jenkins:8080/jenkins/job/myjob/26/ (2/2)
      2. Build Failed
      http://jenkins:8080/jenkins/job/myjob/25/ : FAILURE
      http://jenkins:8080/jenkins/job/myjob/26/ : SUCCESS

      Why does the Gerrit Trigger start multiple builds for only one change in Gerrit? Is this some feature? Can we configure the Gerrit Trigger plugin to always only start a single build?

      Any help would be appreciated. Thanks!

          [JENKINS-10709] multiple builds are triggered for one change in Gerrit

          Edwin Kempin created issue -

          rsandell added a comment -

          This is very similar, but not completely, to bug that I have been trying to solve for the last couple of days.
          And it is definitely a bug.
          In our environment we see some builds triggered more than once on the same patch-set event. The cause seems to be that the project gets duplicated in the list of listeners for the events, so it gets called for every occasion it appears in the list, but I have no idea how that can happen and have been trying to recreate the circumstances to no avail.

          I will attach a groovy script that you can run to see if it is the same in your server.

          rsandell added a comment - This is very similar, but not completely, to bug that I have been trying to solve for the last couple of days. And it is definitely a bug. In our environment we see some builds triggered more than once on the same patch-set event. The cause seems to be that the project gets duplicated in the list of listeners for the events, so it gets called for every occasion it appears in the list, but I have no idea how that can happen and have been trying to recreate the circumstances to no avail. I will attach a groovy script that you can run to see if it is the same in your server.

          rsandell added a comment -

          A groovy script you can execute on the master to see if there are any duplicated listeners for a triggered project.

          rsandell added a comment - A groovy script you can execute on the master to see if there are any duplicated listeners for a triggered project.
          rsandell made changes -

          zlosch added a comment - - edited

          The script throws an error on the above Jenkins instance:

          groovy.lang.MissingMethodException: No signature of method: java.util.LinkedList.keySet() is applicable for argument types: () values: []
          	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
          	at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48)
          	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
          	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
          	at Script1.run(Script1.groovy:2)
          	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:561)
          	at groovy.lang.GroovyShell.evaluate(GroovyShell.java:536)
          	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:141)
          	at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:119)
          	at hudson.remoting.LocalChannel.call(LocalChannel.java:45)
          	at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:116)
          	at hudson.model.Hudson.doScript(Hudson.java:3257)
          	at hudson.model.Hudson.doScript(Hudson.java:3240)
          	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          	at java.lang.reflect.Method.invoke(Method.java:597)
          	at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282)
          	at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149)
          	at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:88)
          	at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:103)
          	at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
          	at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:561)
          	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:646)
          	at org.kohsuke.stapler.Stapler.invoke(Stapler.java:477)
          	at org.kohsuke.stapler.Stapler.service(Stapler.java:159)
          	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          	at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:94)
          	at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:86)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          	at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
          	at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
          	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          	at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
          	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          	at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
          	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          	at hudson.security.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:111)
          	at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
          	at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
          	at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          	at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
          	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
          	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
          	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470)
          	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
          	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
          	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
          	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
          	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
          	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
          	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
          	at java.lang.Thread.run(Thread.java:619)
          

          zlosch added a comment - - edited The script throws an error on the above Jenkins instance: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedList.keySet() is applicable for argument types: () values: [] at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54) at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:48) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120) at Script1.run(Script1.groovy:2) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:561) at groovy.lang.GroovyShell.evaluate(GroovyShell.java:536) at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:141) at hudson.util.RemotingDiagnostics$Script.call(RemotingDiagnostics.java:119) at hudson.remoting.LocalChannel.call(LocalChannel.java:45) at hudson.util.RemotingDiagnostics.executeGroovy(RemotingDiagnostics.java:116) at hudson.model.Hudson.doScript(Hudson.java:3257) at hudson.model.Hudson.doScript(Hudson.java:3240) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:88) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:103) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:561) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:646) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:477) at org.kohsuke.stapler.Stapler.service(Stapler.java:159) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:94) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:86) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:111) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:470) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:619)

          rsandell added a comment -

          Oh, sorry about that. The script is written for the snapshot version that we are running.
          We changed some internal structures to try and fix this problem, but haven't yet.

          But now I know that the bug is not because of those changes, because you are running an earlier version than we do.

          rsandell added a comment - Oh, sorry about that. The script is written for the snapshot version that we are running. We changed some internal structures to try and fix this problem, but haven't yet. But now I know that the bug is not because of those changes, because you are running an earlier version than we do.

          Matthias Sohn added a comment -

          Could you shed some light on what these multiple builds for the same project and gerrit event are good for and how to configure this ?

          We also observed that the data Gerrit Trigger reports as Gerrit review comments for these duplicate builds seems to be mixed up wrt to the build numbers,
          so Hudson says job #23 SUCCEEDED and job #24 FAILED but Gerrit Trigger reports the opposite result in Gerrit review comments (#23 FAILED and #24 SUCCEEDED).
          These results are reported in pairs in the same review comment.

          Matthias Sohn added a comment - Could you shed some light on what these multiple builds for the same project and gerrit event are good for and how to configure this ? We also observed that the data Gerrit Trigger reports as Gerrit review comments for these duplicate builds seems to be mixed up wrt to the build numbers, so Hudson says job #23 SUCCEEDED and job #24 FAILED but Gerrit Trigger reports the opposite result in Gerrit review comments (#23 FAILED and #24 SUCCEEDED). These results are reported in pairs in the same review comment.

          Small script to iterate through the listeners (for the next time it happens).

          Glenn J. Mason added a comment - Small script to iterate through the listeners (for the next time it happens).
          Glenn J. Mason made changes -
          Attachment New: List_Gerrit_Trigger_Listeners.groovy [ 20885 ]

          rsandell added a comment -

          A couple of different fixes around this area has been done up to (including) version 2.6.0
          Can you see if those fixes has resolved this one as well?

          rsandell added a comment - A couple of different fixes around this area has been done up to (including) version 2.6.0 Can you see if those fixes has resolved this one as well?

            rsandell rsandell
            edwin_kempin Edwin Kempin
            Votes:
            23 Vote for this issue
            Watchers:
            37 Start watching this issue

              Created:
              Updated:
              Resolved: