Carbon-Cache accepts metrics with invalid names

Bug #1037672 reported by Dave Rawks
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Graphite
Won't Fix
Undecided
Unassigned

Bug Description

No attempt is made to validate that the metric name does not contain nulls or other characters no accepted by the os.path module's various functions. This results in an uncaught exception in the writer thread when attempting to flush metrics from cache to disk.

14/08/2012 09:52:02 :: Sorted 1012 cache queues in 0.000527 seconds
14/08/2012 09:52:02 :: Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 504, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 167, in _worker
    result = context.call(ctx, function, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/opt/graphite/lib/carbon/writer.py", line 158, in writeForever
    writeCachedDataPoints()
  File "/opt/graphite/lib/carbon/writer.py", line 91, in writeCachedDataPoints
    for (metric, datapoints, dbFilePath, dbFileExists) in optimalWriteOrder():
  File "/opt/graphite/lib/carbon/writer.py", line 54, in optimalWriteOrder
    dbFileExists = exists(dbFilePath)
  File "/usr/lib/python2.7/genericpath.py", line 18, in exists
    os.stat(path)
exceptions.TypeError: must be encoded string without NULL bytes, not str

To resolve this issue it would be appropriate to catch these bogus metric names in the writer thread and raise a log event AND to pop the metrics from the cache to prevent a situation where bad metrics/datapoints fill the cache but are unable to be flushed or otherwise removed.

Revision history for this message
Dave Rawks (drawks) wrote :

To reproduce send a metric with an embedded nulll character in the metric name to the tcp linereceiver.

Revision history for this message
Michael Leinartas (mleinartas) wrote :
Changed in graphite:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.