6

I intermittently get the following error when using Rscript to call mclapply from the command-line:

Error in sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE)) : 
  write error, closing pipe to the master

If I run the exact same code in R Studio or from an interactive R session, I don't get the error. This error pops up in a variety of contexts from very large jobs where each worker has to return a very large object to small jobs. I've also tried turning prescheduling off but it still throws the error. Sometimes it will go away if I reduce the number of threads in the mc.cores argument. I am using Microsoft R Open on Ubuntu 18.04.1. It also popped up on Ubuntu 16.04. One thing I haven't tried is running the code in standard R instead of MRO.

Here's my Rscript -e 'sessionInfo()':

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRblas.so
LAPACK: /opt/microsoft/ropen/3.5.1/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] RevoUtils_11.0.1     RevoUtilsMath_11.0.0

loaded via a namespace (and not attached):
[1] compiler_3.5.1

Any ideas? Has anyone else encountered something like this? I apologize for not having a reproducible example but the data/code where I've encountered the error so far is impractically large to share, and I have not been able to reproduce the error in other contexts. It seems to just occur randomly.

louiszya
  • 61
  • 3
  • 1
    Hi louiszya, could you please produce a minimal piece of code which exhibits this problem? As it stands it’s not reproducible for others (meaning: this *definitely* doesn’t happen with every code using `mclapply`, it requires very specific circumstances). Well done on posting your R configuration though (but don’t run it in a clean session, run it in the problematic session to show what other packages are attached)! – Konrad Rudolph Aug 23 '18 at 13:45
  • It could be that the data sent back to the master processes from the forked, child processes is too big. For troubleshooting, try adding `trace(parallel:::sendMaster, at = 3L, tracer = quote({ str(list(what = what)) }))` at the top of your script, and rerun. That should give us an idea of the size of the data is that cause that error. – HenrikB Aug 23 '18 at 20:14
  • @HenrikB, I also run into this issue. It got significantly worse when I increased the size of the return object. However, the docs claim that _Prior to R 3.4.0 and on a 32-bit platform, the serialized result from each forked process is limited to 2^31 - 1 bytes_. This feels like enough. R 3.5.1, debian sid. – Ott Toomet Nov 13 '18 at 03:37

1 Answers1

0

Try upgrading to R v3.6.0 or later.

I was facing the same issue, which was caused by a bug (use of uninitialized variable) in the parallel package as discussed in detail here: https://r.789695.n4.nabble.com/error-in-parallel-sendMaster-td4760382.html.

akersting
  • 1
  • 1