extra diagnostics for thread issues

This commit is contained in:
Sam 2018-06-20 09:19:16 +10:00
parent cbaf521fc1
commit 4d984a5a63
1 changed files with 13 additions and 3 deletions

View File

@ -61,7 +61,11 @@ describe Scheduler::Manager do
before do
expect(ActiveRecord::Base.connection_pool.connections.length).to eq(1)
@thread_count = Thread.list.count
@thread_ids = Thread.list.map { |t| t.object_id }
@backtraces = {}
Thread.list.each do |t|
@backtraces[t.object_id] = t.backtrace
end
end
after do
@ -81,11 +85,17 @@ describe Scheduler::Manager do
on_thread_mismatch = lambda do
current = Thread.list.map { |t| t.object_id }
extra = current - @thread_ids
missing = @thread_ids - current
old_threads = @backtraces.keys
extra = current - old_threads
missing = old_threads - current
if missing.length > 0
STDERR.puts "\nMissing Threads #{missing.length} thread/s"
missing.each do |id|
STDERR.puts @backtraces[id]
STDERR.puts
end
end
if extra.length > 0