Commit 5cb6800c authored by Kerri Miller's avatar Kerri Miller

Explicitly call #to_a to avoid potential GC bug

We've seen a small number of seg faults that look to be coming from this
method. One candidate for cause is a known issue in Ruby's GC with
flat_map (https://bugs.ruby-lang.org/issues/18140) because the
concatenated array can be GC'd prematurely. By calling #to_a explicitly,
we insert it into the Ruby stack so that GC can recognize it and keep it
around.

There is a fix and backport for this in Ruby, but it may be a while
before they're released.

h/t to @stanhu for identifying this as a possible root cause and
supplying a solution.
parent 1cadf027
......@@ -212,7 +212,7 @@ module Gitlab
)
response = GitalyClient.call(@repository.storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout)
response.flat_map(&:stats)
response.flat_map { |rsp| rsp.stats.to_a }
end
def find_changed_paths(commits)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment