Kenshin icon indicating copy to clipboard operation
Kenshin copied to clipboard

OSError: [Errno 36] File name too long

Open camper42 opened this issue 8 years ago • 5 comments

  File "/var/graphite/env/lib/python2.7/site-packages/kenshin-0.2.6-py2.7-linux-x86_64.egg/kenshin/utils.py", line 24, in mkdir_p
    os.makedirs(path)
  File "/var/graphite/env/lib64/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/var/graphite/env/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)

a 340 characters metric name

camper42 avatar Aug 08 '17 05:08 camper42

Maximum filename length on XFS is 255 bytes. https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits

.hs file successful created, but symlink failed. Ignore filename too long while os.symlink or set a limit(for each part of metric name) in Kenshin Storage? @zzl0

camper42 avatar Aug 08 '17 08:08 camper42

3 options:

  1. Optimize metric names.
  2. Ignore filename too long while os.symlink or set a limit(for each part of metric name) in Kenshin Storage
  3. Investigate how the graphite team solve this problem

zzl0 avatar Aug 08 '17 13:08 zzl0

https://github.com/graphite-project/carbon/issues/181

Adding a regex and a string manipulation on every insert can be very costly at high volume. There used to be code to "correct" malformed metrics but it was removed because of the performance impact. If you want good metric namespaces you should send good metric namespaces, the code shouldn't be a nanny that everyone has to pay for.

camper42 avatar Aug 09 '17 02:08 camper42

match ^.*[^.]{256,}.*$
    send to blackhole
    stop
    ;

add this to relay.conf will prevent bad metrics send to rurouni cache limit (256 here) depends on your file system

camper42 avatar Aug 09 '17 04:08 camper42

@camper42 想了下,我觉得应该在这里(即 instrumentation.incr('creates')前面)加上检查指标格式的逻辑,如果不合法就拒绝,并用 instrumentation 统计不合法的指标数量。

为什么这个检查对 cpu/性能 消耗不大?

  1. 只有新的指标才会走到这里。
  2. 而且我们使用了 token_bucket 控制新指标的数量(我们线上应该是1000 个每分钟,具体参见 settings.MAX_CREATES_PER_MINUTE)。

zzl0 avatar Aug 10 '17 23:08 zzl0