Bug 46942 - error log messages: apr_global_mutex_lock(rewrite_log_lock) failed
Summary: error log messages: apr_global_mutex_lock(rewrite_log_lock) failed
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.2.11
Hardware: PC Linux
: P3 minor (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2009-03-31 04:27 UTC by Roland Friedwagner
Modified: 2011-09-17 16:00 UTC (History)
1 user (show)



Attachments
Remove global mod_rewrite log lock (2.99 KB, patch)
2009-06-11 04:36 UTC, Dan Poirier
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Friedwagner 2009-03-31 04:27:03 UTC
Description of problem:

On httpd graceful restart httpd error log show up this:
[Tue Mar 31 12:50:42 2009] [error] [client 127.1.2.3] (43)Identifier removed: apr_global_mutex_lock(rewrite_log_lock) failed
[Tue Mar 31 12:50:42 2009] [error] [client 127.1.2.3] (43)Identifier removed: apr_global_mutex_unlock(rewrite_log_lock) failed


Version-Release number of selected component (if applicable):

Same Error show up in 2.2.11 upstream apache httpd release


Steps to Reproduce:

0. Build test apache: ./configure --prefix=/tmp/httpd-2.2.11 --enable-mods-shared=most --enable-ssl --enable-proxy
1. Create directory /tmp/foo
2. Add (this) minimal server config foo-httpd.conf:
   --%<--
     ServerRoot "/tmp/foo"
     DocumentRoot "/tmp/foo"
     PidFile /tmp/foo/httpd.pid
     LoadModule dir_module /tmp/httpd-2.2.11/modules/mod_dir.so
     LoadModule rewrite_module /tmp/httpd-2.2.11/modules/mod_rewrite.so
     User nobody
     Group nobody
     ErrorLog  foo-error_log
     RewriteLog foo-rewrite.log

     RewriteLogLevel 1

     Listen 127.1.2.3:8765
     <VirtualHost 127.1.2.3:8765>
         ServerName foo.bar
         RewriteEngine On
         RewriteOptions Inherit
     </VirtualHost>
   --%<--
3. Start server: /tmp/httpd-2.2.11/bin/httpd -f /tmp/foo/foo-httpd.conf -k start
4. Do graceful restart: /tmp/httpd-2.2.11/bin/httpd -f /tmp/foo/foo-httpd.conf -k graceful
5. Find the apr_global_mutex_lock errors in /tmp/foo/foo-error_log
  
Additional info:
  The error messages vanish if 
    the RewriteLogLevel is set to 0
  or 
    the RewriteOptions Inherit ist _not_ set

Kind Regards,
Roland
Comment 1 Dan Poirier 2009-06-10 13:07:17 UTC
I think I've figured out what's going on (with some help from Greg Ames).  Not sure yet how to fix it.

The global mutex used by mod_rewrite to serialize writing to the rewrite log is created in post_config().  So when the parent starts its graceful restart and cleans up the old configuration, it's going to clean up - destroy - that global mutex.  Children still finishing up requests now have a reference to a mutex that no longer exists, hence attempts to lock the mutex fail.

I think the worst effect of this is the possibility that a few rewritelog messages get intermingled in the log, which isn't too important.  Still, it would be nice to figure out a way to make this work right.  Maybe somebody who knows how modules work better than I knows how to do this.
Comment 2 Joe Orton 2009-06-11 01:01:27 UTC
Ah, this was reported directly to us too - I took a look, and I can't see what the point of the logging serialisation is at all:

http://marc.info/?l=apache-httpd-dev&m=124282193217344&w=2
Comment 3 Dan Poirier 2009-06-11 04:36:01 UTC
Created attachment 23792 [details]
Remove global mod_rewrite log lock

I like it!  The Gordian knot solution.

Here's a patch against trunk to remove the lock.
Comment 4 Ruediger Pluem 2009-06-11 05:20:14 UTC
Fixed in trunk as r783734.
Comment 5 Stefan Fritsch 2011-09-17 16:00:37 UTC
2.2.12 / r792910