Ticket #1484994 (closed Bugs: worksforme)

Opened 8 months ago

Last modified 4 weeks ago

PHP Crashes and Browser freezes while searching big folder

Reported by: altex Owned by:
Priority: 7 Milestone: 0.2-stable
Component: IMAP connection Version: 0.1-stable
Severity: normal Keywords: search crash
Cc:

Description (last modified by thomasb) (diff)

Hi dear developers. First of all i want to thank you, RC is the best webmail client.

I installed RoundCube for use with gmail account through imap. My Gmail/All Mail folder consists about 31854 messages (>1Gb used space). When i use Search by this big folder my browser totally freezes.

I use

  • Fedora 8 linux on OpenVZ container
  • apache >= 2.2 (latest available in updates repository)
  • Mysql >= 5 (latest available in updates repository)
  • php >= 5.2 (latest available in updates repository)
  • php memory limit - 64Mb (setted in htaccess)
  • Firefox 2.0.0.14

In php logs there is an error, that php is failed to allocate 2048 bites (64Mb used). So please explain me why 64 Mb is too small to successfully complete search? Is RC trying to read all message's headers in memory while searching? 0_o

Thank You!

Change History

  Changed 8 months ago by altex

Error was -- PHP Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 2049 bytes) in /var/vhosts/mail/www.secure/program/lib/imap.inc on line 170

  Changed 8 months ago by altex

Linux 2.6.18-53.1.6.el5.028stab053.6 #1 SMP PHP - 5.2.4 Server API - Apache 2.0 Handler Apache/2.2.8 (Fedora) MySQL - 5.0.45

follow-up: ↓ 4   Changed 8 months ago by thomasb

  • component changed from Core functionality to IMAP connection
  • description modified (diff)
  • severity changed from major to normal

No RoundCube does not load all headers in memory, just the message index. Headers are then fetched for the number of messages you configured in "rows per page". Looks like our IMAP library missed the end of the response or the size of the result set washuge. What was the expected number of results of your search?

I can search a folder with 15'000 messages in about a second...

in reply to: ↑ 3   Changed 8 months ago by altex

Replying to thomasb:

No RoundCube does not load all headers in memory, just the message index. Headers are then fetched for the number of messages you configured in "rows per page". Looks like our IMAP library missed the end of the response or the size of the result set washuge. What was the expected number of results of your search? I can search a folder with 15'000 messages in about a second...

I trying to search small number of documents in this 30000+ folder, so a search the word "документы" and i found 15 matches within 4 seconds. But when the result matches more than hundreds i get low memory error.

  Changed 7 months ago by alec

  • milestone changed from later to 0.1.2

  Changed 3 months ago by chugadie

It's easy to reproduce this behavior by using htaccess files to limit the memory to 1M and then searching.

To make the system not feel like it's "freezing", the ajax command should be ASYNC

in app.js add "true" as a 3rd parameter to open()

3716 this.xmlhttp.onreadystatechange = function(){ _ref.xmlhttp_onreadystatechange(); }; 3717 this.xmlhttp.open('GET', url, true); <-- async flag 3718 this.xmlhttp.setRequestHeader('X-RoundCube-Referer', bw.get_cookie('roundcube_sessid')); 3719 this.xmlhttp.send(null); 3720 };

Also, to gracefully recover from this error, we could add a nice error box to "http_error" in app.js

3550 request_obj.reset(); 3551 request_obj.lock = false; 3552 this.display_message('Unknown Serer Error!', 'error'); <-- nice error box 3553 };

This should at least make RC look like it's not completely non-functional when the server encounters some unexpected error. I can happily change my memory back up and continue using the system.

  Changed 3 months ago by chugadie

fix code formatting for the previous comment

in app.js add "true" as a 3rd parameter to open()

  3716     this.xmlhttp.onreadystatechange = function(){ _ref.xmlhttp_onreadystatechange(); };
  3717     this.xmlhttp.open('GET', url, true);
  3718     this.xmlhttp.setRequestHeader('X-RoundCube-Referer', bw.get_cookie('roundcube_sessid'));
  3719     this.xmlhttp.send(null);
  3720     };

Also, to gracefully recover from this error, we could add a nice error box to "http_error" in app.js

  3550     request_obj.reset();
  3551     request_obj.__lock = false;
  3552     this.display_message('Unknown Serer Error!', 'error');
  3553     };
  3554

  Changed 3 months ago by thomasb

Applied the suggested patch in r1758

  Changed 8 weeks ago by alec

To altex, there are some fixes in imap library in svn-trunk version which may fix your issue. Please, try it.

  Changed 4 weeks ago by alec

  • status changed from new to closed
  • resolution set to worksforme

Old, no feedback.

Note: See TracTickets for help on using tickets.