]> Cypherpunks repositories - goredo.git/commitdiff
Fix possible NFS locking issue v2.6.4
authorSergey Matveev <stargrave@stargrave.org>
Sat, 4 Jan 2025 12:18:15 +0000 (15:18 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sat, 4 Jan 2025 12:37:50 +0000 (15:37 +0300)
Niklas Böhm reported and fixed:
I was using goredo on an NFS and noticed that I sometimes ran into issues
where my program would fail with the following error:

        run.go:234: interrupted system call /gpfs01/.../folders/.redo/1.zip.lock

After doing some digging, it seems like the problem is that calling
unix.FcntlFlock with F_SETLKW can be too slow over an NFS and will get
interrupted (see `man 2 flock`, Section on errors [1]).  Apparently there is
an automatic restart mechanism [2], but it's also unreliable, so I thought
it's better to handle it explicitly.

[1]: https://www.man7.org/linux/man-pages/man2/fcntl.2.html#ERRORS
[2]: https://unix.stackexchange.com/questions/509375/what-is-interrupted-system-call

doc/news.texi
run.go
usage.go

index 6fbd8133f85206c9eb7e5e240e38e1a74d560467..4a08a68ca346aa5c0a9ae313c394e6cda8a70128 100644 (file)
@@ -2,6 +2,15 @@
 @cindex news
 @unnumbered News
 
+@anchor{Release 2_6_4}
+@section Release 2.6.4
+@itemize
+@item
+    Fix possible NFS locking issue.
+@item
+    Updated dependant libraries.
+@end itemize
+
 @anchor{Release 2_6_3}
 @section Release 2.6.3
 @itemize
diff --git a/run.go b/run.go
index 506fd359ecad7ea7d677c9a35c4c0776980b4629..5423b49bb335fdd89594604428ba21171d238f52 100644 (file)
--- a/run.go
+++ b/run.go
@@ -227,7 +227,7 @@ func runScript(tgt *Tgt, errs chan error, forced, traced bool) error {
                        tracef(CLock, "LOCK_EX: %s", fdLock.Name())
                LockAgain:
                        if err = unix.FcntlFlock(fdLock.Fd(), unix.F_SETLKW, &flock); err != nil {
-                               if errors.Is(err, unix.EDEADLK) {
+                               if errors.Is(err, unix.EDEADLK) || errors.Is(err, unix.EINTR) {
                                        time.Sleep(10 * time.Millisecond)
                                        goto LockAgain
                                }
index dc08f2505eccd7fb575ea9dadb5c224ce3b5cc5a..67ae2e708c1738629b29dd3248b15c9410a3101c 100644 (file)
--- a/usage.go
+++ b/usage.go
@@ -22,7 +22,7 @@ import (
 )
 
 const (
-       Version  = "2.6.3"
+       Version  = "2.6.4"
        Warranty = `Copyright (C) 2020-2025 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify