graphite-project / carbon

Carbon is one of the components of Graphite, and is responsible for receiving metrics over the network and writing them down to disk using a storage backend.
http://graphite.readthedocs.org/
Apache License 2.0
1.51k stars 490 forks source link

ENABLE_LOGROTATION = False with multiple carbon daemons #549

Closed jonsulman closed 7 years ago

jonsulman commented 8 years ago

I think the code that supports "logrotate" log rotation is not working under multiple carbon daemons.

log.py:

  def write(self, data):
    if not self.enableRotation:
      if not os.path.exists(self.path):
        self.reopen()
    DailyLogFile.write(self, data)

If you are running multiple daemons, as soon as one daemon notices the log file has rotated it will create a new one. Then for the other daemons os.path.exists(self.path) will be true (seeing the other daemon's newly created file), so they will not reopen their log file and will continue writing to the old file.

As a result you end up with a situation like this:

$ sudo lsof console.log*
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
carbon-ca 40009 carbon    6u   REG  253,0   585103 4372133 console.log.2016_4_26
carbon-ca 50485 carbon    6u   REG  253,0   798915  574424 console.log.2016_4_23
carbon-re 50563   root    6u   REG  253,0    10090 2728960 console.log
jonsulman commented 8 years ago

550

jonsulman commented 8 years ago

The default settings from carbon.conf.example show how to set ENABLE_LOGROTATE, but don't clearly indicate that since the example is in the [cache] section, it doesn't apply to relay processes unless added to the [relay] section.

deniszh commented 7 years ago

PR is merged, closing