Forum Moderators: phranque

Message Too Old, No Replies

rewritelock with rewritemaps on shared volume

Running external rewrite maps without defining a RewriteLock is DANGEROUS!

         

BlueBlizz

8:48 am on Dec 18, 2009 (gmt 0)

10+ Year Member



Good morning,

We've goty this error:
[Wed Dec 16 21:11:49 2009] [warn] mod_rewrite: Running external rewrite maps without defining a RewriteLock is DANGEROUS!
[Wed Dec 16 21:11:49 2009] [error] (2)No such file or directory: exec of '/home/epages5/eproot/Shared/BB_special_characters.pl' failed

Let's explain our systems:
We have 2 web servers and 1 database server.
They have a shared nfs volume on the database server(/home/epages5/eproot/Shared)
On both the web server apache is configured.
Both configurations have a rewritemap to the same map-file with is located on the nfs-volume. The maps are static text-files and prg's:

RewriteMap BB prg:/home/epages5/eproot/Shared/BB_special_characters.pl

RewriteMap AmapA10 txt:/home/epages5/eproot/Shared/AnummersA10.map
RewriteMap AmapA11 txt:/home/epages5/eproot/Shared/AnummersA11.map
RewriteMap AmapA12 txt:/home/epages5/eproot/Shared/AnummersA12.map
RewriteMap AmapA13 txt:/home/epages5/eproot/Shared/AnummersA13.map
RewriteMap AmapA14 txt:/home/epages5/eproot/Shared/AnummersA14.map
...

No rewritelocks are set in the configuration.

Must there be a rewritelock file for each map-file on each server? So yes, how and where in the config file?

second: the file BB_special_characters.pl is available :
ls -lsa /home/epages5/eproot/Shared/BB_special_characters.pl
8 -rwxr-xr-x 1 ep_appl ep_web 725 Oct 15 16:12 /home/epages5/eproot/Shared/BB_special_characters.pl
it seemds to be an error due to the former warning

How to deal with this problem?
What does a rewritelock do exactly? If a map request is executed, is the map file locked for other requests? Do they have to wait?

Eric

jdMorgan

7:08 pm on Dec 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> Must there be a rewritelock file for each map-file on each server?

There must be a rewritelock file for each server instance if your RewriteMap is a script. From the mod_rewrite documentation:

RewriteLock: This directive sets the filename for a synchronization lock-file which mod_rewrite needs to communicate with RewriteMap programs. Set this lockfile to a local path (not on a NFS-mounted device) when you want to use a rewriting map-program. It is not required for other types of rewriting maps.

The lock file is needed to keep the stdin-stdout streams used to communicate with the mapping script single-threaded, so that various RewriteMap requests initiated by asynchronously-arriving HTTP requests don't end up 'mixing their characters' in these I/O streams -- with disastrous results to your URL mappings.

The Apache docs and log messages weren't written by Nanny-Staters: If they say something is dangerous, it really is dangerous.

> So yes, how and where in the config file?

Wherever your RewriteLock (mod_rewrite configuration) directive defines it as being located.

Since problem #2 may be related to problem #1, I suggest you fix the first problem by adding a RewriteLock directive and then re-test.

No harm will come if you define a RewriteLock file and don't end up using it; It's simply a way to use the OS flock function to ensure that only one HTTP request's mapping request is writing stdin or reading stdout to communicate with the mapping script at any given time.

Jim