Author Topic: many timeouts in imap.inc  (Read 8420 times)

Offline kapitan

  • Newbie
  • *
  • Posts: 7
many timeouts in imap.inc
« on: September 30, 2008, 04:57:35 AM »
Hi,

I installed recently roundcube v0.2-beta (instead of squirrelmail)
And i noticed that almost all the time my httpd (apache 2.2) consumes 100% CPU.

Probably the reason is communication with imap server (separate machine), in the logs I can see:
# grep  'Maximum execution time of' logs/errors
[24-wrz-2008 18:55:51] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 274
[24-wrz-2008 18:56:13] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 758
[24-wrz-2008 18:59:38] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 758
[24-wrz-2008 18:59:41] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 759
[24-wrz-2008 19:00:10] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[24-Sep-2008 20:36:12] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 758
[24-wrz-2008 20:40:43] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 759
[24-wrz-2008 20:44:20] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 771
[24-wrz-2008 20:59:19] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 760
[24-wrz-2008 23:21:51] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 273
[24-wrz-2008 23:23:19] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 273
[25-wrz-2008 08:46:31] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 275
[25-wrz-2008 08:46:34] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 209
[25-wrz-2008 15:07:52] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[26-wrz-2008 10:01:20] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[26-wrz-2008 13:24:11] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 758
[26-wrz-2008 13:24:23] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 771
[26-wrz-2008 13:24:26] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 760
[26-wrz-2008 13:24:32] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 275
[26-wrz-2008 13:24:35] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 759
[26-wrz-2008 13:24:49] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 2384
[26-wrz-2008 13:26:13] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 274
[26-wrz-2008 16:26:17] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[26-wrz-2008 16:26:35] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 759
[26-wrz-2008 16:26:37] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 208
[26-wrz-2008 16:29:14] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[26-wrz-2008 16:29:20] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 758
[26-wrz-2008 18:52:12] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 197
[29-wrz-2008 10:53:25] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 221
[29-wrz-2008 14:00:01] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 771
[30-wrz-2008 08:49:29] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 771
[30-wrz-2008 08:49:39] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 760
[30-wrz-2008 08:49:49] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 2384
[30-wrz-2008 08:49:54] PHP Fatal error:  Maximum execution time of 120 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 759


There were not such problems with squirrelmail before, also users connecting IMAP directly don't have problems, so it seems that the IMAP server works correctly.

Any Ideas?

BR,
Maciej M.

Offline kapitan

  • Newbie
  • *
  • Posts: 7
one fix
« Reply #1 on: September 30, 2008, 10:44:21 AM »
Hi,

Problem with the imap exists, but I fixed the 100% CPU load.
In the ./program/steps/mail/get.inc there is:

if (!ini_get('safe_mode')) {
    set_time_limit(0);
}
[...]
$IMAP->get_message_part($MESSAGE->uid, $part->mime_id, $part, true);
 

When I changed the limit to 300, errors like this started to appear in the logs:
[30-wrz-2008 16:32:48] PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 771
[30-wrz-2008 16:33:04] PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 278
[30-wrz-2008 16:33:59] PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768
[30-wrz-2008 16:34:13] PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 278
[30-wrz-2008 16:34:19] PHP Fatal error:  Maximum execution time of 300 seconds exceeded in /var/www/poczta/program/lib/imap.inc on line 768

So at least my server is not overloaded.

Of course it is not a solution, but I guess we should not set the time limit to infinity.

BR,
Maciej M.

Offline NEComputer

  • Newbie
  • *
  • Posts: 5
many timeouts in imap.inc
« Reply #2 on: September 30, 2008, 05:10:10 PM »
This is interesting... Can you provide more specifics of the setup in which your using RC with? Apache Version? PHP Version? MySQL Version? etc. I have found a few instances of this but I myself have not ran into the same problem. I would like to help but need more info.

-Pat

Offline kapitan

  • Newbie
  • *
  • Posts: 7
many timeouts in imap.inc
« Reply #3 on: October 01, 2008, 04:24:29 AM »
It is v0.2-beta downloaded from the main page.

