Current file locking does not work on NFS mounts
|Reported by:||Malcolm Tredinnick||Owned by:||Malcolm Tredinnick|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The code in
django.core.files.locks assumes that
flock() is safe to use on every POSIX system to lock files. This isn't the case when the filesystem in question is a relatively recent NFS system. In that case,
flock() actively raises an error (rather than potentially silently failing to lock things, which was the older behaviour). For those situations
fnctl() should be used to do file locking.
From a bit of a search around and some source reading (plus some comments on the Mailman list, although I've avoided reading the relevant code there for the moment, since it's GPL and I might end up being the person who fixes this ticket), it looks like posixfile.lock() in the Python source is an appropriate way to do this.
I realise the
locks.py file isn't our source, but it is broken in this respect and we do include it. So we have to fix it, since, right now, you can't save files to an NFS-mounted filesystem.
This effect in Django was initially noticed in this django-users thread.
Change History (14)
comment:4 Changed 8 years ago by
|Owner:||changed from roman to Malcolm Tredinnick|
|Status:||new → assigned|