-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mapserver not working in fcgi mode and external spawning manager #3099
Comments
|
Author: gehasia As you can see when we hit an errorfull url (because the cgi can't load the mapfile for example) mapserver is calling exit(0); The process die (apache logs it as "exit(normal exit), return code : 0" ) and then mod_fcgid has to cleanup the zombie process (!) and restart a new one. I'm not an C nor FCGI developer (or expert), but i think the process has to exit in standard CGI mode, but not in FastCGI (as process is running as a background daemon), but maybe i'm wrong. |
|
Author: pmauduit Is it then possible that the current issue is beyond the scope of mapserver ? I'm not a fastcgi / C expert either, but it seems that the exit() call is triggered into fastcgi library code, and not into mapserver. |
|
Author: pmauduit I figured out that the function loadParams from cgiutil.c did a lot of another calls to exit(), although this is the role of the function mapserv.c:main() to call exit() when necessary (mapserv.c, around line 1219), if I understood correctly. Please find attached a patch, which seems to solve the current issue. Anyway, since I'm pretty new to mapserver codebase, I don't know if I did it in a good way. Comments are welcome. Cheers, |
|
Author: pmauduit
More complicated than that, there are exit() calls from mapserv.c:writeError() to track down as well. Sorry for polluting the trac, i'll try to dig on the problem and come back when i'll be sure to have something relevant to give. |
|
Author: warmerdam |
|
Author: warmerdam There will still be fatal errors that cause the fastcgi to terminate - so the original person really ought to find a way of restarting as needed. |
|
Author: sdlime Steve |
|
Author: warmerdam That sounds reasonable to me. |
|
Author: pmauduit I sent a patch on the dev mailing-list yesterday, which actually was catastrophic (double-free, sigabrt ...) ; so I reworked my local modifications and did some better test cases (with a non-existent mapfile given in parameter, with a mapfile existing but with junk in the parameters, with a correct mapfile), I was able to get the process still working after each requests. And I actually tried a GetMap with a correct mapfile, and achieved to get a resulting image. So please find attached an update of my current work on this issue ; anyway I did not find any better solutions to track possible memory leaks than launching a "watch -n1 ps aux | grep mapserv", and see after some tests if the memory used was increasing (I've tried to launch valgrind on top of my spawn-fcgi process, but without success). I'm pretty sure that you have better solutions than that. And of course, my remarks concerning my own work made on the mailing-list did not change. I would be glad to improve it but I may need your support, comments, critics ... ;-) Cheers, Pierre |
|
Author: sdlime |
|
Author: warmerdam I don't like the duplication of error formatting logic between writeError() and the new writeErrorWithoutExit(). I dislike the proliferation of USE_FASTCGI ifdefs. I don't think the patch is comprehensive in catching errors, though I haven't reviewed this version "in context" well enough to be sure about that. I'm not really keen enough on it to apply this patch. I just don't believe in the use of a fastcgi manager that doesn't know how to restart things. But if you like you can apply it. |
|
Author: dmorissette I am also -1 on the last proposed patch... we need to find a cleaner solution, maybe through the use of configurable error handlers that could be used to trap error situations in non-CGI mode and would default to exit() in CGI mode? I don't have a solution to propose yet, just wishful thinking. |
|
Author: tbonfort
Instead of calls to exit(), child functions now return an error code, and it's up to main() to decide to print the error and eventually continue the fastcgi loop or not. |
|
Author: tbonfort |
|
attachment http://trac.osgeo.org/mapserver/attachment/ticket/3099/cgiutil.c.diff : |
|
attachment http://trac.osgeo.org/mapserver/attachment/ticket/3099/mapserv_fcgi.patch : |
Reporter: gehasia
Date: 2009/08/19 - 03:17
Trac URL: http://trac.osgeo.org/mapserver/ticket/3099
Hi,
i did some test with mapserver as fcgi + spawn-fcgi + nginx.[[BR]]
The problem is that in the case mapserver generates an error (invalid mapfile syntax or invalid mapfile path for example) the external fcgi process kill himself ! It should just send the error and keep running...[[BR]]
Here is my test case and result :[[BR]]
'''Nginx + spawn-fcgi + mapserver :'''[[BR]]
Calling valid mapfile like this : [[BR]]
http://localhost/cgi-bin/mapserv.fcgi?map=/var/mapfile.map&mod=map [[BR]]
= OK - Process Remains[[BR]]
Calling invalid mapfile like this :[[BR]]
http://localhost/cgi-bin/mapserv.fcgi?map=/var/mpfile.map&mod=map
(in this case mpfile.map does not exists) = NO OK = Throw an error but then terminate the fcgi process !! So no more fcgi process running and all others queries, valid or invalid, won't work !
'''Apache + fcgid (or fastcgi) + mapserver'''[[BR]]
= OK for both case, but this is the apache fcgi manager which relaunch the fcgi process as i can see. This is the installation documented everywhere
'''Apache + spawn-fcgi + mapserver (fcgi is called as an external process, communication done via tcp or socket)'''[[BR]]
Same results than with Nginx in first case. Valid url = OK, invalid mapfile or any other error (error in mapfile syntax ) = fcgi process get killed
So i did some test with another well known fast-cgi aka PHP ...
'''Nginx + spawn-fcgi + php5-cgi'''
Valid or invalid php file (ie : throw errors) keep the process running, so normal behavior
'''Apache + spawn-fcgi + php5-cgi''' [[BR]]
Valid or invalid php file (ie : throw errors) keep the process running, so normal behavior
The php5 cgi has a normal comportment, it throws error and keep running.
The mapserver throws error and kill himself.
I did some debug with fcgi-debug tool and here is the result if we send an invalid command to the mapserver cgi :
As you can see, there is a
but the fcgi did send the html error message correctly (and after that, died)
in a php-cgi session, you have the message but the process does not exit after (it just continues to listen).
I don't think this is a normal behavior, as with my different test case i can conclude it's not the nginx (because it does the same with apache) or spawn-fcgi (because it runs well php5-cgi -with nginx and apache-) fault. Why mapserver kill himself when it throws an error ?? Is it not the mapserver fcgi role to keep himself running and spawn fork or keep them clean ?
I can add more test case or debug info if needed !
(and i hope i do not make a mistake on who, in the fcgi world, has to keep up running and spawning process)
This affect every version i tried (Debian binary, stable source, trunk source)
The text was updated successfully, but these errors were encountered: