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

SaveableListener.onchange() called multiple times after a job config save

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • None
    • 1.642.3

      I just noticed in Jenkins 1.398, SaveableListener.onchange() is called 5 times (instead of only one) after a job configuration save.

      This can be easily demonstrated by using a plugin using, in debug mode, the SaveableListener extension point (for example, scm-sync-configuration plugin) and updating job configuration.

          [JENKINS-8953] SaveableListener.onchange() called multiple times after a job config save

          Daniel Beck added a comment -

          More information is needed to investigate this issue. The Job Config History plugin might help here.

          Chances are this is a side-effect of plugins saving their config with their own save() call.

          Daniel Beck added a comment - More information is needed to investigate this issue. The Job Config History plugin might help here. Chances are this is a side-effect of plugins saving their config with their own save() call.

          Marc Carter added a comment -

          This has always been the case. Jenkins v1.642.3 vanilla freestyle project saved. Here's the summary:

          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.model.AbstractItem.setDisplayName(AbstractItem.java:167)
              at hudson.model.Job.doConfigSubmit(Job.java:1208)
          
          WARNING: SaveableListenerLogger heard hudson.plugins.promoted_builds.PromotionProcess@20706ee8[test_project/promotion/promo1]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.plugins.promoted_builds.PromotionProcess.configure(PromotionProcess.java:130)
              at hudson.plugins.promoted_builds.JobPropertyImpl.<init>(JobPropertyImpl.java:110)
              at hudson.plugins.promoted_builds.JobPropertyImpl.<init>(JobPropertyImpl.java:51)
              at hudson.plugins.promoted_builds.JobPropertyImpl$DescriptorImpl.newInstance(JobPropertyImpl.java:375)
              at hudson.plugins.promoted_builds.JobPropertyImpl$DescriptorImpl.newInstance(JobPropertyImpl.java:351)
              at hudson.model.JobProperty.reconfigure(JobProperty.java:187)
              at hudson.model.JobProperty.reconfigure(JobProperty.java:79)
              at hudson.util.DescribableList.rebuild(DescribableList.java:175)
              at hudson.model.Job.doConfigSubmit(Job.java:1215)
          
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.model.AbstractProject.setScm(AbstractProject.java:1570)
              at hudson.model.AbstractProject.submit(AbstractProject.java:1871)
              at hudson.model.Project.submit(Project.java:230)
              at hudson.model.Job.doConfigSubmit(Job.java:1225)
          
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.util.PersistedList.onModified(PersistedList.java:173)
              at hudson.util.PersistedList.replaceBy(PersistedList.java:85)
              at hudson.model.AbstractProject.submit(AbstractProject.java:1875)
              at hudson.model.Project.submit(Project.java:230)
              at hudson.model.Job.doConfigSubmit(Job.java:1225)
              
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.util.PersistedList.onModified(PersistedList.java:173)
              at hudson.util.PersistedList.replaceBy(PersistedList.java:85)
              at hudson.util.DescribableList.rebuild(DescribableList.java:187)
              at hudson.model.Project.submit(Project.java:234)
              at hudson.model.Job.doConfigSubmit(Job.java:1225)
              
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.util.PersistedList.onModified(PersistedList.java:173)
              at hudson.util.PersistedList.replaceBy(PersistedList.java:85)
              at hudson.util.DescribableList.rebuildHetero(DescribableList.java:208)
              at hudson.model.Project.submit(Project.java:235)
              at hudson.model.Job.doConfigSubmit(Job.java:1225)
          
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.util.PersistedList.onModified(PersistedList.java:173)
              at hudson.util.PersistedList.replaceBy(PersistedList.java:85)
              at hudson.util.DescribableList.rebuildHetero(DescribableList.java:208)
              at hudson.model.Project.submit(Project.java:236)
              at hudson.model.Job.doConfigSubmit(Job.java:1225)
          
          WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.AbstractProject.save(AbstractProject.java:306)
              at hudson.model.Job.doConfigSubmit(Job.java:1227)
          
          WARNING: ItemListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]
              at hudson.model.listeners.ItemListener.fireOnUpdated(ItemListener.java:193)
              at hudson.model.Job.doConfigSubmit(Job.java:1228)
          

          Marc Carter added a comment - This has always been the case. Jenkins v1.642.3 vanilla freestyle project saved. Here's the summary: WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.model.AbstractItem.setDisplayName(AbstractItem.java:167)     at hudson.model.Job.doConfigSubmit(Job.java:1208) WARNING: SaveableListenerLogger heard hudson.plugins.promoted_builds.PromotionProcess@20706ee8[test_project/promotion/promo1]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.plugins.promoted_builds.PromotionProcess.configure(PromotionProcess.java:130)     at hudson.plugins.promoted_builds.JobPropertyImpl.<init>(JobPropertyImpl.java:110)     at hudson.plugins.promoted_builds.JobPropertyImpl.<init>(JobPropertyImpl.java:51)     at hudson.plugins.promoted_builds.JobPropertyImpl$DescriptorImpl.newInstance(JobPropertyImpl.java:375)     at hudson.plugins.promoted_builds.JobPropertyImpl$DescriptorImpl.newInstance(JobPropertyImpl.java:351)     at hudson.model.JobProperty.reconfigure(JobProperty.java:187)     at hudson.model.JobProperty.reconfigure(JobProperty.java:79)     at hudson.util.DescribableList.rebuild(DescribableList.java:175)     at hudson.model.Job.doConfigSubmit(Job.java:1215) WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.model.AbstractProject.setScm(AbstractProject.java:1570)     at hudson.model.AbstractProject.submit(AbstractProject.java:1871)     at hudson.model.Project.submit(Project.java:230)     at hudson.model.Job.doConfigSubmit(Job.java:1225) WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.util.PersistedList.onModified(PersistedList.java:173)     at hudson.util.PersistedList.replaceBy(PersistedList.java:85)     at hudson.model.AbstractProject.submit(AbstractProject.java:1875)     at hudson.model.Project.submit(Project.java:230)     at hudson.model.Job.doConfigSubmit(Job.java:1225)      WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.util.PersistedList.onModified(PersistedList.java:173)     at hudson.util.PersistedList.replaceBy(PersistedList.java:85)     at hudson.util.DescribableList.rebuild(DescribableList.java:187)     at hudson.model.Project.submit(Project.java:234)     at hudson.model.Job.doConfigSubmit(Job.java:1225)      WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.util.PersistedList.onModified(PersistedList.java:173)     at hudson.util.PersistedList.replaceBy(PersistedList.java:85)     at hudson.util.DescribableList.rebuildHetero(DescribableList.java:208)     at hudson.model.Project.submit(Project.java:235)     at hudson.model.Job.doConfigSubmit(Job.java:1225) WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.util.PersistedList.onModified(PersistedList.java:173)     at hudson.util.PersistedList.replaceBy(PersistedList.java:85)     at hudson.util.DescribableList.rebuildHetero(DescribableList.java:208)     at hudson.model.Project.submit(Project.java:236)     at hudson.model.Job.doConfigSubmit(Job.java:1225) WARNING: SaveableListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.AbstractProject.save(AbstractProject.java:306)     at hudson.model.Job.doConfigSubmit(Job.java:1227) WARNING: ItemListenerLogger heard hudson.model.FreeStyleProject@2d2a42e6[test_project]     at hudson.model.listeners.ItemListener.fireOnUpdated(ItemListener.java:193)     at hudson.model.Job.doConfigSubmit(Job.java:1228)

          Marc Carter added a comment -

          Attached "testcase" and full stack traces for 1.642.3

          Marc Carter added a comment - Attached "testcase" and full stack traces for 1.642.3

          Daniel Beck added a comment -

          As the stack traces indicate, it's different calls to save, each calling onChange once. It's a bit inefficient, but not wrong.

          Daniel Beck added a comment - As the stack traces indicate, it's different calls to save , each calling onChange once. It's a bit inefficient, but not wrong.

          Marc Carter added a comment -

          Not wrong but makes it unusable if, like me, you have an expensive operation to perform onChange. I'm facing option of checksumming the Item for actual changes or not using onChange and having individual plugins call an action on mine when they do make a real change.

          Marc Carter added a comment - Not wrong but makes it unusable if, like me, you have an expensive operation to perform onChange. I'm facing option of checksumming the Item for actual changes or not using onChange and having individual plugins call an action on mine when they do make a real change.

          Daniel Beck added a comment -

          Right, which is basically what the "deduplication" option of Job Config History does. I think oleg_nenashev worked on a batch saving change that would resolve this (AFAIUI), maybe he has an idea how to fix this easily.

          Daniel Beck added a comment - Right, which is basically what the "deduplication" option of Job Config History does. I think oleg_nenashev worked on a batch saving change that would resolve this (AFAIUI), maybe he has an idea how to fix this easily.

          Oleg Nenashev added a comment -

          drekbour danielbeck Hi, I have fixed the sequential calls of save() operation in Jenkins 2.37 (JENKINS-40435), then the fix has been backported to 2.32.2.

          From what I see this fix does exactly what has been requested in this ticket. drekbour please correct me if I am wrong.

          Oleg Nenashev added a comment - drekbour danielbeck Hi, I have fixed the sequential calls of save() operation in Jenkins 2.37 ( JENKINS-40435 ), then the fix has been backported to 2.32.2. From what I see this fix does exactly what has been requested in this ticket. drekbour please correct me if I am wrong.

          Marc Carter added a comment -

          Tested and confirmed in 2.32.2, thanks!

          Marc Carter added a comment - Tested and confirmed in 2.32.2, thanks!

            Unassigned Unassigned
            fcamblor Frédéric Camblor
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: