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

Lock held too long on Folder while deleting

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      If you have a large folder and delete it, all jobs inside are first deleted. This could take a while (minutes?) if you have the Job Config History plugin installed, or generally if I/O is slow:

      "Handling POST /jenkins/job/.../doDelete ..." ...
         java.lang.Thread.State: RUNNABLE
              at java.io.UnixFileSystem.getBooleanAttributes0(Native Method)
              at java.io.UnixFileSystem.getBooleanAttributes(UnixFileSystem.java:242)
              at java.io.File.exists(File.java:819)
              at hudson.plugins.jobConfigHistory.HistoryFileFilter.accept(HistoryFileFilter.java:18)
              at java.io.File.listFiles(File.java:1291)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.getRevisions(FileHistoryDao.java:330)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.getRevisions(FileHistoryDao.java:320)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.getRevisions(FileHistoryDao.java:314)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.hasDuplicateHistory(FileHistoryDao.java:556)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.checkDuplicate(FileHistoryDao.java:578)
              at hudson.plugins.jobConfigHistory.FileHistoryDao.saveItem(FileHistoryDao.java:263)
              at hudson.plugins.jobConfigHistory.JobConfigHistorySaveableListener.onChange(JobConfigHistorySaveableListener.java:29)
              at hudson.model.listeners.SaveableListener.fireOnChange(SaveableListener.java:81)
              at hudson.model.Descriptor.save(Descriptor.java:763)
              - locked <0x0000000541f80148> (a javaposse.jobdsl.plugin.DescriptorImpl)
              at javaposse.jobdsl.plugin.DescriptorImpl.removeSeedReference(DescriptorImpl.java:106)
              at javaposse.jobdsl.plugin.DescriptorImpl.access$000(DescriptorImpl.java:25)
              at javaposse.jobdsl.plugin.DescriptorImpl$GeneratedJobMapItemListener.onDeleted(DescriptorImpl.java:114)
              at hudson.model.listeners.ItemListener$4.apply(ItemListener.java:205)
              at hudson.model.listeners.ItemListener$4.apply(ItemListener.java:203)
              at hudson.model.listeners.ItemListener.forAll(ItemListener.java:167)
              at hudson.model.listeners.ItemListener.fireOnDeleted(ItemListener.java:203)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.onDeleted(AbstractFolder.java:606)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.onDeleted(AbstractFolder.java:115)
              at hudson.model.AbstractItem.delete(AbstractItem.java:584)
              at hudson.model.Job.delete(Job.java:665)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x00000005477cbcd8> (a com.cloudbees.hudson.plugins.folder.Folder)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x00000005472fd180> (a com.cloudbees.hudson.plugins.folder.Folder)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x00000005472fb028> (a com.cloudbees.hudson.plugins.folder.Folder)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x00000005448201a8> (a com.cloudbees.hudson.plugins.folder.Folder)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x0000000544820210> (a com.cloudbees.hudson.plugins.folder.Folder)
              at com.cloudbees.hudson.plugins.folder.AbstractFolder.performDelete(AbstractFolder.java:623)
              at hudson.model.AbstractItem.delete(AbstractItem.java:582)
              - locked <0x0000000544820290> (a com.cloudbees.hudson.plugins.folder.Folder)
              at hudson.model.AbstractItem.doDoDelete(AbstractItem.java:543)
              at ...
      

      Note that the monitor is being held on the Folder while deleting its children. This means that view threads can hang during the process:

      "Handling GET /jenkins/job/.../ ... : ... View/index.jelly View/sidepanel.jelly AbstractFolder/tasks-bottom.jelly" ... BLOCKED on com.cloudbees.hudson.plugins.folder.Folder@... owned by "Handling POST /jenkins/job/.../doDelete ..." ...
      	at com.cloudbees.hudson.plugins.folder.Folder.getActions(Folder.java:161)
      	-  blocked on com.cloudbees.hudson.plugins.folder.Folder@4b4fc60a
      	at hudson.model.Actionable.getAllActions(Actionable.java:94)
      	at ...
      

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java
            http://jenkins-ci.org/commit/cloudbees-folder-plugin/7b132953106cab243334992ff527b4bd65b08e71
            Log:
            [FIXED JENKINS-34939] Hold the lock on this folder only while deleting itself, not its children.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java http://jenkins-ci.org/commit/cloudbees-folder-plugin/7b132953106cab243334992ff527b4bd65b08e71 Log: [FIXED JENKINS-34939] Hold the lock on this folder only while deleting itself, not its children.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/test/java/com/cloudbees/hudson/plugins/folder/FolderTest.java
            http://jenkins-ci.org/commit/cloudbees-folder-plugin/47ea285bf5f01bdf861eed5ff9a4acbd3a87a7ee
            Log:
            JENKINS-34939 Verifying deletion behavior in test, and reproducing deadlock variant.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/test/java/com/cloudbees/hudson/plugins/folder/FolderTest.java http://jenkins-ci.org/commit/cloudbees-folder-plugin/47ea285bf5f01bdf861eed5ff9a4acbd3a87a7ee Log: JENKINS-34939 Verifying deletion behavior in test, and reproducing deadlock variant.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java
            src/test/java/com/cloudbees/hudson/plugins/folder/FolderTest.java
            http://jenkins-ci.org/commit/cloudbees-folder-plugin/9987689fe62ad7f9e85c685adf1867efc9dff845
            Log:
            Merge pull request #63 from jglick/hang-JENKINS-34939

            JENKINS-34939 Hold the lock on this folder only while deleting itself, not its children

            Compare: https://github.com/jenkinsci/cloudbees-folder-plugin/compare/645d3c1f33d7...9987689fe62a

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/com/cloudbees/hudson/plugins/folder/AbstractFolder.java src/test/java/com/cloudbees/hudson/plugins/folder/FolderTest.java http://jenkins-ci.org/commit/cloudbees-folder-plugin/9987689fe62ad7f9e85c685adf1867efc9dff845 Log: Merge pull request #63 from jglick/hang- JENKINS-34939 JENKINS-34939 Hold the lock on this folder only while deleting itself, not its children Compare: https://github.com/jenkinsci/cloudbees-folder-plugin/compare/645d3c1f33d7...9987689fe62a

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                jglick Jesse Glick
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: