diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-02-23 13:25:12 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-02-24 09:29:34 -0500 |
commit | 4004f646cd7a99f86b2098587c256071a89a4dc7 (patch) | |
tree | 2dd8da33094ab8cbac7012473bfccd916ad2ae4f /libpod/container_internal.go | |
parent | 18dcb84d641f4e8ae7fa31fa446d9461e0c915ab (diff) | |
download | podman-4004f646cd7a99f86b2098587c256071a89a4dc7.tar.gz podman-4004f646cd7a99f86b2098587c256071a89a4dc7.tar.bz2 podman-4004f646cd7a99f86b2098587c256071a89a4dc7.zip |
Add basic deadlock detection for container start/remove
We can easily tell if we're going to deadlock by comparing lock
IDs before actually taking the lock. Add a few checks for this in
common places where deadlocks might occur.
This does not yet cover pod operations, where detection is more
difficult (and costly) due to the number of locks being involved
being higher than 2.
Also, add some error wrapping on the Podman side, so we can tell
people to use `system renumber` when it occurs.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 11f9721dc..ff43bfc8f 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1401,6 +1401,9 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string) return nil, errors.Wrapf(err, "error retrieving named volume %s for container %s", v.Name, c.ID()) } + if vol.config.LockID == c.config.LockID { + return nil, errors.Wrapf(define.ErrWillDeadlock, "container %s and volume %s share lock ID %d", c.ID(), vol.Name(), c.config.LockID) + } vol.lock.Lock() defer vol.lock.Unlock() if vol.needsMount() { |