From 1422b7b43a132c786d17935aa4f78620bea5ad87 Mon Sep 17 00:00:00 2001 From: Ole Tange Date: Wed, 25 Apr 2018 22:38:42 +0200 Subject: [PATCH] parallel: Fixed bug #53748: -k --retries 10 + out of filehandles = blocking. --- src/parallel | 13 ++++++++++++- testsuite/tests-to-run/parallel-local-10s.sh | 7 +++++++ testsuite/wanted-results/parallel-local-10s | 9 +++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/parallel b/src/parallel index c45b6d4d..49297417 100755 --- a/src/parallel +++ b/src/parallel @@ -2729,6 +2729,7 @@ sub init_run_jobs { $no_more_file_handles_warned++ or ::warning("No more file handles. ", "Raising ulimit -n or /etc/security/limits.conf may help."); + debug("start", "No more file handles. "); return 0; } } @@ -3973,7 +3974,9 @@ sub reaper { } my $sshlogin = $job->sshlogin(); $sshlogin->dec_jobs_running(); - if(not $job->should_be_retried()) { + if($job->should_be_retried()) { + $job->free_ressources(); + } else { # The job is done $sshlogin->inc_jobs_completed(); # Free the jobslot @@ -9126,6 +9129,14 @@ sub print_tag { return print_normal(@_); } +sub free_ressources() { + my $self = shift; + for my $fdno (sort { $a <=> $b } keys %Global::fd) { + close $self->fh($fdno,"w"); + close $self->fh($fdno,"r"); + } +} + sub print_normal { my $self = shift; my ($fdno,$in_fh,$out_fd) = @_; diff --git a/testsuite/tests-to-run/parallel-local-10s.sh b/testsuite/tests-to-run/parallel-local-10s.sh index 65b7bb2e..d6d3d0fd 100644 --- a/testsuite/tests-to-run/parallel-local-10s.sh +++ b/testsuite/tests-to-run/parallel-local-10s.sh @@ -299,6 +299,13 @@ par_linebuffer_tag_slow_output() { parallel --delay 1 -j0 --tag --line-buffer halfline ::: a b } +par_retries_all_fail() { + echo "bug #53748: -k --retries 10 + out of filehandles = blocking" + ulimit -n 30 + seq 8 | + parallel -k -j0 --retries 2 --timeout 0.1 'echo {}; sleep {}; false' 2>/dev/null +} + export -f $(compgen -A function | grep par_) compgen -A function | grep par_ | sort | parallel --joblog /tmp/jl-`basename $0` -j10 --tag -k '{} 2>&1' diff --git a/testsuite/wanted-results/parallel-local-10s b/testsuite/wanted-results/parallel-local-10s index 5ccee16a..77f6e43f 100644 --- a/testsuite/wanted-results/parallel-local-10s +++ b/testsuite/wanted-results/parallel-local-10s @@ -506,6 +506,15 @@ par_results_csv 8,:,999.999,999.999,0,6,0,0,"echo 23 11",23,11,"23 11 par_results_csv ", par_results_csv 9,:,999.999,999.999,0,6,0,0,"echo 23 12",23,12,"23 12 par_results_csv ", +par_retries_all_fail bug #53748: -k --retries 10 + out of filehandles = blocking +par_retries_all_fail 1 +par_retries_all_fail 2 +par_retries_all_fail 3 +par_retries_all_fail 4 +par_retries_all_fail 5 +par_retries_all_fail 6 +par_retries_all_fail 7 +par_retries_all_fail 8 par_round_robin_blocks bug #49664: --round-robin does not complete par_round_robin_blocks 8 par_slow_total_jobs bug #51006: Slow total_jobs() eats job