Gitlab::Popen.popen is not thread-safe
Summary
Gitlab::Popen.popen is not thread-safe, this can affect Sidekiq workers that use this method. For example, I had three long-running imports that all failed on the account one of them failing, and they all got the same error message.
Steps to reproduce
Make a shell file (name it echo_then_sleep.sh
)
echo $1
sleep $2
and from a Rails console run this line
[Thread.new { Gitlab::Popen::popen(%w(./echo_then_sleep.sh Five 5)) }, Thread.new { Gitlab::Popen::popen(%w(./echo_then_sleep.sh One 1)) }].map(&:value)
Expected behavior
# => [["Five\n", 0], ["One\n", 0]]
Actual behavior
#=> [["One\nFive\n", 0], ["One\nFive\n", 0]]