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.
Created attachment 432250 [details] patch proposal
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
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.
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.