20846: Avoid deadlock in unmount-and-replace race.
authorTom Clegg <tom@curii.com>
Fri, 10 Nov 2023 22:18:13 +0000 (17:18 -0500)
committerTom Clegg <tom@curii.com>
Sat, 11 Nov 2023 00:37:50 +0000 (19:37 -0500)
refs #20846

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

services/fuse/arvados_fuse/unmount.py

index 12d047a8f35d00fc682e846ba20bce466b93dd21..144c582ddce52017ad14f47e660a9584f086b84c 100644 (file)
@@ -154,6 +154,16 @@ def unmount(path, subtype=None, timeout=10, recursive=False):
             path = os.path.realpath(path)
             continue
         elif not mounted:
+            if was_mounted:
+                # This appears to avoid a race condition where we
+                # return control to the caller after running
+                # "fusermount -u -z" (see below), the caller (e.g.,
+                # arv-mount --replace) immediately tries to attach a
+                # new fuse mount at the same mount point, the
+                # lazy-unmount process unmounts that _new_ mount while
+                # it is being initialized, and the setup code waits
+                # forever for the new mount to be initialized.
+                time.sleep(1)
             return was_mounted
 
         if attempted: