mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
faf5b4d3e9
Incorporates learnings from /t/64227: * Changes the code to set access control posts in the rake task to be an efficient UPDATE SQL query. The original version was timing out with 312017 post uploads, the new query took ~3s to run. * Changes the code to mark uploads as secure/not secure in the rake task to be an efficient UPDATE SQL query rather than using UploadSecurity. This took a very long time previously, and now takes only a few seconds. * Spread out ACL syncing for uploads into jobs with batches of 100 uploads at a time, so they can be parallelized instead of having to wait ~1.25 seconds for each ACL to be changed in S3 serially. One issue that still remains is post rebaking. Doing this serially is painfully slow. We have a way to do this in sidekiq via PeriodicalUpdates but this is limited by max_old_rebakes_per_15_minutes. It would be better to fan this rebaking out into jobs like we did for the ACL sync, but that should be done in another PR.
38 lines
924 B
Ruby
38 lines
924 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe Jobs::SyncAclsForUploads do
|
|
let(:upload1) { Fabricate(:upload) }
|
|
let(:upload2) { Fabricate(:upload) }
|
|
let(:upload3) { Fabricate(:secure_upload) }
|
|
let(:upload_ids) { [upload1.id, upload2.id, upload3.id] }
|
|
|
|
def run_job
|
|
described_class.new.execute(upload_ids: upload_ids)
|
|
end
|
|
|
|
it "does nothing if not using external storage" do
|
|
Upload.expects(:where).never
|
|
run_job
|
|
end
|
|
|
|
context "external storage enabled" do
|
|
before do
|
|
setup_s3
|
|
stub_s3_store
|
|
end
|
|
|
|
it "runs update_upload_ACL for each upload" do
|
|
Discourse.store.expects(:update_upload_ACL).times(3)
|
|
run_job
|
|
end
|
|
|
|
it "handles updates throwing an exception" do
|
|
Discourse.store.expects(:update_upload_ACL).raises(StandardError).then.returns(true, true).times(3)
|
|
Discourse.expects(:warn_exception).once
|
|
run_job
|
|
end
|
|
end
|
|
end
|