You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2008/02/15 02:55:06 UTC

DO NOT REPLY [Bug 44427] New: - Externally triggered rotatlogs rotation

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427

           Summary: Externally triggered rotatlogs rotation
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: PatchAvailable
          Severity: enhancement
          Priority: P2
         Component: support
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: rainer.jung@kippdata.de


There is a common problem of how to compress/archive log files without
restarting the server processes.

Although rotatelogs solves the problem partially by rotating size or time based,
there remains the problem of files to which data is written not often enough,
like error logs. Rotatelogs only checks the rotation conditions, when it has
something to write to the files.

People placing their log files on NFS and running compress cron jobs end up with
a lot of .nfs files, because the compression removes the original files, which
are still open by rotatelogs waiting (maybe since a long time) for some message
to handle.

The solution to (gracefully) restart Apache has the disadvantage, that it
destroys status information. Altough the info in the status handler is maybe not
that important to accumulate for a long time, there is the example of mod_jk
that allows dynamic but non-persistant changes in the configuration, thus
allowing people to temporarily disable workers. Often people do thet in the
evening to prepare for updates on the next day and automatic restart scripts for
the web servers will undo those changes :(

Another solution is to allow rotatlogs to wake up by an external trigger and
then close the open file if the rotation conditions are fulfilled.

I rearranged the 2.2 rotatelogs and included a signal handler for SIGHUP, which
closes the file if size or tim conditions are met. The doesn't get immediately
opened, because it might be, that there is no need for the new file for more
than the next rotation interval.

The code seems to work fine, but maybe could be improved. I don't attach a
patch, because I moved bigger code parts into functions and thus the patch is
not really helpful. When looking at it logically, the changes mostky are:

- Move condition checks into a function
- Move Close and open into a function
- Put the config variables into a struct in order to pass them more easily
between main and functions
- The same for the dynamic status variables
- Register signal handler for SIGHUP that calls the rotation check and closes
the old file if necessary
- unblock signal only during the apr_read_file() call

I've got no idea, what needs to get changed for Windows.

The signal handling relies on the implementation detail of apr_file_read(), that
it catches any interruption in the inner read in a loop.

If there is some interest in such a solution, I would also provide 2.3 and 2.2
head based code versions.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatlogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From rainer.jung@kippdata.de  2008-02-14 17:57 -------
Created an attachment (id=21534)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21534&action=view)
Full implementation of SIGHUP handler

Based on httpd 2.2.8.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From rainer.jung@kippdata.de  2008-02-17 05:30 -------
Created an attachment (id=21549)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21549&action=view)
rotatelogs with HUP and INT handler based on trunk (r615901)


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From rainer.jung@kippdata.de  2008-02-17 05:35 -------
Inspired by the comment #2 of Kevin Connor I extended my idea to using two
different signals:

- SIGHUP as before closes the used log file, if the time or size conditions are met
- SIGINT closes the file unconditionally

In the SIGINT case when using time interval based rotation it is possible that
the new file gets opened before the time interval of the old file is over. In
this case the new file uses a file name based on the time of its opening, and
not the last start of interval. The end of use time for the file will still be
the normal interval boundary (or of course the next INT signal).

If someone wants to review this: I don't plan any more extensions, so the code
should be stable for review.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427


rainer.jung@kippdata.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Externally triggered        |Externally triggered
                   |rotatlogs rotation          |rotatelogs rotation




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From kconnor@proofpoint.com  2008-02-15 11:05 -------
I'd like this for webapp testing/debugging purposes.  It would make it easy to
find relevant log sections for a given test just by rotating the log prior to
the test.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427


rainer.jung@kippdata.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #21534|0                           |1
        is obsolete|                            |




------- Additional Comments From rainer.jung@kippdata.de  2008-02-17 05:29 -------
Created an attachment (id=21548)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=21548&action=view)
rotatelogs with HUP and INT handler based n 2.2 HEAD (r598272) 


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From rainer.jung@kippdata.de  2008-02-15 13:03 -------
Caution: the proposed change doesn not close the file unconditionally. It closes
the file only, if the rules about size or time interval given when starting up
rotatelogs are fulfilled. The only difference to standard rotatelogs is, that a
standard version does only check the rules, when a new log line is received. If
the logger is idle, then it keeps the file open indefinitly.

For your use case I would suggest a trivial enhancement: use a different signal
to unconditionally close the file. There's a caveat then: in case we use the
common interval based log rotation and we force a log rotation at some point in
time, we need to calculate the file name for the new log file in a different
way. Otherwise we would very likely overwrite the most recent file. In this case
we should use the actual timestamp instead of the beginning of the interval for
the name. That would be OK, if the two uses were seperated by using different
signals, so that the admin knows, what the result of his action would be.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 44427] - Externally triggered rotatelogs rotation

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=44427>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=44427





------- Additional Comments From kconnor@proofpoint.com  2008-02-19 11:46 -------
 Would USR1 USR2 signals be more appropriate than SIGHUP SIGINT?

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org