New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
emits CREATE when it should have been REMOVE #404
Comments
I'm having this exact issue.
|
I just tried spinning up a couple of Docker containers with In another tab, I ran a basic script to generate files sequentially, write a few bytes and remove them from the watcher dir:
And indeed, we're ending up an inconsistent state at the end of the run:
Where all counts should be 5000. |
I'm able to reproduce this on an Alpine Linux docker container, with similar conditions to the above. It does not occur on my host installation of Ubuntu. Interestingly, the issue occurs within the following fsnotify program:
In one run, using However, it does NOT occur if I use inotify-wait (a CLI utilizing inotify) to count the number of operations. See following output:
I think this implies that the issue does not lie with inotify/Docker/Alpine, but rather with fsnotify. |
Strangely, I'm not able to reproduce the above issue as well anymore; I modified my script to create, modify, and remove 20000 files per run, and I get some variation of the following:
Clearly some events are being dropped, but it's not as egregious. After removing the following snippet from the ignoreLinux method (as follows) I was able to achieve the expected results.
Essentially, if the event doesn't contain a remove or a rename, we check lstat every time to see if the file still exists, and drop the event if it doesn't, but that's no guarantee that the file still exists by the time the client receives it, or processes the event. I think this snippet still guarantees the correct behavior (it would simply drop most events for which the corresponding file no longer existed), but we're not actually providing any guarantee to the clients that the file still exists by the time that they receive the event, so do we really need to be invoking lstat thousands of times? The inotify man page indicates that events will be sent in order, and they are processed in fsnotify in order, so there shouldn't be any cases in which we've received a delete, and then later on receive a write event to the same file (unless a file with the same name has been created). Could you please make this modification on your ends, and see if you can still reproduce the issue? |
I think #470 should have fixed this; please let me know if you can still reproduce it with that change. |
Prior to this commit, sysbox-mgr only monitored fsnotify events that signaled the removal of a container's rootfs. However in some situations it appears fsnotify can miss the notification or notify via a different event type (see fsnotify/fsnotify#404). This commit causes sysbox-mgr to explicitly check for container rootfs removal whenever it receives any fsnotify event. In addition, update the fsnotify version from v1.4.7 -> v1.5.4 to leverage several improvements and bug fixes. Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
Before reporting an issue, please ensure you are using the latest release of fsnotify.
Which operating system (GOOS) and version are you using?
Please describe the issue that occurred.
Basically I am running an application that uses fsnotify in docker and I am manually creating and removing files just to see the events, and sometimes it reports
CREATE
when it should have been aREMOVE
.Are you able to reproduce the issue? Please provide steps to reproduce and a code sample if possible.
What I would do is make a Dockerfile with
alpine:latest
and copy the example you have in github. Mount a directory and watch that directory and just delete and create files on the host, not the container, and you'll see it. It happens pretty often, but not all the time.I dont know if this is an issue with containers, mounting volumes, and deleting from the host or an issue just in general. In general, as in not using docker and being able to repo this since I've only tried it using docker and creating/deleting files on the host.Okay looks to be an issue with potentially with either docker or alpine linux.
The text was updated successfully, but these errors were encountered: