Skip to content

Envoy does not release access log fd on sigusr1 #4060

Closed

Description

@taion809

Envoy does not release access log fd on sigusr1

Description:
In one of our more heavily used clusters we've seen that despite employing logrotate and kill -USR1 $ENVOY_PID the file descriptors are still present in /proc/$ENVOY_PID/fd. We have also seen the reported memory usage increase until we force a reload either by restarting the process or kill -HUP $ENVOY_HOT_RESTART_PID.

Version:

envoy 08fadcc41f34b5816f2dc9412a1614efca4d9667/1.8.0-dev/Clean/RELEASE live 2829 44974 1

Repro steps:

  1. ls -l /var/log/envoy/200
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 130 -> /var/log/envoy/default_https.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 131 -> /var/log/envoy/200/default_https_access.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 146 -> /var/log/envoy/spark_default_https.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 61 -> /var/log/envoy/default.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 77 -> /var/log/envoy/spark_default.log
  1. kill -USR1 $ENVOY_PID
  2. sudo ls -l /proc/$ENVOY_PID/fd
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 130 -> /var/log/envoy/default_https.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 131 -> /var/log/envoy/200/default_https_access.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 146 -> /var/log/envoy/spark_default_https.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 147 -> /var/log/envoy/200/spark_default_https_access.log.1
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 61 -> /var/log/envoy/default.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 62 -> /var/log/envoy/200/default_access.log.1
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 77 -> /var/log/envoy/spark_default.log
	lrwx------ 1 envoy envoy 64 Aug  6 12:39 78 -> /var/log/envoy/200/spark_default_access.log.1

Mitigation:
(this is for anyone that lands here from google searching in the future)

There are 2 ways to mitigate:

  1. Restart the envoy process.
  2. If using the envoy hot restarter script you can force a reload: kill -HUP $ENVOY_HOT_RESTART_PID

Activity

  1. added
    question
    on Aug 6, 2018
  2. mattklein123 commented on Aug 6, 2018

    @mattklein123
    Member

    Here is the reopen logic: https://github.com/envoyproxy/envoy/blob/master/source/common/filesystem/filesystem_impl.cc#L196. I'm pretty sure it's working correctly.

    Do you essentially see this leak forever in your env no matter how many times you rotate? @danielhochman might be able to spot check what's going at Lyft in this area.

  3. taion809 commented on Aug 6, 2018

    @taion809
    ContributorAuthor

    bleh... I think this is me v_v

    I did some more work and this is what i see:

    • we have 1 higher volume route generating a couple hundred mb in access logs every 10 minutes but we have a number of low volume routes that do not generate many logs
    • time-based logrotation would take an existing log and rotate it
      • a new log would be created, an old one would be rotated but envoy would keep the old fd until the new one received traffic then it would release the old fd.
    • size-based logrotation would take an existing log and rotate it
      • The reported memory usage by systemd was the sum of all log files in the log directory (weird).
      • Envoy would release the old fd as the new one received traffic immediately.
  4. mattklein123 commented on Aug 7, 2018

    @mattklein123
    Member

    Cool, glad it's working. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions