carbon icon indicating copy to clipboard operation
carbon copied to clipboard

whisper files created with no permissions

Open mleinart opened this issue 13 years ago • 41 comments

Imported from https://bugs.launchpad.net/bugs/702066

Reported by pete-appnexus
Date Created Jan 12, 2011

I'm using carbon-relay (Graphite-0.9.6) to send metrics from one server to another.

Currently, I populate a metric on one server, and it looks fine in the browser.

I look on the other server, and I get this:

Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 86, in get_response response = callback(request, _callback_args, *_callback_kwargs) File "/opt/graphite/webapp/graphite/render/views.py", line 97, in renderView seriesList = evaluateTarget(target, timeInterval) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 14, in evaluateTarget result = evaluateTokens(tokens, timeInterval) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 30, in evaluateTokens return evaluateTokens(tokens.expression, timeInterval, originalTime) File "/opt/graphite/webapp/graphite/render/evaluator.py", line 43, in evaluateTokens dbResults = dbFile.fetch( timestamp(startTime), timestamp(endTime) ) File "/opt/graphite/webapp/graphite/storage.py", line 232, in fetch (timeInfo,values) = whisper.fetch(self.fs_path, startTime, endTime) File "/usr/lib/python2.4/site-packages/whisper.py", line 462, in fetch fh = open(path,'rb') IOError: [Errno 13] Permission denied: '/opt/graphite/storage/whisper/path/to/my/metric.wsp'

The permissions on the file are 0000 instead of 0644 as I'm seeing on the source server.

The directory used for this is a 20GB tmpfs, although I'm not sure that should play into it.

Have you seen anything like this before, and can you help me track this down?

Thanks, Pete

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by pete-appnexus on Jan 12, 2011:

I just fixed the permissions and restarted the carbon-cache and the carbon-relay, and then sent a new metric in. The new metric showed up with the proper permissions. So for now, I'm unwedged, but it's still a mystery.

Pete

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by chrismd on Jan 12, 2011:

Pete, I have encountered this exact same problem a few times myself and I am completely at a loss as to what causes it. The characteristics I have noticed are that carbon starts out completely fine but after something happens that triggers this issue (no idea what), all subsequent files created by carbon-cache have 0000 perms. Restarting it always seems to fix it.

This issue led me to add some excessive permission-fixing code which is still in trunk, carbon-cache explicitly sets its umask to 022 and chmod's each wsp file after creation. That seemed to fix the issue for me so perhaps try 0.9.7 (which has those changes) and see if the problem recurs or not.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by chrismd on Jan 18, 2011:

Currently implemented solution is just a workaround, still need to determine the root cause.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by chrismd on Apr 01, 2011:

The workaround for this was to use os.system("mkdir -p ...") instead of os.makedirs(). I have no idea why os.makedirs() breaks in this fashion, setting umask and even putting an explicit os.chmod after the makedirs call doesn't even help! However, since this is a severely bad problem when it occurs, I'm going to stick with the os.system workaround for now.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by chrismd on Apr 01, 2011:

The os.system workaround was first released in 0.9.7.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by ziggy on Jul 12, 2011:

So in my version of Graphite, (trunk from somewhere around 0.9.8), carbon creates new directories as you described: os.system("mkdir -p -m 755 '%s'" % dbDir) but I see occasional bouts where it creates directories with broken permissions of "d-wx------". I don't see how this could possibly happen but it has been biting us with increasing frequency recently. I'm going to keep investigating but just wanted to throw it out there that this is still an issue.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by chrismd on Jul 12, 2011:

Thanks ziggy, I'm reopening this as its not really "fixed" until we understand what is broken. The os.system workaround has eliminated the issue for me but I'd still like to figure this thing out. Since you have a system that can recreate the problem any info you can provide for debugging would be much appreciated.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by ziggy on Jul 29, 2011:

I made a change to writer.py to make it explicitly set the permissions on new directories as a separate step, much like it does for whisper files. It is working. I haven't seen any bad permissions in the week or two since I applied the attached one-line patch.

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by cbowman-z on Dec 13, 2011:

