futureverse / futureverse/future
ROBUSTNESS: Protect against user interrupts for calls that need to be atomic
- Dominant language
- R
- Stars
- 1k
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
# Background
In interactive R sessions, the user can signal user interrupts by hitting Ctrl-C in the terminal. If this happens while R evaluates a set of R expressions that must all complete or not, there is a risk of breaking the state of a future. In some cases, we can recover from it whereas in others the only solution is to restart R.
# Suggestion
In R (>= 3.5.0), we have `suspendInterrupts(expr)` which suspends user-interrupts with evaluating expression `expr`.
The first task is to identify places where they can safely protect against user interrupts without risking ending up in a situation where R completely blocks. We can always signal a SIGQUIT (Ctrl-\ in the terminal).
One obvious candidate is for cluster futures in main-worker communication. There should be no need to protect against user-interrupts on the worker's end.
Due to the risk of breaking something, we should probably introduce an R option `future.onInterrupts` and a corresponding environment variable `R_FUTURE_ONINTERRUPTS` to allow users/sysadmins to enable or disable this feature. To minimize the introduced overhead from checking these all the time, it's probably better to just do it when the package is loaded, i.e. during `.onLoad()`.
We could start off by enabling these user-interrupt protections only for interactive R sessions.
# See also
* https://github.com/HenrikBengtsson/parallelly/issues/29
Contributor guide
Assessment
This issue has not been assessed yet.