Processes continue to hold open file descriptor for old log when log file is renamed or deleted
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.log |
Fix Released
|
Wishlist
|
Marian Horban |
Bug Description
For OpenStack services that spawn multiple processes (such as nova-api or cinder-volume), some of those processes will hold open file descriptors to renamed or deleted log files. The latter case will prevent the filesystem from recovering space from a deleted file until after the process exits.
For example, nova-api has four processes holding open
/var/log/
# ps -e -o pid,cmd |
grep nova-api |
awk '/python/ {print $1}' |
xargs -iPID ls -l /proc/PID/fd/3
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3485/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3490/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3492/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3501/fd/3 -> /var/log/
If I delete this file:
# rm /var/log/
The processes will continue to hold that fd open until a write occurs:
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3485/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3490/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3492/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3501/fd/3 -> /var/log/
After a write operation, the process making the write will recognize
that the file has gone missing and will open a new output file, but
other processes will continue to hold open the file descriptor until
(a) they exit or (b) they write a log message:
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3485/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3490/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3492/fd/3 -> /var/log/
l-wx------. 1 nova nova 64 Mar 27 17:56 /proc/3501/fd/3 -> /var/log/
This could lead to problems in the event that someone is trying to
delete log files in order to free up space. There are several ways to
solve this, the simplest of which is to clearly document this behavior
and recommend the use of something like logrotates "copytruncate"
option for handling log rotation. Is that the best option?
At a glance, this affects at least nova, cinder, neutron, and glance.
Changed in oslo.log: | |
milestone: | none → 1.12.0 |
status: | Fix Committed → Fix Released |
Looks like this originated from: /bugzilla. redhat. com/show_ bug.cgi? id=1123298
https:/