ListConflictFiles stalls Gitaly-Ruby when processing merge with large number of merge bases
The symptoms of this issue are identical to #2027 (closed), but the parameters that trigger the problem are different.
No binary or particularly large files were found in the MR. Total changes were ~200 files and ~20,000 lines changed.
The project being updated has a large number of forks, with changes are made to the forks and merged into the parent repo. Running merge_commits in a separate script outside of Gitaly took over two minutes to complete. For comparison, a git merge for the same commits takes 8 seconds.
Using gdb, we found that merge_annotated_commits was recursing into itself up to 28 times, which per @pks-t suggests a very large number of merge bases. Oddly, git merge-base --all only returned two commits.
See below for a backtrace:
Enabling the GIT_MERGE_NO_RECUSRIVE flag in libgit2 caused execution time for merge_commits to go from 154.47 seconds to 0.55 seconds.
For reference, here is the commit graph from Repository -> Graph for the parent / target project:
And here is the same for the fork / source project:
Here's the perf record output of the stuck process:
/cc @pks-t



