Project

General

Profile

Actions

Bug #11639

closed

Entries from rotated log files may be displayed out of order when log display includes contents from multiple files

Added by Jim Pingle over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Logging
Target version:
Start date:
03/09/2021
Due date:
% Done:

100%

Estimated time:
Plus Target Version:
Release Notes:
Default
Affected Version:
2.5.0
Affected Architecture:

Description

The code in rsort_log_filename() is making faulty assumptions about the log filenames. It is not only testing the wrong part of the filename, but it isn't properly accounting for both compressed and uncompressed log filenames.

In some cases it's OK since glob() may happen to return the filenames in order by chance, but when there are a large number of related log files the incorrect order is more apparent.

To reproduce, touch /var/log/filter.log.0 through /var/log/filter.log.18 and then check the contents of the array returned by sort_related_log_files('/var/log/filter.log', false, false).
Remove those files and touch /var/log/filter.log.0.bz2 through /var/log/filter.log.18.bz2 and repeat the test.

In each case it returns a result in an unexpected order, for example:

array(20) {
  [0]=>
  string(21) "/var/log/filter.log.5" 
  [1]=>
  string(21) "/var/log/filter.log.3" 
  [2]=>
  string(21) "/var/log/filter.log.4" 
  [3]=>
  string(22) "/var/log/filter.log.18" 
  [4]=>
  string(21) "/var/log/filter.log.2" 
  [5]=>
  string(21) "/var/log/filter.log.8" 
  [6]=>
  string(21) "/var/log/filter.log.0" 
  [7]=>
  string(22) "/var/log/filter.log.14" 
  [8]=>
  string(22) "/var/log/filter.log.15" 
  [9]=>
  string(22) "/var/log/filter.log.12" 
  [10]=>
  string(22) "/var/log/filter.log.13" 
  [11]=>
  string(22) "/var/log/filter.log.11" 
  [12]=>
  string(22) "/var/log/filter.log.10" 
  [13]=>
  string(21) "/var/log/filter.log.1" 
  [14]=>
  string(21) "/var/log/filter.log.6" 
  [15]=>
  string(22) "/var/log/filter.log.16" 
  [16]=>
  string(21) "/var/log/filter.log.7" 
  [17]=>
  string(22) "/var/log/filter.log.17" 
  [18]=>
  string(21) "/var/log/filter.log.9" 
  [19]=>
  string(19) "/var/log/filter.log" 
}

To me, I have a fix.

Actions

Also available in: Atom PDF