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

AbstractLazyLoadRunMap.getById subject to race condition with .load

    Details

    • Similar Issues:

      Description

      If Run.onLoad takes a little while to run, or generally if RunMap.retrieve is not instantaneous, a race condition can arise. Say thread 1 calls getByNumber for a Run which in fact exists on disk (with a numeric symlink). search will call load(int, null), which will delegate to load(File, null) which acquires the lock; and then blocks for a while in retrieve. Then thread 2 calls getById with the ID of the same build. index.byId is still empty, so it jumps to load(String, null) and then blocks waiting to enter load(File, null). Now thread 1 finishes retrieve, stores the newly loaded Run in the index, and returns. When the lock is released, thread 2 enters it, loads another copy of the same Run, and stores it in the index, clobbering the first entry, and returns that.

      Seems to be fixable by making getById double-check the index while holding the lock, forcing it to wait for the first thread to store an entry. (Or could just check under lock whether snapshot != index, and if so, retry.)

      Also load(File, null) should assert that there is no current entry for a build before it stores one.

        Attachments

          Issue Links

            Activity

            jglick Jesse Glick created issue -
            jglick Jesse Glick made changes -
            Field Original Value New Value
            Link This issue is related to JENKINS-24380 [ JENKINS-24380 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-27532 [ JENKINS-27532 ]
            jglick Jesse Glick made changes -
            Resolution Duplicate [ 3 ]
            Status Resolved [ 5 ] Reopened [ 4 ]
            jglick Jesse Glick made changes -
            Status Reopened [ 4 ] Open [ 1 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            jglick Jesse Glick made changes -
            Remote Link This issue links to "PR 1989 (Web Link)" [ 13757 ]
            jglick Jesse Glick made changes -
            Labels lazy-loading threads lazy-loading lts-candidate threads
            scm_issue_link SCM/JIRA link daemon made changes -
            Status In Progress [ 3 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            jglick Jesse Glick made changes -
            Link This issue is related to JENKINS-26761 [ JENKINS-26761 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-32755 [ JENKINS-32755 ]
            olivergondza Oliver Gondža made changes -
            Labels lazy-loading lts-candidate threads 1.642.3-fixed lazy-loading threads
            olivergondza Oliver Gondža made changes -
            Link This issue depends on JENKINS-33219 [ JENKINS-33219 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 154881 ] JNJira + In-Review [ 195067 ]
            jglick Jesse Glick made changes -
            Link This issue relates to JENKINS-37121 [ JENKINS-37121 ]
            jglick Jesse Glick made changes -
            Link This issue is duplicated by JENKINS-38509 [ JENKINS-38509 ]

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: