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

Git Polling isRevExcluded causes OutOfMemoryException


    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • git-client-plugin
    • None
    • git-plugin 2.4.0
      git-client-plugin 1.19.0
      jenkins 1.609.3

      In our environment, during git polling (Git Polling Log) the following command causes an OutOfMemoryException attempting to read a 2GB+? String from a ByteArrayOutputStream (~1GB when I copied it from the heap dump to a .txt file).

      This is the offending command:

      /usr/bin/git log --full-history --no-abbrev --format=raw -M -m --raw <previous_build_sha1>..<polling_sha1> # timeout=10 

      The actual error in the build log is:

      ERROR: Connection was broken: java.io.IOException: Unexpected reader termination
      at hudson.remoting.SynchronousCommandTransport$ReaderThread.run(SynchronousCommandTransport.java:76)
      Caused by: java.lang.OutOfMemoryError: Requested array size exceeds VM limit

      This is due to the two commits being 1000's of commits/1000's of files different. When this error occurs the JVM ends up in such a bad state that the ssh-slaves-plugin is unable to relaunch the slaves, and all our machines go offline when this happens on a machine.

      Details: GitSCM.isRevExcluded() calls CliGitAPIImpl.showRevision() which calls the "git log -full-history .." command. Only 3 extensions implement isRevExcluded(): PathRestriction.class, MessageExclusion.class, and UserExclusion.class. These extensions require commit files, commit message, and commit author respectively. Since the vast majority of the size of the ByteArray is from the commit file info, my proposal is to remove the "--raw" if the PathRestriction extension is not being used by the job:

      /usr/bin/git log --full-history --no-abbrev --format=raw -M -m <previous_build_sha1>..<polling_sha1> # timeout=10

            bjacklyn Brandon Jacklyn
            bjacklyn Brandon Jacklyn
            0 Vote for this issue
            4 Start watching this issue