DEV: Warn if distributed-mutexing in a request

This commit is contained in:
Jarek Radosz 2022-08-12 19:35:20 +02:00
parent 5afdf24292
commit ab0cefe54a
No known key found for this signature in database
GPG Key ID: 62D0FBAE5BF9B953
2 changed files with 6 additions and 0 deletions

View File

@ -29,6 +29,7 @@ class ApplicationController < ActionController::Base
end
end
before_action :set_thread_variable
before_action :rate_limit_crawlers
before_action :check_readonly_mode
before_action :handle_theme
@ -56,6 +57,10 @@ class ApplicationController < ActionController::Base
layout :set_layout
def set_thread_variable
Thread.current["_in_request"] = true
end
def has_escaped_fragment?
SiteSetting.enable_escaped_fragments? && params.key?("_escaped_fragment_")
end

View File

@ -48,6 +48,7 @@ class DistributedMutex
# NOTE wrapped in mutex to maintain its semantics
def synchronize
Rails.logger.warn("DistributedMutex.synchronize called inside a request lifecycle") if Thread.current["_in_request"]
result = nil
@mutex.synchronize do