FIX: Sometimes not all output of psql was logged during restores

FIX: Sometimes not all output of psql was logged during restores

There was a race condition which could prevent Discourse from logging the last couple of lines of output from psql.

diff --git a/lib/backup_restore/database_restorer.rb b/lib/backup_restore/database_restorer.rb
index 9ccb6a5..40c1459 100644
--- a/lib/backup_restore/database_restorer.rb
+++ b/lib/backup_restore/database_restorer.rb
@@ -70,7 +70,7 @@ module BackupRestore
 
       log_thread = Thread.new do
         RailsMultisite::ConnectionManagement::establish_connection(db: @current_db)
-        while psql_running
+        while psql_running || !logs.empty?
           message = logs.pop.strip
           log(message) if message.present?
         end

GitHub sha: fc8e8427

1 Like