Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-14058

Git processes from merges that have timed out are not cleaned up

XMLWordPrintable

      Issue Summary

      This occurs for git versions 2.38.0+ where a change was introduced to `git merge` to always stash changes before conducting the merge: https://github.com/git/git/commit/034195ef927bcfc348a69672494f3781e8f5c093

      For repos that are very large and have many files (millions), it may take a long time to merge pull requests as now git has to record the current state of the working directory. E.g. for ~8million files `git stash` takes around 100s. 

      This issues occurs regardless of setting the property `plugin.bitbucket-git.trymerge.use-mergetree`

      Steps to Reproduce

      1. Have a large repo with millions of files
      2. Set `pullrequest.merge.timeout` to a value that's slightly more than the time it takes to run `git stash`
      3. Try merge a PR

      Expected Results

      git processes are cleaned up even when the merge itself times out

      Actual Results

      The following git processes are left behind, even on Bitbucket restart:

      USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
      atlbitb+ 17912  1.2  9.6 7740264 6260468 ?     S    04:05   1:19 /usr/libexec/git-core/git stash create
      atlbitb+ 18017  100  2.7 1804088 1759696 ?     R    04:06 106:03 /usr/libexec/git-core/git update-index --ignore-skip-worktree-entries -z --add --remove --stdin
      atlbitb+ 17869  0.3  0.0      0     0 ?        Z    04:05   0:20 [git] <defunct>

      Workaround

      Manually remove the leftover git processes, or downgrade git to pre 2.38

              Unassigned Unassigned
              ysun Yingran Sun
              Votes:
              6 Vote for this issue
              Watchers:
              13 Start watching this issue

                Created:
                Updated:
                Resolved: