FIX: Perform topics bulk action in a background thread (#28061)

Performing a bulk action on many topics can exceed the 30 seconds timeout that Unicorn workers have which results in the request failing and the operation getting aborted. To get around this 30 seconds timeout, we can push the operation into a background thread using the rack `hijack` API.

Internal topic: t/133779.
This commit is contained in:
Osama Sayegh 2024-07-25 11:43:00 +03:00 committed by GitHub
parent 5a37fa3760
commit 596a93d2cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 2 deletions

View File

@ -1028,9 +1028,12 @@ class TopicsController < ApplicationController
.symbolize_keys
raise ActionController::ParameterMissing.new(:operation_type) if operation[:type].blank?
operator = TopicsBulkAction.new(current_user, topic_ids, operation, group: operation[:group])
changed_topic_ids = operator.perform!
render_json_dump topic_ids: changed_topic_ids
hijack(info: "topics bulk action #{operation[:type]}") do
changed_topic_ids = operator.perform!
render_json_dump topic_ids: changed_topic_ids
end
end
def private_message_reset_new