Repository navigation
Description
Log files previously rolled by ATS are not being removed when disk limits specified by the following parameters are reached:
proxy.config.log.max_space_mb_for_logs
proxy.config.log.max_space_mb_headroom
..and when proxy.config.log.auto_delete_rolled_files is set to 1.
This issue could be related to #5966. The configuration works in ATS 8.x, but does not work in ATS 9. Both rolling_max_count and rolling_min_count are set to zero. Setting the former to > 0 does not appear to have an effect, and the latter causes files to be rotated as expected, but prior to disk space exhaustion. It could be that the two settings influence the behavior in an unexpected manner, but our expectation is that the max_space parameters would work regardless of the min and max count settings.
Additionally, it appears the proxy.config.log.max_space_mb_for_orphan_log setting was removed, and the concern is that logs created by a prior running instance of ATS may not be selected as a candidate for removal. I was unable to confirm if this is the case because ATS is not even deleting the files it rolled during its current run.
In the following example, ATS 9 was put under load such that logging would eventually cross the thresholds specified by the above parameters. The parameters do cause ATS to detect that disk space has been exhausted, as seen in this sequence, but ATS is unable to find the logs it had just rolled itself. The log directory was filled by ATS' usual log rotation, creating a number of rotated files as expected and filling up the disk. That is where the log messages begin.
...manually removed all rolled files...
NOTE: Logging space is no longer exhausted.
NOTE: Logging disk is no longer low; access logging to local log directory resumed.
...load sent to ATS...
...ATS log files roll as expected...
NOTE: Cannot clear space because there are no recognized Traffic Server rolled logs for auto deletion.
NOTE: Logging space exhausted, any logs writing to local disk will be dropped!
WARNING: Access logging to local log directory suspended - configured space allocation almost exhausted.
NOTE: [Alarms::signalAlarm] Skipping Alarm: 'Access logging to local log directory suspended - configured space allocation almost exhausted.'
NOTE: Cannot clear space because there are no recognized Traffic Server rolled logs for auto deletion.
NOTE: Cannot clear space because there are no recognized Traffic Server rolled logs for auto deletion.
...continues until files are manually removed...
The LogConfig::update_space_used() method is where the files are detected for removal. Logic wraps the call to RolledLogDeleter's consider_for_candidacy() that could be failing, but consider_for_candidacy() also has a side effect where it's incrementing the candidate counter, that is then used later in update_space_used() via a call to RolledLogDeleter's has_candidates() method. That method returns false and prints the above error message (Cannot clear space because there are no recognized Traffic Server rolled logs for auto deletion) We can infer that means that consider_for_candidacy() never executed, or it did, but didn't find a candidate, and didn't increment the candidate counter.
Activity
bneradt commentedon Sep 17, 2020
elsloo commentedon Sep 21, 2020
After further testing, I've narrowed this down to when
logging.yamlis updated. Once that file is touched, regardless of whether or not a config change is present, and the config is reloaded, log rolling stops working. There is no "Error opening logging directory..." message logged.To reproduce, I lowered the log rolling thresholds, and directed traffic toward ATS until it started rolling logs. I then updated records.config to enable debug for the
logspacetag, touchedlogging.yamland reloaded the config viatraffic_ctl config reload. I also reproduced the issue by performing the same sequence, but starting with an empty log directory, and reloading the configuration prior to the log directory being deemed full by ATS. The debug output of these steps follow, marked as sequence A and B, respectively.Sequence A:
Sequence B:
bneradt commentedon Sep 23, 2020
I've reproduced this in our prod sim environment. After touching
logging.yamland performing thetraffic_ctl config reloadas described by Jeff above, Traffic Server seems to lose certain categories of rolled log files it can autodelete. It still can delete rolled traffic.out, diags.out, and manager.out log files, for instance, but not any log files configured via logging.yaml. Once I restart the Traffic Server process, it notices the logging.yaml rolled log files and deletes them, freeing up the space it couldn't before after the config reload.It's not clear to me why this is happening. I see in the traffic.out output that those logging.yaml configured log files are indeed registered for log deletion, so why aren't they being deleted? I'll look into this more tomorrow morning.
bneradt commentedon Sep 23, 2020
I see what is happening now. When a config reload happens, this is what takes place (among a lot of other stuff, of course, this is just what is relevant to this bug):
Log::change_configurationcreates a new LogConfig object and initializes it from the old one: Log.cc:117LogObject::_setup_rolling(LogObject.cc:692) viaLog::config->register_rolled_log_auto_delete(m_basename, m_min_rolled);Thus the old Log::config gets registered for auto deletion with the new logging.yaml LogObject instances instead and the new LogConfig. As a side note, traffic.out, manager.out, etc. are registered by LogConfig itself, so that is why they were still properly handled after a reload. But none of the logging.yaml objects persist across a reload.
I believe this can be easily resolved in the LogConfig::init() function by copying over the old RolledLogDeleter to the new config.
bneradt commentedon Sep 23, 2020
Digging further, what is described here as a problem with auto deletion using the old config looks like just one of a host of like problems that happen as LogObject and LogBuffer objects are created based upon values from the old config. Basically, all objects created in new_config->init in Log.cc are created referencing the old rather than the new config (the
// <--comments are added as annotations by me):Thus, for example, if the user changes the max buffer size and does a config reload, LogObjects will instead be configured to use the old max buffer size.
While fixing the problem with rolled log auto deletion, we should consider fixing these issues with LogObject and LogBuffer as well.
bneradt commentedon Sep 24, 2020
PR is up. Thank you @elsloo for your thorough description of the problem. It helped me reproduce the bug.
bneradt commentedon Sep 28, 2020
On a related note, rather than using the ATS implemented log rotation and deletion mechanism, Yahoo has been internally using logrotate with the signal USR2 to handle log rotation and deletion for ATS 9. Support for this has been released to open source via:
#6806
I mention this since it is an alternative mechanism for handling log rotation that others may want to consider.
It is merged into master and is targeted for 9.1.x.