Git Polling isRevExcluded causes OutOfMemoryException

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      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

            Assignee:
            Brandon Jacklyn
            Reporter:
            Brandon Jacklyn
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: