Plesk 9.2.2: High CPU Load , many stale greylisting executable processes

workaround, solution.

Simple Workaround for a problem (bug?) occuring on my plesk 9.2.2 server with greylisting enabled.

UPDATE 20-10-2009: Do not use this script, it does not work either!!!

To my disappointment i had to discover, that this workaround does NOT work!
It seems impossible to properly kill the hanging greylisting process. I leave the script here, maybe someone can overlook it and suggest a better solution.

Problem Description:

After upgrading my (SuSE)-Servers to Plesk Control Panel Version 9.2.2 and enabling built-in GreyListing Support one of these servers died randomly because of CPU overload.

Symptoms: Many infinitely running processes of the greylisting binary.

server#>ps ax |grep "executable" | grep -v grep
13906 ?        00:07:05 executable  
13911 ?        00:07:01 executable  
13916 ?        00:07:07 executable
13921 ?        00:07:06 executable
13926 ?        00:07:05 executable
13939 ?        00:07:02 executable

[.....] and many, many more.....

Root Cause:

Unknown to me.

The situation occurs randomly, sometimes multiple times per hour, while working completely faultless on other days.

Other people experience the same see http://forum.parallels.com/showthread.php?t=90550

I administrate other servers with nearly the same setup which do not face this problem, so i guess it has something to do with the mails examined, maybe an infinite loop while examining headers.

Workarounds that did NOT work!

Besides disabling Greylisting at all, i have tried to monitor the greylisting executable processes with a cronjob and to kill stale processes above a certain count.

This prevented the server from dying due to lack of resources, but brought up a new problem with duplicate mails, because the sender smpt-connection has already timed out at this point, the sender will therefore try again - but mail-handling delivers the first mail anyway, after greylisting process has exited.

Final Solution: A custom mail-handler

Because i assume, that the build-up of processes is caused by the initial call not exiting properly, i thought about a solution that kicks in before the greylisting executable is called and handles the error if it occurs.

How it works

My solution is basically a wrapper written in php to replace the original greylisting filter binary.
If called by plesk's qmail-queue-handlers, the wrapper in turn calls the renamed original binary as a child process and monitors it. if it exits properly, the result is passed through, if it does not exit within a certain time, the hanging child process is killed and the message passed through without modification.

How to install the wrapper script:

  1. Temporary disable Plesk greylisting in the GUI
  2. Download wrapper script below
    • gl-watchdog.zip wrapper script to monitor plesk greylisting filter processes
      zip, 16,4K, 10/17/09, 303 downloads
  3. Log into console and locate your mailhandler hooks directory, usually something like /usr/local/psa/handlers/hooks
  4. Copy original greylisting binary grey, retaining its permissions
  5. server:#> cd /usr/local/psa/handlers/hooks
    server:/u.../hooks #> cp -p grey grey.orig


  6. Edit Config Section in unpacked Script gl-wrapper.php and upload it to the hooks directory on the server.
    If you are courious and want to test the wrapper before using it, upload SAMPLE.MSG too.
  7. Overwrite grey with wrapper-script retaining original permissions.
  8. server:/u.../hooks #> cp gl-wrapper.php grey


  9. Optional: If you want to test functionality you can now call the wrapper from command line:
    server:/u.../hooks #> cp gl-wrapper.php grey
    server: #> ./grey gl-wd s1@domain.com r1@domain.com < SAMPLE.MSG
    SKIPserver:/u.../hooks #



    Notice the output SKIP, you can also examine your mail.info log. If you enabled debugging it should contain something like:
  10. Oct 17 14:57:11 mail2you greylisting watchdog[11333]:
    GreyListing Filter Watchdog: started...
    Oct 17 14:57:11 mail2you greylisting watchdog[11333]:
    greylisting filter child process started.
    Oct 17 14:57:11 mail2you greylisting filter[11334]:
    Starting greylisting filter...
    Oct 17 14:57:11 mail2you greylisting watchdog[11333]:
    greylisting filter returned after: 8.141ms with exitcode:5




  11. Optional: create writable debug_log file and enable debug, as described in the wrapper config section
  12. Finally re-enable Plesk Greylisting!!
  13. Use at your own risk!!!

Notice on Updates

Plesk update will overwrite the custom grey handler, if a new grey binary is delivered, hopefully correcting this error.
If not reinstalling the wrapper is a matter of seconds.

Comments:


Enter the Code from the image exactly as you see it.
Captcha

11/13/2009 18:23 comment #1 by james o

i was having the same problem. looks like plesk has a "hotfix" here: ***//kb.parallels.com/en/6875