We're still experiencing this randomly on the directory level. Leads me to have to run a find /opt/graphite/storage/whisper -type d ! -perm 755 -exec chmod 755 {} ; when I notice the problem.

I believe I have the current issue boiled down to the permissions on the parent directories. I propose that the mkdir call be modified to set the umask in it: os.system("(umask u=rwx,go=rx; mkdir -p -m 755 '%s')" % directory)

[root@hostname test]# umask 0077 [root@hostname test]# cat file_perm.py #!/usr/bin/python26

import os, sys

directory = 'a/b/c' os.system("(umask u=rwx,go=rx; mkdir -p -m 755 '%s')" % directory)

directory = 'b/a/d' os.system("mkdir -p -m 755 '%s'" % directory) [root@hostname test]# ./file_perm.py [root@hostname test]# find . -type d -exec ls -ald {} ; drwxr-xr-x 4 root root 4096 Dec 13 17:08 . drwxr-xr-x 3 root root 4096 Dec 13 17:08 ./a drwxr-xr-x 3 root root 4096 Dec 13 17:08 ./a/b drwxr-xr-x 2 root root 4096 Dec 13 17:08 ./a/b/c drwx------ 3 root root 4096 Dec 13 17:08 ./b drwx------ 3 root root 4096 Dec 13 17:08 ./b/a drwxr-xr-x 2 root root 4096 Dec 13 17:08 ./b/a/d

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by ziggy on Dec 13, 2011:

Yes I still see this bug as well. I'd be happy to try setting the umask because we run the find command every hour, and it hogs a lot of I/O. Let me know how it works for you.

On Tue, Dec 13, 2011 at 11:10 AM, Christopher Bowman [email protected] wrote:

We're still experiencing this randomly on the directory level.  Leads me to have to run a find /opt/graphite/storage/whisper -type d ! -perm 755 -exec chmod 755 {} ; when I notice the problem.

I believe I have the current issue boiled down to the permissions on the parent directories.  I propose that the mkdir call be modified to set the umask in it: os.system("(umask u=rwx,go=rx; mkdir -p -m 755 '%s')" % directory)

[root@hostname test]# umask 0077 [root@hostname test]# cat file_perm.py #!/usr/bin/python26

import os, sys

directory = 'a/b/c' os.system("(umask u=rwx,go=rx; mkdir -p -m 755 '%s')" % directory)

directory = 'b/a/d' os.system("mkdir -p -m 755 '%s'" % directory) [root@hostname test]# ./file_perm.py [root@hostname test]# find . -type d -exec ls -ald {} ; drwxr-xr-x 4 root root 4096 Dec 13 17:08 . drwxr-xr-x 3 root root 4096 Dec 13 17:08 ./a drwxr-xr-x 3 root root 4096 Dec 13 17:08 ./a/b drwxr-xr-x 2 root root 4096 Dec 13 17:08 ./a/b/c drwx------ 3 root root 4096 Dec 13 17:08 ./b drwx------ 3 root root 4096 Dec 13 17:08 ./b/a drwxr-xr-x 2 root root 4096 Dec 13 17:08 ./b/a/d

You received this bug notification because you are subscribed to the bug report. https://bugs.launchpad.net/bugs/702066

Title:  whisper files created with no permissions

To manage notifications about this bug go to: https://bugs.launchpad.net/graphite/+bug/702066/+subscriptions

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by marty-supine on Oct 17, 2012:

Seeing this on Centos 6.3 running carbon-0.9.10-py2.6

I've modified the mkdir system call in our writer.py to use the umask settings mentiond in comment 9 and will see how that goes

mleinart avatar Mar 11 '13 12:03 mleinart

Comment by millerdev on Feb 20, 2013:

I'm seeing the same issue seen by Eric Ziegenhorn (ziggy) on carbon-0.9.10. Directories (except for leaf nodes) are created with incorrect permissions: "d-wx------". I was able to determine the umask of the carbon process with gdb:

