Bug 615100

Summary: log rotationinfo always recreated at startup, and corrupted on some platforms
Product: [Retired] 389 Reporter: Ulf Weltman <ulf.weltman>
Component: Directory ServerAssignee: Noriko Hosoi <nhosoi>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.2.6CC: amsharma, jgalipea, nhosoi
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:32:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 576869, 639035    
Attachments:
Description Flags
patch proposal nhosoi: review+

Description Ulf Weltman 2010-07-15 23:18:29 UTC
1) At startup log__check_prevlogs() verifies that all logs are referenced in the rotationinfo file.  If the rotationinfo file doesn't reference all the present log files, it will recreate the rotationinfo file based on the log files that are present.  However, the logic to break out of the loop that performs the verification is incorrect so it always considers the rotationinfo file to be bogus and recreates it.  I've corrected the logic.

2) Recreating the rotationinfo file isn't bad per se, but the code that recreates the rotationinfo file is also broken on HP-UX (and probably Solaris).  It tries to use the libc function strptime() to format a date such as "20100128-153532" into a struct tm, so that it can create an epoch date from there.  The format string being used for strptime() is "%Y%m%d-%H%M%S", which works on Linux, but the strptime() function requires whitespace or alpha-numeric separators between format specifiers on HP-UX (and Solaris according to their man page), so strptime() fails.  My fix here was to convert the compact date string into a string in ISO8601-like format with separators so strptime() can parse it.

Comment 1 Ulf Weltman 2010-07-15 23:21:03 UTC
Created attachment 432250 [details]
patch proposal

Comment 4 Noriko Hosoi 2011-01-12 19:34:24 UTC
Thank you so much for providing us the patch.

The patch was reviewed and tested by nhosoi.

Pushing the patch to master on behalf of Ulf Weltman (ulf.weltman).

$ git merge 615100
Updating ad3c528..3bcba24
Fast-forward
 ldap/servers/slapd/log.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
$ git push
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.63 KiB, done.
Total 6 (delta 4), reused 0 (delta 0)
To ssh://git.fedorahosted.org/git/389/ds.git
   ad3c528..3bcba24  master -> master

Comment 5 Noriko Hosoi 2011-01-12 19:47:08 UTC
Steps to verify.
0. Generate at least one previous log file.  E.g., errors.20110107-135151
1. Check the modification time of errors.rotationinfo.  E.g.,
   Jan 12 11:23 errors.20110107-135151
2. Wait at least one minute and restart the server and check the modification 
   time of errors.rotationinfo. If the time hasn't been updated, the fix is
   verified.

3. To make sure the log rotationinfo file is correctly reset,
3-1. Stop the server
3-2. Open errors.rotationinfo and remove line(s) starting with 
     LOGINFO:Previous Log File:
3-3. Restart the server and check errors.rotationinfo.  
     If LOGINFO:Previous Log File line is recovered which points to the correct previous log file, the log rotationinfo is correctly recreated.

Comment 6 Amita Sharma 2011-06-13 09:43:30 UTC
0. Generate at least one previous log file.  E.g., errors.20110107-135151
1. Check the modification time of errors.rotationinfo.  E.g.,
   Jan 12 11:23 errors.20110107-135151
2. Wait at least one minute and restart the server and check the modification 
   time of errors.rotationinfo. If the time hasn't been updated, the fix is
   verified.
-rw-------. 1 amsharma amsharma     63 Jun  7 16:44 errors.rotationinfo
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/stop-slapd 
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/start-slapd 
-rw-------. 1 amsharma amsharma     63 Jun  7 16:44 errors.rotationinfo
=========================
3. To make sure the log rotationinfo file is correctly reset,
3-1. Stop the server
3-2. Open errors.rotationinfo and remove line(s) starting with 
     LOGINFO:Previous Log File:
3-3. Restart the server and check errors.rotationinfo.  
     If LOGINFO:Previous Log File line is recovered which points to the correct
previous log file, the log rotationinfo is correctly recreated.

[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/stop-slapd 
[root@rhel61-ds90-amita slapd-M1]# vim errors.rotationinfo
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/start-slapd 
[root@rhel61-ds90-amita slapd-M1]# vim errors.rotationinfo
LOGINFO:Log file created at: 13/Jun/2011:14:19:44 (1307954984)
LOGINFO:Previous Log File:/var/log/dirsrv/slapd-M1/errors.19700101-053000 (0) (898785)
Hence VERIFIED.

Comment 7 Amita Sharma 2011-06-13 09:44:05 UTC
0. Generate at least one previous log file.  E.g., errors.20110107-135151
1. Check the modification time of errors.rotationinfo.  E.g.,
   Jan 12 11:23 errors.20110107-135151
2. Wait at least one minute and restart the server and check the modification 
   time of errors.rotationinfo. If the time hasn't been updated, the fix is
   verified.
-rw-------. 1 amsharma amsharma     63 Jun  7 16:44 errors.rotationinfo
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/stop-slapd 
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/start-slapd 
-rw-------. 1 amsharma amsharma     63 Jun  7 16:44 errors.rotationinfo
=========================
3. To make sure the log rotationinfo file is correctly reset,
3-1. Stop the server
3-2. Open errors.rotationinfo and remove line(s) starting with 
     LOGINFO:Previous Log File:
3-3. Restart the server and check errors.rotationinfo.  
     If LOGINFO:Previous Log File line is recovered which points to the correct
previous log file, the log rotationinfo is correctly recreated.

[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/stop-slapd 
[root@rhel61-ds90-amita slapd-M1]# vim errors.rotationinfo
[root@rhel61-ds90-amita slapd-M1]# /usr/lib64/dirsrv/slapd-M1/start-slapd 
[root@rhel61-ds90-amita slapd-M1]# vim errors.rotationinfo
LOGINFO:Log file created at: 13/Jun/2011:14:19:44 (1307954984)
LOGINFO:Previous Log File:/var/log/dirsrv/slapd-M1/errors.19700101-053000 (0) (898785)
Hence VERIFIED.