Commit c5546d9c authored by Stan Hu's avatar Stan Hu

Fix formatting of restore from backup text

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40911, we added
a confirmation step if psql encountered any errors. However, the threads
used to read stdout/stderr were not joined, so it was likely that the
stdout spew from psql would continue to spew before the process was
actually complete. As done in Popen3#capture3, this change waits for
those stdout/stderr threads to finish before proceeding.
parent 85c3aeff
......@@ -70,9 +70,9 @@ module Backup
success = $?.success? && status.success?
if errors.present?
progress.print "------ BEGIN ERRORS -----".color(:yellow)
progress.print "------ BEGIN ERRORS -----\n".color(:yellow)
progress.print errors.join.color(:yellow)
progress.print "------ END ERRORS -------".color(:yellow)
progress.print "------ END ERRORS -------\n".color(:yellow)
end
report_success(success)
......@@ -89,12 +89,12 @@ module Backup
Open3.popen3(ENV, *cmd) do |stdin, stdout, stderr, thread|
stdin.binmode
Thread.new do
out_reader = Thread.new do
data = stdout.read
$stdout.write(data)
end
Thread.new do
err_reader = Thread.new do
until (raw_line = stderr.gets).nil?
warn(raw_line)
# Recent database dumps will use --if-exists with pg_dump
......@@ -108,8 +108,7 @@ module Backup
end
stdin.close
thread.join
[thread, out_reader, err_reader].each(&:join)
[thread.value, errors]
end
end
......
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