Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 31 additions & 64 deletions docs/locks.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,34 @@
# Locks

!!! warning
This page will soon replace <https://docs.easybuild.io/en/latest/Locks.html>.

**
It still needs to be ported from *reStructuredText* (.rst) to *MarkDown* (.md),
and you can help with that!
**

- source: [`docs/Locks.rst` in `easybuilders/easybuild` repo](https://raw.githubusercontent.com/easybuilders/easybuild/develop/docs/Locks.rst)
- target: [`docs/locks.md` in `easybuilders/easybuild-docs` repo](https://github.com/easybuilders/easybuild-docs/tree/main/docs/locks.md)

See <https://github.com/easybuilders/easybuild-docs> for more information.

```rst
.. _locks:

Locks to prevent duplicate installations running at the same time
=================================================================
## Locks to prevent duplicate installations running at the same time {: #locks }

Easybuild creates a lock before starting the installation of an easyconfig file,
to avoid a collision between multiple installations running at the same time.

If an EasyBuild session tries to install an easyconfig file when a lock for that installation already exists,
it will be automatically aborted with an error like "``Lock ... already exists, aborting!``".
it will be automatically aborted with an error like "`Lock ... already exists, aborting!`".

.. note:: Locking of installations was implemented in EasyBuild version 4.2.0 .
!!! note
Locking of installations was implemented in EasyBuild version 4.2.0 .


.. contents::
:depth: 3
:backlinks: none

.. _locks_implementation:

Locking implementation details
------------------------------
### Locking implementation details {: #locks_implementation }

Easybuild will create a lock when starting an installation if no corresponding lock exists yet,
regardless of whether the installation was requested explicitly or is performed to resolve a dependency.

The name of the lock corresponds to the *full* path of the installation directory, with slashes (``/``) and
dashes (``-``) replaced by underscores (``_``), and with an additional ``.lock`` added at the end.
The name of the lock corresponds to the *full* path of the installation directory, with slashes (`/`) and
dashes (`-`) replaced by underscores (`_`), and with an additional `.lock` added at the end.

Locks are created in the :ref:`locks_dir`.
Locks are created in the [locks directory][locks_dir].

The lock created by EasyBuild is an empty directory (rather than a file),
because that can be created more atomically on modern filesystems.

For example, if ``OpenFOAM-7-foss-2019b.eb`` is being installed to ``/apps/easybuild/software``,
For example, if `OpenFOAM-7-foss-2019b.eb` is being installed to `/apps/easybuild/software`,
an empty directory that serves as a lock for this installation will be created at
``/apps/easybuild/software/.locks/_apps_easybuild_software_OpenFOAM_7_foss_2019b.lock``
(assuming the default :ref:`locks_dir` is used).
`/apps/easybuild/software/.locks/_apps_easybuild_software_OpenFOAM_7_foss_2019b.lock`
(assuming the default [locks directory][locks_dir] is used).

A lock is automatically removed by Easybuild when the installation ends, regardless of whether the installation
was successful or not. Therefore, new installations of the same easyconfig will be aborted in case of:
Expand All @@ -60,61 +37,51 @@ was successful or not. Therefore, new installations of the same easyconfig will
* a previous installation of the same easyconfig was abruptly interrupted;


.. _locks_removing:

Removing locks
--------------
### Removing locks {: #locks_removing }

If a previous installation was abruptly interrupted and a lock was left in place,
it can be easily removed using the ``rmdir`` command (since the lock is actually an empty directory).
it can be easily removed using the `rmdir` command (since the lock is actually an empty directory).


.. _locks_configuration_options:

Configuration options related to installation locks
---------------------------------------------------
### Configuration options related to installation locks {: #locks_configuration_options }

The behaviour of the locking mechanism in Easybuild can be tuned with the following configuration options:

.. _locks_ignore:
#### Ignoring locks {: #locks_ignore }

Ignoring locks (``--ignore-locks``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*(`--ignore-locks`)*

Using the ``--ignore-locks`` configuration option, you can instruct EasyBuild to ignore any existing locks.
Using the `--ignore-locks` configuration option, you can instruct EasyBuild to ignore any existing locks.
Locks that exist are left untouched, even if the installation completes successfully.

**Use this with caution, since installations may be (partially) overwritten if another EasyBuild session is also
performing those installations!**


.. _locks_wait:
#### Waiting for locks to be removed {: #locks_wait }

Waiting for locks to be removed (``--wait-on-lock``)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*(`--wait-on-lock`)*

Using the ``--wait-on-lock`` configuration option, you can change how EasyBuild deals with existing locks,
by specifying how frequently EasyBuild should check whether an existing lock was removed. By specifying a non-zero value ``S``,
Using the `--wait-on-lock` configuration option, you can change how EasyBuild deals with existing locks,
by specifying how frequently EasyBuild should check whether an existing lock was removed. By specifying a non-zero value `S`,
you can indicate how many seconds EasyBuild should wait before checking again whether the lock is still in place.

.. note:: EasyBuild will wait indefinitely for an existing lock to be removed if ``--wait-on-lock`` is set to a non-zero value...
!!! note
EasyBuild will wait indefinitely for an existing lock to be removed if `--wait-on-lock` is set to a non-zero value...

If the lock is never removed, the EasyBuild session will never terminate; it will keep checking every ``S`` seconds whether the lock is still in place.
If the lock is never removed, the EasyBuild session will never terminate; it will keep checking every `S` seconds whether the lock is still in place.

By default, EasyBuild will *abort* the installation with an error like "``Lock ... already exists, aborting!``"
if a corresponding lock already exists, which is equivalent to setting ``--wait-on-lock`` to zero (``0``),
By default, EasyBuild will *abort* the installation with an error like "`Lock ... already exists, aborting!`"
if a corresponding lock already exists, which is equivalent to setting `--wait-on-lock` to zero (`0`),
implying that no waiting should be done at all.


.. _locks_dir:

Locks directory
---------------
### Locks directory {: #locks_dir }

If desired, an alternate location where locks should be created and checked for can be specified via the ``--locks-dir`` configuration option.
If desired, an alternate location where locks should be created and checked for can be specified via the `--locks-dir` configuration option.

.. note:: Keep in mind that a path on a *shared* filesystem should be used, to ensure that active EasyBuild sessions running on different systems use the same locks directory.
!!! note
Keep in mind that a path on a *shared* filesystem should be used, to ensure that active EasyBuild sessions running on different systems use the same locks directory.

By default, locks are created in a hidden subdirectory ``.locks`` in the top-level ``software`` installation directory; that is, the ``software`` subdirectory of the ``installpath`` configuration setting of the active EasyBuild session.
By default, locks are created in a hidden subdirectory `.locks` in the top-level `software` installation directory; that is, the `software` subdirectory of the `installpath` configuration setting of the active EasyBuild session.

```