mirror of
https://github.com/discourse/discourse.git
synced 2025-02-21 19:55:43 +00:00
DEV: No need to pause Sidekiq during backups.
This was done for historical reasons where we stop all writes going to the DB during a backup by setting the database to readonly mode.
This commit is contained in:
parent
162958380a
commit
c7f1777ac9
@ -33,14 +33,7 @@ module BackupRestore
|
|||||||
ensure_directory_exists(@archive_directory)
|
ensure_directory_exists(@archive_directory)
|
||||||
|
|
||||||
update_metadata
|
update_metadata
|
||||||
|
dump_public_schema
|
||||||
begin
|
|
||||||
pause_sidekiq
|
|
||||||
wait_for_sidekiq
|
|
||||||
dump_public_schema
|
|
||||||
ensure
|
|
||||||
unpause_sidekiq
|
|
||||||
end
|
|
||||||
|
|
||||||
log "Finalizing backup..."
|
log "Finalizing backup..."
|
||||||
|
|
||||||
@ -127,32 +120,6 @@ module BackupRestore
|
|||||||
BackupMetadata.create!(name: "multisite", value: Rails.configuration.multisite)
|
BackupMetadata.create!(name: "multisite", value: Rails.configuration.multisite)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pause_sidekiq
|
|
||||||
log "Pausing sidekiq..."
|
|
||||||
Sidekiq.pause!
|
|
||||||
end
|
|
||||||
|
|
||||||
def wait_for_sidekiq
|
|
||||||
log "Waiting for sidekiq to finish running jobs..."
|
|
||||||
iterations = 1
|
|
||||||
while sidekiq_has_running_jobs?
|
|
||||||
log "Waiting for sidekiq to finish running jobs... ##{iterations}"
|
|
||||||
sleep 5
|
|
||||||
iterations += 1
|
|
||||||
raise "Sidekiq did not finish running all the jobs in the allowed time!" if iterations > 6
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def sidekiq_has_running_jobs?
|
|
||||||
Sidekiq::Workers.new.each do |_, _, worker|
|
|
||||||
payload = worker.try(:payload)
|
|
||||||
return true if payload.try(:all_sites)
|
|
||||||
return true if payload.try(:current_site_id) == @current_db
|
|
||||||
end
|
|
||||||
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
def dump_public_schema
|
def dump_public_schema
|
||||||
log "Dumping the public schema of the database..."
|
log "Dumping the public schema of the database..."
|
||||||
|
|
||||||
@ -403,14 +370,6 @@ module BackupRestore
|
|||||||
log "Something went wrong while removing the following tmp directory: #{@tmp_directory}", ex
|
log "Something went wrong while removing the following tmp directory: #{@tmp_directory}", ex
|
||||||
end
|
end
|
||||||
|
|
||||||
def unpause_sidekiq
|
|
||||||
return unless Sidekiq.paused?
|
|
||||||
log "Unpausing sidekiq..."
|
|
||||||
Sidekiq.unpause!
|
|
||||||
rescue => ex
|
|
||||||
log "Something went wrong while unpausing Sidekiq.", ex
|
|
||||||
end
|
|
||||||
|
|
||||||
def mark_backup_as_not_running
|
def mark_backup_as_not_running
|
||||||
log "Marking backup as finished..."
|
log "Marking backup as finished..."
|
||||||
BackupRestore.mark_as_not_running!
|
BackupRestore.mark_as_not_running!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user