gdb attach CARBON_PID

... (gdb) call umask(0) $1 = 511 (gdb) call umask(511) $2 = 0

Don't forget the second call to reset the umask!

python -c 'print(oct(511))'

0777

After restarting carbon it has the correct umask:

gdb attach CARBON_PID

... (gdb) call umask(0) $1 = 18 (gdb) call umask(18) $2 = 0

python -c 'print(oct(18))' 022

mleinart avatar Mar 11 '13 12:03 mleinart

I am also seeing this with 0.9.10, on centos 6.3:

d-wx------ 3 root root 4096 Mar 15 15:08 updateNamesOfUser

scottbessler avatar Mar 18 '13 05:03 scottbessler

We're still seeing this issue on CentOS 6.4 with 0.9.10. Is there any progress on a fix?

bnied avatar Aug 21 '13 13:08 bnied

@bnied Can you please post some specifics of your setup? Kernel and Python package versions? How long was carbon-cache running before it started to exhibit the behavior? (Calendar time and CPU time) carbon-cache metricsReceived average? number of open filehandles?

It seems like this affects "busy" carbon-caches after a period of operation. If we can start collecting and comparing setups, maybe that will help find the issue.

irvingpop avatar Aug 21 '13 16:08 irvingpop

I was seeing this on one of my carbon servers. I will add my setup to the collection:

Kernel: 2.6.32-279.el6.x86_64 Python: python-2.6.6-29.el6_3.3.x86_64 Python 2.6.6 (r266:84292, Sep 11 2012, 05:13:24) [GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2 Carbon: 0.9.10 Pypy: pypy-libs-1.9-1.el6.x86_64 pypy-1.9-1.el6.x86_64

I last noticed this about 2 months ago. On this server, I have 3 carbon-caches running in cpython behind 1 carbon relay running in pypy. The carbon caches average 60k metrics/minute each with a cpuUsage that hovers between 17 and 28. The carbon caches were running for about 2 months without a restart. When I noticed the issue, it was blocking some important new metrics, so I restarted all of my carbon caches and changed permissions of the impacted metrics.

These carbon caches have now been running since Jun 14 without issue. They currently have 577 files open between them, while the relay has 88 open.

jbrinegar avatar Aug 21 '13 17:08 jbrinegar

We have two graphite nodes:

Kernel: 2.6.32-279.el6.x86_64 Python: python-2.6.6-29.el6_2.2.x86_64 Carbon: 0.9.10 CPU Usage: 100% (node 1), 20%-90% (node 2) Memory Usage: ~2.6 GB (node 1), 100 - 650 MB (node 2) Metrics Received: ~600K/minute (node 1) with spikes up to 1M/minute, 200K-300K (node 2)

We last saw this problem on Node 2 this morning. Weirdly enough, this problem does not seem to be happening on Node 1, which is under far higher load.

bnied avatar Aug 21 '13 18:08 bnied

@bnied earlier you stated that you had this issue on 6.4, but your Kernel and Python package versions match 6.3.

I experienced this issue on my carbon-cache node (~75K metrics/minute avg) a few months ago when it was on RHEL 6.3. Since upgrading to 6.4 (kernel 2.6.32-358.6.2.el6.x86_64, python-2.6.6-36.el6.x86_64) on Jul 11, I haven't noticed the issue (yet).

HOWEVER, my rate of directory churn is now quite low (very few directories being created), so I'm not sure if it's appropriate to correlate.

irvingpop avatar Aug 21 '13 19:08 irvingpop

FWIW, CentOS 6.3 stopped being supported/updated as soon as CentOS 6.4 came out. Same for RHEL, unless you pay extra for "Extended Update Support"

irvingpop avatar Aug 21 '13 19:08 irvingpop

You're right; my mistake. I thought we'd upgraded these servers to 6.4.

bnied avatar Aug 21 '13 19:08 bnied