You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionnot-our-bugUsed only when we want to keep an issue open for visibility, but the real problem is somewhere else
I'm upgrading the OpenBSD package to 1.4.2. All is well, but just occasionally (i.e. non-deterministically) I'm able to get kqueue-related test failures like this:
In the meantime, should this stop me from updating the package? Presumably nothing terrible will happen in the event that a kqueue fails?
Kqueue failing wouldn't be that bad, just means error in the UI and falling back to more frequent periodic scans. However panicking is another matter, that takes the entire program down.
Any ideas?
Please check if after increasing kern.maxfiles this doesn't come up anymore. If yes well have to see how to integrate this: Unfortunately go doesn't provide a way to set this value (golang/go#8757), but if there's a simple way to modify this without elevated privileges it would be worth baking it into Syncthing itself, pointers appreciated. Otherwise probably through some post-install script of your packaging.
The fatal error is from the net poller which is go internal and not involved in the fs watcher, although I guess bugs in one could theoretically affect the other.
This is reporting an EBADF returned by a call to kevent() where fd 13 is the file descriptor previously returned by kqueue(). This would most likely be caused by the program closing the file descriptor underneath the Go runtime:
package main
import (
"log"
"net/http"
"syscall"
)
func main() {
if _, err := http.Get("https://google.com/"); err != nil {
log.Fatal(err)
}
for i := 3; i < 100; i++ {
if err := syscall.Close(i); err == nil {
log.Printf("Closed fd %d\n", i)
}
}
if _, err := http.Get("https://google.com/"); err != nil {
log.Fatal(err)
}
}
Folks, if someone can tell me either: how run the tests without caching; or how to clean the sources, then I can run tests under ktrace to verify the above hypothesis.
This test is running with the race detector, yes? Only way I could see this being "our" fault is we had a race in the tests where we open/close stuff so that we close the wrong fd somehow.
Folks, I'm keen to get to the bottom of this. Are there any STLOG flags which could help to figure out what is going on here?
I'm going to try running syncthing-1.5.0 on one of my BSD boxes for a while and see if this comes up outside of tests. I may delve into code, but I have limited time to invest.
Supposing this did come up outside of tests, what are the consequences? Just that syncthing stops running, right? Is there any chance of data loss?
Crashes should not cause data loss. If you can provoke it outside of tests we can look at log flags then depending on what was happening when it crashed.
What I can say is that no user with crash reporting enabled (which is the default) has ever run into this issue, because there are zero hits on "netpoll" in our crash reporting system. (Plenty of other odd stuff though.)
Crashes should not cause data loss. If you can provoke it outside of tests we can look at log flags then depending on what was happening when it crashed.
OK. I may still try adding some prints in strategic locations to see if I can understand what's gone wrong.
What I can say is that no user with crash reporting enabled (which is the default) has ever run into this issue, because there are zero hits on "netpoll" in our crash reporting system. (Plenty of other odd stuff though.)
That's good to know, but also somewhat expected for OpenBSD users at least. Most OpenBSD users will install from our binary packages repo and we've not yet updated to the version with this problem :)
So I cloned the notify source code and ran the tests on OpenBSD:
arrakis:notify> go test -count=1
PASS
ok github.com/syncthing/notify 18.567s
arrakis:notify> go test -count=1
--- FAIL: TestWatcherKqueue (0.14s)
testing_test.go:215: testing_test.go:371: unlinkat /home/edd/source/notify/testdata/621182279/src/github.com/ppknap/link/include/coost/link: bad file descriptor
testing_test.go:219: testing_test.go:300: w.Watcher.Close()=Not all watches were removed: len(t.pthLkp) == 3
FAIL
exit status 1
FAIL github.com/syncthing/notify 17.977s
arrakis:notify> go test -count=1
runtime: kevent on fd 40 failed with 9
fatal error: runtime: netpoll failed
...
Oh, I'm not sure it has anything to do with the crash above. I read it sloppily and assumed you had reproduced the crash from the issue. Regardless, my comment is still mostly the same.
OK, so I've been running 1.5.0 for a few days on a production node and no kevent issues. I'm probably going to move forward with the package update.
I did spend some time reading the notify source code, but since I'm a total n00b at golang, I can't really follow. Really we'd need an interested go programmer to take a look and see what's going on.
Would you folks mind if I open a bug bounty for this? It's bothering me. Obviously, cash out of my own pocket (and probably not a huge amount. I'm hoping this'd be a easy fix for a seasoned go programmer) 😸
frozen-due-to-ageIssues closed and untouched for a long time, together with being locked for discussionnot-our-bugUsed only when we want to keep an issue open for visibility, but the real problem is somewhere else
Activity
vext01 commentedon May 3, 2020
I'm guessing the 9 here is an errno.
vext01 commentedon May 3, 2020
File descriptor limit is 7030 -- the maximum the kernel allows. Hopefully we are not out of descriptors...
imsodin commentedon May 3, 2020
While it's a bit surprising in tests, in practice it's very likely given kqueue is non-recursive, i.e. a descriptor is needed for every dir in the folder (and maybe even file, didn't check). It has been a problem previously and the limit can be increased: https://forum.syncthing.net/t/high-file-descriptor-usage-openbsd/13408
Kqueue failing wouldn't be that bad, just means error in the UI and falling back to more frequent periodic scans. However panicking is another matter, that takes the entire program down.
Please check if after increasing
kern.maxfilesthis doesn't come up anymore. If yes well have to see how to integrate this: Unfortunately go doesn't provide a way to set this value (golang/go#8757), but if there's a simple way to modify this without elevated privileges it would be worth baking it into Syncthing itself, pointers appreciated. Otherwise probably through some post-install script of your packaging.vext01 commentedon May 3, 2020
Ah yes, I forgot about
kern.maxfiles.Well, I upped the limit to 16000 and kqueue still occasionally fails. That should be more than enough, right?
imsodin commentedon May 3, 2020
For tests either 7k or 16k should be enough, so the issue you see here might be something else indeed, but if I wasn't mistaken in that thread it's definitely not enough in general (https://forum.syncthing.net/t/high-file-descriptor-usage-openbsd/13408/7):
16k dirs and files is not much.
What version of Go are you on?
calmh commentedon May 3, 2020
The fatal error is from the net poller which is go internal and not involved in the fs watcher, although I guess bugs in one could theoretically affect the other.
AudriusButkevicius commentedon May 3, 2020
Yet I think this should be a ticket with go, as the stacktrace does not even touch our code.
vext01 commentedon May 3, 2020
You mean I should try more?
go-1.13.9
EDIT: Sorry, github didn't update. So if this is a go issue, I'll get our go packager involved.
4a6f656c commentedon May 4, 2020
This is reporting an EBADF returned by a call to
kevent()where fd 13 is the file descriptor previously returned bykqueue(). This would most likely be caused by the program closing the file descriptor underneath the Go runtime:vext01 commentedon May 4, 2020
Folks, if someone can tell me either: how run the tests without caching; or how to clean the sources, then I can run tests under
ktraceto verify the above hypothesis.(Please excuse my near zero knowledge of golang).
imsodin commentedon May 4, 2020
To run tests regardless of caching, use
-counts=1.vext01 commentedon May 5, 2020
Thanks!
I added
-count=1to the test invocation inbuild.goand ran it in a loop until it crashed:Full stack trace
Using the ktrace output, I filtered on the crashing PID and eyeballed the result. Here's what I believe to be the crux of the problem:
And here's the unelided snippet of the trace (syscalls seem to be interleaved; presumably threads?):
So we are seeing some permission denied errors, which may or may not be related.
Hopefully the ST devs can glean some insight from this?
AudriusButkevicius commentedon May 5, 2020
This is just test failures, correct?
calmh commentedon May 5, 2020
This test is running with the race detector, yes? Only way I could see this being "our" fault is we had a race in the tests where we open/close stuff so that we close the wrong fd somehow.
vext01 commentedon May 5, 2020
I've not yet actually tried running this version of ST. But I can.
Whatever we do, I'd like to be sure that there's no possibility of data loss.
Last we spoke about the race detector, it didn't work on OpenBSD. If that's no longer the case, I'm happy to try.
P.S. Above traces were from master by the way.
6 remaining items
vext01 commentedon May 11, 2020
Folks, I'm keen to get to the bottom of this. Are there any STLOG flags which could help to figure out what is going on here?
I'm going to try running syncthing-1.5.0 on one of my BSD boxes for a while and see if this comes up outside of tests. I may delve into code, but I have limited time to invest.
Supposing this did come up outside of tests, what are the consequences? Just that syncthing stops running, right? Is there any chance of data loss?
calmh commentedon May 11, 2020
Crashes should not cause data loss. If you can provoke it outside of tests we can look at log flags then depending on what was happening when it crashed.
What I can say is that no user with crash reporting enabled (which is the default) has ever run into this issue, because there are zero hits on "netpoll" in our crash reporting system. (Plenty of other odd stuff though.)
vext01 commentedon May 11, 2020
OK. I may still try adding some prints in strategic locations to see if I can understand what's gone wrong.
That's good to know, but also somewhat expected for OpenBSD users at least. Most OpenBSD users will install from our binary packages repo and we've not yet updated to the version with this problem :)
vext01 commentedon May 13, 2020
So I cloned the
notifysource code and ran the tests on OpenBSD:full output
So is this where the issue lies?
I see that you have a fork of notify and the original author's tree (rjeczalik) may be abandoned?. Who do I raise this with?
FWIW, I can reproduce this on both trees.
calmh commentedon May 13, 2020
Well, we're already aware and not super likely to fix it in short order, so try upstream for one more option.
vext01 commentedon May 13, 2020
OK. It's here:
rjeczalik/notify#187
vext01 commentedon May 13, 2020
I didn't realise that we already knew
notifywas at fault :Pcalmh commentedon May 13, 2020
Oh, I'm not sure it has anything to do with the crash above. I read it sloppily and assumed you had reproduced the crash from the issue. Regardless, my comment is still mostly the same.
vext01 commentedon May 13, 2020
vext01 commentedon May 15, 2020
OK, so I've been running 1.5.0 for a few days on a production node and no
keventissues. I'm probably going to move forward with the package update.I did spend some time reading the notify source code, but since I'm a total n00b at golang, I can't really follow. Really we'd need an interested go programmer to take a look and see what's going on.
Would you folks mind if I open a bug bounty for this? It's bothering me. Obviously, cash out of my own pocket (and probably not a huge amount. I'm hoping this'd be a easy fix for a seasoned go programmer) 😸
vext01 commentedon Jul 8, 2022
When updating OpenBSD package to 1.20.3 I didn't see any failure like this.
Will close for now.