Make the test that seems to be getting stuck noisier
I assume it's upset because of the change in d314646c96
,
but I don't yet understand why.
This commit is contained in:
parent
c2f4a200e2
commit
87f5e5e28a
|
@ -455,8 +455,9 @@ module ActiveRecord
|
|||
with_single_connection_pool do |pool|
|
||||
[:disconnect, :disconnect!, :clear_reloadable_connections, :clear_reloadable_connections!].each do |group_action_method|
|
||||
conn = pool.connection # drain the only available connection
|
||||
second_thread_done = Concurrent::CountDownLatch.new
|
||||
second_thread_done = Concurrent::Event.new
|
||||
|
||||
begin
|
||||
# create a first_thread and let it get into the FIFO queue first
|
||||
first_thread = Thread.new do
|
||||
pool.with_connection { second_thread_done.wait }
|
||||
|
@ -470,7 +471,7 @@ module ActiveRecord
|
|||
# first_thread when a connection is made available
|
||||
second_thread = Thread.new do
|
||||
pool.send(group_action_method)
|
||||
second_thread_done.count_down
|
||||
second_thread_done.set
|
||||
end
|
||||
|
||||
# wait for second_thread to get in queue
|
||||
|
@ -482,16 +483,35 @@ module ActiveRecord
|
|||
# if the second_thread is not able to preempt the first_thread,
|
||||
# they will temporarily (until either of them timeouts with ConnectionTimeoutError)
|
||||
# deadlock and a join(2) timeout will be reached
|
||||
failed = true unless second_thread.join(2)
|
||||
assert second_thread.join(2), "#{group_action_method} is not able to preempt other waiting threads"
|
||||
|
||||
#--- post test clean up start
|
||||
second_thread_done.count_down if failed
|
||||
ensure
|
||||
# post test clean up
|
||||
failed = !second_thread_done.set?
|
||||
|
||||
first_thread.join
|
||||
second_thread.join
|
||||
#--- post test clean up end
|
||||
if failed
|
||||
second_thread_done.set
|
||||
|
||||
flunk "#{group_action_method} is not able to preempt other waiting threads" if failed
|
||||
puts
|
||||
puts ">>> test_disconnect_and_clear_reloadable_connections_are_able_to_preempt_other_waiting_threads / #{group_action_method}"
|
||||
p [first_thread, second_thread]
|
||||
p pool.stat
|
||||
p pool.connections.map(&:owner)
|
||||
|
||||
first_thread.join(2)
|
||||
second_thread.join(2)
|
||||
|
||||
puts '---'
|
||||
p [first_thread, second_thread]
|
||||
p pool.stat
|
||||
p pool.connections.map(&:owner)
|
||||
puts '<<<'
|
||||
puts
|
||||
end
|
||||
|
||||
first_thread.join(10) || raise("first_thread got stuck")
|
||||
second_thread.join(10) || raise("second_thread got stuck")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue