Skip to content
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

OSError on cache.delete [Errno 13] Permission denied #4

Closed
grantjenks opened this issue Mar 24, 2016 · 4 comments
Closed

OSError on cache.delete [Errno 13] Permission denied #4

grantjenks opened this issue Mar 24, 2016 · 4 comments

Comments

@grantjenks
Copy link
Owner

File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/djangocache.py", line 77, in delete
    self._cache.delete(key)
  File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/fanout.py", line 123, in delete
    return self.__delitem__(key)
  File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/fanout.py", line 111, in __delitem__
    return self._shards[index].__delitem__(key)
  File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/core.py", line 737, in __delitem__
    return self._delete(rowid, version, filename)
  File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/core.py", line 763, in _delete
    self._remove(filename)
  File "/home/grantj/repos/xxx/env27/lib/python2.7/site-packages/diskcache/core.py", line 790, in _remove
    os.remove(full_path)

OSError: [Errno 13] Permission denied: '/tmp/xxx-cache/003/e6/be/87b78c58d79c1a502b05ce645db8.val'

This is an odd error. On one particular server I get transient [Errno 13] Permission denied errors.

@grantjenks
Copy link
Owner Author

Hit it again. Odd that it hits on os.remove. I was able to reproduce in the shell on the server. But I screwed up while debugging and lost the reference. When it happens again it's worth debugging on the server. The key format is:

'thread-question-summary-%d-%s' % (thread_id, 'en')

@grantjenks
Copy link
Owner Author

This is odd:

In [23]: !ls -al /tmp/xxx-cache/000/8f/17/
total 16
drwxr-xr-x  2 grantj root 4096 Mar 23 19:55 .
drwxr-xr-x 48 grantj root 4096 Mar 27 15:12 ..
-rw-r--r--  1 grantj root 5740 Mar 23 19:55 cdc864e3de42f9a7578953f5f0c7.val

In [24]: !ls -al /tmp/xxx-cache/000/8f/f3/
total 12
drwxr-xr-x  2 root   root 4096 Mar 26 23:57 .
drwxr-xr-x 48 grantj root 4096 Mar 27 15:12 ..
-rw-r--r--  1 root   root 2732 Mar 26 23:57 c6f9cfb2aad602bb9a59db9ec183.val

Some cache values are stored as root. Not all are. Only the ones here. How does that happen?

If it now tries to delete the key at 000/8f/f3 then it raises OSError.

@grantjenks
Copy link
Owner Author

Attempted fix:

sudo find /tmp/xxx-cache/ -user root -type d -exec chown grantj:root {} \;
sudo find /tmp/xxx-cache/ -user root -type f -exec chown grantj:grantj {} \;

We'll see. It's otherwise very odd. Maybe I was debugging something and running uwsgi manually as root? I'm not sure.

@grantjenks
Copy link
Owner Author

Error happened again. I think it may be the crontab. Some management commands are run under root. I very much doubt this is a DiskCache bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant