Bug 25520

Summary: Corrupt log lines at high volumes
Product: Apache httpd-2 Reporter: Adam Sussman <adam.sussman>
Component: mod_log_configAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: CLOSED FIXED    
Severity: normal    
Priority: P3    
Version: 2.0-HEAD   
Target Milestone: ---   
Hardware: Other   
OS: other   

Description Adam Sussman 2003-12-15 01:10:26 UTC
mod_log_config with buffered logging turned on shows corrupted log lines when
serving at very high volumes using the worker mpm.  This is very consistent
behaviour with all recent versions of 2.0.

The problem appears to be that the per-child buffer management is not thread
safe.  There is nothing to prevent the memcpy operations in
ap_buffered_log_writer by different threads from overlapping.

Since this is a problem that happens at high volume, adding a mutex around this
isn't necessarily the most attractive option.  Also, it is unclear whether or
not a thread mutex is good enough.  mod_rewrite uses a global mutex for its logging.
Comment 1 Jeff Trawick 2003-12-18 12:43:44 UTC
A thread mutex should be good enough for handling the buffer and possibly
flushing.  Each process would be atomically appending a set of complete trace
records to the file, and that doesn't have to be handled explicitly by
mod_log_config.  With buffered logs there will be a much higher incidence of out
of order records, but that can happen already.

I wonder if the big picture is that for a threaded MPM config you're better off
shoving everything to a piped logger to handle in its simple way rather than
adding serious mutex contention to the web server.  Still, the code to make it
functionally correct is relatively simple so it should be implemented and the
user should get to decide which is more appropriate.
Comment 2 Jeff Trawick 2004-01-17 00:17:54 UTC
fix just committed to Apache 2.1-dev...  I'll propose it for backport once folks
have had a chance to look at it

Thanks for your report, and thanks for using Apache!