There are two machines:


First: (roundcube) Centos 5.2:

PHP Version 5.2.6 (compiled)
'./configure' '--with-config-file-path=/etc/httpd' '--with-mysql' '--with-apxs2' '--with-imap' '--with-gettext' '--with-zlib-dir' '--with-kerberos' '--with-imap-ssl' '--enable-mbstring' '--with-openssl' '--with-mcrypt' '--with-gd' '--with-png-dir' '--with-jpeg-dir'

Apache/2.2.3
Mysql 5.0.45
libc-client-2004g-2.2.


Second: (mailserver) Slackware 8.0
UW IMAP4rev1 2004.357
sendmail-8.13.7


Both of them are in the same sub-network, so there are no delays in communication.

BR,
Maciej M.
« Last Edit: October 01, 2008, 04:27:42 AM by kapitan »

Offline hett

  • Newbie
  • *
  • Posts: 2
same problem
« Reply #4 on: October 01, 2008, 10:17:21 AM »
I'm experiencing the same problem.

It's not related to v0.2-beta, as I had it with at least the previous two roundcube.net announced releases.
It's not related to apache/php version or configuration as I can see the problem still exists in configurations ranging from php 4.3 as apache 1.3.33 module to php 5.2 ran in (fast)cgi mode through lighttpd 1.4.19.

The latest configuration that still experiences the problem is:

php through FastCGI: PHP 5.2.6-0.dotdeb.1 with Suhosin-Patch 0.9.6.2 (cgi-fcgi) (built: May 15 2008 12:52:11)
lighttpd: 1.4.19 built from source.
roundcube: v0.2-beta

From my observations all the php5-cgi processes that start eating as much CPU as they can have gotten to net state CLOSE_WAIT(1) while talking to the IMAP server. At least on that particular box those processes can't be straced at all, strace just can't attach to the process.

IMAP server that Roundcube is talking to is Nginx in proxy mode which in turn is talking to courier imap behind the scenes.

Seeing this makes me thing the problem lies in the imap library (imap.inc) that Roundcube borrowed from IlohaMail and didn't used the standard php imap functions.

While checking Roundcube's mailing lists I've stumbled upon a user submitted patch(2) against imap.inc that tries to fix the above-mentioned-like problem. Unfortunately it led to no success in my situation.


1. SUMMARY: How to break CLOSE_WAIT
2. Re: [RCD] More info: httpd using 100% cpu...

Offline kapitan

  • Newbie
  • *
  • Posts: 7
some traces from xdebug
« Reply #5 on: October 01, 2008, 10:25:05 AM »
Hi.

Here you are some stack traces that were produced with xdebug.



It seems to me that loop in the iil_C_Select() can be infinite.


BR,
Maciej M.

Offline hett

  • Newbie
  • *
  • Posts: 2
many timeouts in imap.inc
« Reply #6 on: October 02, 2008, 03:12:53 AM »
no word from the roundcube team on the subject?

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
many timeouts in imap.inc
« Reply #7 on: October 08, 2008, 03:08:26 AM »
please try to get help @ trac.roundcube.net. the devs are not or at least not very often here.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline kapitan

  • Newbie
  • *
  • Posts: 7
many timeouts in imap.inc
« Reply #8 on: October 08, 2008, 09:56:41 AM »
Hi,

Tried to send emails to:

help at trac.roundcube.net

and

dev at lists.roundcube.net


without success, both were rejected by the MTA.


BR,
Maciej M.

Offline rosali

  • Hero Member
  • *****
  • Posts: 2,533
many timeouts in imap.inc
« Reply #9 on: October 09, 2008, 02:39:03 AM »
RoundCube Webmail ? Trac !!! It´s not a mailing list. You can  release there a ticket for your issue.
Regards,
Rosali
__________________
MyRoundcube Project (commercial)

Offline kapitan

  • Newbie
  • *
  • Posts: 7
many timeouts in imap.inc
« Reply #10 on: October 09, 2008, 04:55:13 AM »
ok,

I gave up.
Maybe I'll come back to try roundcube later.


BR,
Maciek