Skip to content

Commit 4880ec6

Browse files
committed
Rewrite connection reaper test with timeout
1 parent 4cc1de7 commit 4880ec6

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

activerecord/test/cases/reaper_test.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,35 @@ def test_connection_pool_starts_reaper_in_fork
128128
pool = ConnectionPool.new(pool_config)
129129
pool.checkout
130130

131+
# We currently have a bug somewhere which leads for this test case to be deadlocked
132+
# and timeout after 30 minutes on the CI. Until that bug is fixed, this test is made
133+
# to timeout after a short period of time to reduce the damage.
134+
reader, writer = IO.pipe
135+
131136
pid = fork do
137+
reader.close
132138
pool = ConnectionPool.new(pool_config)
133139

134140
conn, child = new_conn_in_thread(pool)
135141
child.terminate
136142

137143
wait_for_conn_idle(conn)
144+
writer.close
138145
if conn.in_use?
139146
exit!(1)
140147
else
141148
exit!(0)
142149
end
143150
end
144151

145-
Process.waitpid(pid)
146-
assert_predicate $?, :success?
152+
writer.close
153+
completed = reader.wait_readable(20)
154+
reader.close
155+
unless completed
156+
Process.kill("ABRT", pid)
157+
end
158+
_, status = Process.wait2(pid)
159+
assert_predicate status, :success?
147160
ensure
148161
pool.discard!
149162
end

0 commit comments

Comments
 (0)