Skip to content

Commit

Permalink
Run FD stress test in separate process (#35040)
Browse files Browse the repository at this point in the history
As noted in #35011, the `stress` test is likely causing ENOMEM
errors in unrelated processes on FreeBSD as it's causing kernel
resource exhaustion. This fixes that by running that test with
a low FD ulimit (100). Should fix #23143. Closes #30511.
  • Loading branch information
Keno authored Mar 8, 2020
1 parent 4d745aa commit e13d06f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
24 changes: 3 additions & 21 deletions test/stress.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,9 @@

# test for proper handling of FD exhaustion
if Sys.isunix()
let ps = Pipe[]
ulimit_n = tryparse(Int, readchomp(`sh -c 'ulimit -n'`))
try
for i = 1:100*something(ulimit_n, 1000)
p = Pipe()
Base.link_pipe!(p)
push!(ps, p)
end
if ulimit_n === nothing
@warn "`ulimit -n` is set to unlimited, fd exhaustion cannot be tested"
@test_broken false
else
@test false
end
catch ex
isa(ex, Base.IOError) || rethrow()
@test ex.code in (Base.UV_EMFILE, Base.UV_ENFILE)
finally
foreach(close, ps)
end
end
# Run this test with a really small ulimit. If the ulimit is too high,
# we might saturate kernel resources (See #23143)
run(`sh -c "ulimit -n 100; $(Base.shell_escape(Base.julia_cmd())) --startup-file=no $(joinpath(@__DIR__, "stress_fd_exec.jl"))"`)
end

# issue 13559
Expand Down
22 changes: 22 additions & 0 deletions test/stress_fd_exec.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Test
let ps = Pipe[]
ulimit_n = tryparse(Int, readchomp(`sh -c 'ulimit -n'`))
try
for i = 1:100*something(ulimit_n, 1000)
p = Pipe()
Base.link_pipe!(p)
push!(ps, p)
end
if ulimit_n === nothing
@warn "`ulimit -n` is set to unlimited, fd exhaustion cannot be tested"
@test_broken false
else
@test false
end
catch ex
isa(ex, Base.IOError) || rethrow()
@test ex.code in (Base.UV_EMFILE, Base.UV_ENFILE)
finally
foreach(close, ps)
end
end

0 comments on commit e13d06f

Please sign in to comment.