Can a snakemake job mistakenly run twice at the same time?

Viewed 100

When running Snakemake on a cluster, jobs get scheduled fine via slurm. Sometimes I have a case that one job is failing and consequently leads to a stop of the snakemake instance/run after completion of the still running jobs. To speed up this I have stopped snakemake (CTRl+C) and restarted it. What I did not thought of was that in this case some jobs from the previous run might still be running on the cluster. Hence it could potentially happen that the same job is started again in case no output has been written until then. In this case it could finally lead to the situation where 2 jobs write to the same output file. Or is that prevented by some other log of snakemake to care about successful completion? I hope you can follow this explanation. Happy for every comment !

1 Answers

In this case it could finally lead to the situation where 2 jobs write to the same output file.

Snakemake should be aware that the previous execution didn't exit clean (because of Ctrl+C) and the jobs that were running at that moment are incomplete or absent. However, snakemake cannot know that those pending jobs are still running as independent processes.

So yes, I think it can happen that jobs steps on each other feet in what you are doing.

In my opinion, before re-running snakemake it would be safer to kill the pending jobs and start fresh. (Those that have completed before snakemake was killed are ok of course).

Note that there is an option in snakemake that may help you:

  --keep-going, -k      Go on with independent jobs if a job fails. (default:
                        False)
Related