mlr-org / mlr-org/batchtools

ROBUSTNESS: Write RDS files atomically

Open
#317 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
184
Forks
53
Avg merge
7d 2h
Merged PRs (30d)
1

Description

Issue

When writing an RDS file, it might fail half way through, resulting in an incomplete, corrupt file. Similarly, if one process attempts to read a file that is currently being written by another process, the read might occur on an incomplete file.

Suggestion

Always write RDS file atomically. This can be achieved by writing to *.rds.tmp and then rename the file to *.rds after saveRDS() completes. This way the target *.rds is guaranteed to be complete.

By writing to *.rds.tmp instead of tempfile() guarantees that we write to the same drive, avoiding cross-drive moves and copies.

Patch

See PR #316 for a patch. I updated writeRDS() to write atomically and I've added wait = 300, which can optionally be set to wait = 0. The latter is used to replace two remaining saveRDS() uses.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the writeRDS() implementation and locate the two remaining saveRDS() uses mentioned in the issue. Review PR #316 to understand the proposed scope and check that all RDS writes avoid exposing incomplete target files; completion means the affected writes follow the issue’s atomicity requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.