﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31900	Reloader using watchman initiates reloads despite no file changed	Julien Chol	nobody	"While running runserver with watchman, reloader would initiate a server reload after only a few requests, even without any file modified.

On my main project, it would actually restart after every request, defeating completely the purpose of watchman.

This bug can be reproduced on a fresh install. It affects versions 2.2.15 and 3.1. I haven't tested other releases.

For convenience, I made a Docker image installing Django, watchman and pywatchman according to the docs. Docker file is attached.

To experience the bug run `docker run -p 8000:8000 chelou/debug-watchman:latest`, then visit [http://localhost:8000] and refresh a few times. 

You should then see a server reload being fired, as per the following output:
{{{
Watching for file changes with WatchmanReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 18, 2020 - 15:16:12
Django version 3.1, using settings 'debug_watchman.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[18/Aug/2020 15:16:23] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:23] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:25] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:25] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:37] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:37] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:39] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:39] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:44] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:44] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:45] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:45] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:46] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:47] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:54] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:55] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:55] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:56] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:56] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:57] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:58] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:58] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:16:59] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:16:59] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:17:07] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:17:07] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:17:08] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:17:08] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:17:09] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:17:10] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
[18/Aug/2020 15:17:10] ""GET / HTTP/1.1"" 200 16351
[18/Aug/2020 15:17:10] ""GET /static/admin/css/fonts.css HTTP/1.1"" 304 0
/usr/local/lib/python3.7/sqlite3/dbapi2.py changed, reloading.
Watching for file changes with WatchmanReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 18, 2020 - 15:17:13
Django version 3.1, using settings 'debug_watchman.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
}}}

The full traceback is provided as attachment. It can be reproduced by using the following command `docker run -p 8000:8000 --env LOG=1 chelou/debug-watchman:latest`

I have noticed that this problem seems to affect only files in `/usr/local/lib/python3.7/`, not actual project files.

To ensure that the bug was not linked to `inotify` limits, I have set `fs.inotify.max_user_instances` `fs.inotify.max_user_watches` `fs.inotify.max_queued_events` to `1000000`

`pywatchman` version is `1.4.1` and `watchman` version is `2020.08.17.00`"	Bug	closed	Utilities	3.1	Normal	worksforme	reloader watchman	Tom Forbes	Unreviewed	0	0	0	0	0	0
