- Defined in:
This middleware can be used to diagnose deadlocks in the autoload interlock.
To use it, insert it near the top of the middleware stack, using
config.middleware.insert_before ::Sendfile, ::DebugLocks
After restarting the application and re-triggering the deadlock condition, the route
/rails/locks will show a summary of all threads currently known to the interlock, which lock level they are holding or awaiting, and their current backtrace.
Generally a deadlock will be caused by the interlock conflicting with some other external lock or blocking I/O call. These cannot be automatically identified, but should be visible in the displayed backtraces.
NOTE: The formatting and content of this middleware’s output is intended for human consumption, and should be expected to change between releases.
This middleware exposes operational details of the server, with no access control. It should only be enabled when in use, and removed thereafter.
Instance Method Summary collapse
- #call(env) ⇒ Object
#initialize(app, path = "/rails/locks") ⇒ DebugLocks
A new instance of DebugLocks.
#initialize(app, path = "/rails/locks") ⇒
Returns a new instance of DebugLocks.
26 27 28 29
# File 'actionpack/lib/action_dispatch/middleware/debug_locks.rb', line 26 def initialize(app, path = "/rails/locks") @app = app @path = path end
Instance Method Details
31 32 33 34 35 36 37 38 39 40 41 42
# File 'actionpack/lib/action_dispatch/middleware/debug_locks.rb', line 31 def call(env) req = ::. env if req.get? path = req.path_info.chomp("/") if path == @path return render_details(req) end end @app.call(env) end