Roundcube Community Forum

Release Support => Pending Issues => Topic started by: no1knows on December 02, 2009, 07:21:01 AM

Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 07:21:01 AM
I am using RoundCube 0.3.1 as a client for Gmail on my Fedora 11 box w/ Apache 2.2.13, PHP 5.2.11 and Mysql 5.1.37.

It works great for most users but not for my personal account.

Essentially, some time (overnight) following the creation of me as a user on RoundCube I can no longer login and the connection times-out with the following message after I enter my user/pass:

500 Server Error
The following error occurred: [code=SERVER_RESPONSE_CLOSE] The server closed the connection while reading the response. Contact your system administrator.
Could not open error file

No errors appear in the Apache or RoundCube logs. But an entry in the Session table is successfully created.

If i edit the database entries for my user and then re-login (thereby creating another new user) it works fine until the next day when the problem repeats itself.

I can fix this, by making RoudCube treat me as a new user every day (in which case I can log in as usual immediately) but would prefer a real solution!

This happens with caching enabled or disabled.

Any help would be appreciated, happy to post config files if you think it would help (my PHP.ini execution timeout is currently 600s so its not that!).
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 02, 2009, 07:24:07 AM
Is the RoundCube logs directory writable?
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 07:48:16 AM
Hi Skaero,

Yes the log files are writeable - they contains various unrelated entries. I was logging IMAP for a while but nothing seemed to be out of the ordinary, successful logins from Gimap e.t.c. but RoundCube would still timeout.

Forgot to mention, mysql is on local machine, IMAP is obviously remote. But given that ti works fine for other users, I can't think its a problem with connectivity or delayed connections.
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 02, 2009, 07:55:06 AM
It sound like this problem: http://www.roundcubeforum.net/pending-issues/5431-gmail-roundcube-dreamhost-internal-server-error.html
Try with that latest SVN and see if it works.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 08:00:55 AM
Sounds about right, let me give it a go, I'll report back.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 08:18:44 AM
Upgraded to Version 0.3-20090814 using UPGRADING instructions and same symptoms :(

The update.sh says "This instance of RoundCube is up-to-date." after I re-ran the installer.

Seems strange that when I am a new user it works fine for a day...

Is it worth me trying a fresh copy of the SVN (i.e. not upgrading?)
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 02, 2009, 08:29:11 AM
I'd try a fresh install of the SVN the version you where using 8-14-2009 is older that RoundCube 3.1 witch was released 10-31-2009
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 08:31:10 AM
That is the current version in the trunk according to the top of the index.php file:

> head /var/www/html/trunk/roundcubemail/index.php
/*
 +-------------------------------------------------------------------------+
 | RoundCube Webmail IMAP Client                                           |
 | Version 0.3-20090814                                                    |

I will try a fresh install but have a feeling it'll work to start with, and I'll be back tomorrow when it starts timing out again :)
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 02, 2009, 08:37:06 AM
Ah sorry I forgot ticket 1484766 #1484766 (Version tag incorrect) ? Roundcube Webmail (http://trac.roundcube.net/ticket/1484766) BTW how many emails do you have on the account that your trying to login to?
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 02, 2009, 08:45:18 AM
ahah :)

17,919 emails in total... obviously split among several folders. But if it was the number of emails, surely it wouldn't work at all as opposed to working for a day then having a brain fart?

So far so good on the fresh SVN install and new database. I'll let you know if it starts timing out again tomorrow. Trying preview pane - nice feature.

Thanks for the help!
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 02, 2009, 08:53:50 AM
True, let me know if it starts timing out again.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 04:44:31 AM
Bad news I'm afraid SKaero - its timing out again today...

Any ideas?

TIA

[edit] please feel free to move this to SVN forum (although the problem does exist in SVN and stable builds) [/edit]
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 08:24:42 AM
You said that when you delete the user in the database it goes away so its most likely something in the database. Does it work if you clear the session table?
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 08:54:22 AM
clearing session table does not help. If I modify the old user's email address and then login (thereby creating a new username as none match the email address) it works fine for the day...

Do you think it might be a cron job amending the database or something? I'll keep trying to find out at what point it stops working.

Would there be anyway to get a log entry out of it as to what is causing the timeout?

[edit] just tried it on your server (http://mail.skaero.com/), no luck, get the same error (would you mind checking your logs?) [/edit]
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 09:57:24 AM
I have logs! It looks to be a cache error, have you tried clearing the cache table?
Code: [Select]

[03-Dec-2009 08:45:13 -0600]: DB Error: _doQuery: [Error message: Could not execute statement]
[Last executed query: PREPARE mdb2_statement_mysql_66210accae1f73d927aef0aa41d895f58d102a120 FROM 'SELECT idx, uid\n       FROM messages\n       WHERE  user_id=?\n       AND    cache_key=?\n       ORDER BY `idx` ASC']
[Native code: 2006]
[Native message: MySQL server has gone away]
 in /home/skaeroco/mail.skaero.com/program/include/rcube_mdb2.php on line 269 (GET /?_task=mail)
[03-Dec-2009 08:45:13] MDB2 Error: unknown error (-1): _doQuery: [Error message: Could not execute statement]
[Last executed query: PREPARE mdb2_statement_mysql_7048eb189dd6d6bc46074370ecc06884b70285e92 FROM 'SELECT cache_id\n         FROM cache\n         WHERE  user_id=?\n         AND    cache_key=?']
[Native code: 2006]
[Native message: MySQL server has gone away]

[03-Dec-2009 08:45:13 -0600]: DB Error: _doQuery: [Error message: Could not execute statement]
[Last executed query: PREPARE mdb2_statement_mysql_7048eb189dd6d6bc46074370ecc06884b70285e92 FROM 'SELECT cache_id\n         FROM cache\n         WHERE  user_id=?\n         AND    cache_key=?']
[Native code: 2006]
[Native message: MySQL server has gone away]
 in /home/skaeroco/mail.skaero.com/program/include/rcube_mdb2.php on line 269 (GET /?_task=mail)
[03-Dec-2009 08:45:13] MDB2 Error: unknown error (-1): connect: [Error message: Could not select the database: skaeroco_mail]
[Last executed query: PREPARE mdb2_statement_mysql_7048eb189dd6d6bc46074370ecc06884b70285e92 FROM 'SELECT cache_id\n         FROM cache\n         WHERE  user_id=?\n         AND    cache_key=?']
[Native code: 2006]
[Native message: MySQL server has gone away]

[03-Dec-2009 08:45:13 -0600]: DB Error: connect: [Error message: Could not select the database: skaeroco_mail]
[Last executed query: PREPARE mdb2_statement_mysql_7048eb189dd6d6bc46074370ecc06884b70285e92 FROM 'SELECT cache_id\n         FROM cache\n         WHERE  user_id=?\n         AND    cache_key=?']
[Native code: 2006]
[Native message: MySQL server has gone away]
 in /home/skaeroco/mail.skaero.com/program/include/rcube_mdb2.php on line 269 (GET /?_task=mail)

Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 10:04:38 AM
Nice, could be getting somewhere! I had tried, I will try again. But the problem seemed to exist even with cache disabled.

[edit]No luck with an empty cache table - should I empty the messages table to?
It seems during the timeout that the Messages table is updated with the latest emails, although no entries are made in the cache table.
[/edit]
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 10:08:43 AM
I checked my database and there were no cache for your user, looking at the query in the error there is "\n" and ? that shouldn't be there it looks like it querying the database when it shouldn't be.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 10:22:30 AM
Ahah... weird that it only occurs after the user is X hours old on my server...

But I am a new user on your server and its broken from the get-go.
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 11:22:53 AM
True, but my server is still running 0.3 if you the $rcmail_config['debug_level'] to 8 in the main.inc.php does anything show up in the console.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 11:31:55 AM
nothing in the console, just stays blank then goes to the 500 error page.

The console file in the logs directory contains this:

Code: [Select]
[03-Dec-2009 16:31:27 +0000]: * OK Gimap ready for requests from 78.105.63.52 i6if192184gve.16
AUTH PLAIN: Resource id #87
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 11:58:41 AM
Ok no new info there, try login on on my server again I made some changes where the error code was let me know if you can get in.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 12:08:17 PM
I'm in on your server!!!
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 03, 2009, 12:20:35 PM
Its a start! Hopefully it keeps working, let me know if it stops working.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 03, 2009, 12:26:16 PM
ok, let me know what changes you made and I'll try the same on mine?
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 04:19:23 AM
SKaero - I tried again this morning on your server and its working!

Would you mind letting me know what amends you made?
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 04, 2009, 07:01:04 AM
Sure, remember that the one on my site is a mix of versions try at your own risk :rolleyes: I also have caching enabled. I removed the code that was causing the error forcing it not get a cache key witch seams to be where it was hanging.

Edited the [RC root]/program/include/rcube_imap.php

Fine:
Code: [Select]

// get cache entry ID for this key


Replace:
Code: [Select]

$sql_result = $this->db->query(
"SELECT cache_id
FROM ".get_table_name('cache')."
WHERE  user_id=?
AND    cache_key=?",
$_SESSION['user_id'],
'IMAP.'.$key);


With:
Code: [Select]

$sql_result = '';
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 07:30:29 AM
ok, done that - but still timing out... :mad:

where did you get your logs from? apache error_log? I don't get any entries.

This is incredibly frustrating! Hopefully if I can find some logs we can find the culprit in the SVN!

[edit] found this in the error_log:

Code: [Select]
[Fri Dec 04 12:42:49 2009] [error] [client 80.254.146.52] PHP Fatal error:  Call to a member function fetchRow() on a non-object in /var/www/html/webmail/program/include/rcube_mdb2.php on line 386, referer: http://ldn.no1knows.com/webmail/

This is as a result of the above amend I believe... [/edit]
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 04, 2009, 07:45:10 AM
I forgot to say I did remove you from the database when I made the changes. I had that log entry one as well, but everything else still works.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 07:57:37 AM
Ah, so you removed me from the database today? that explains why its working then... if you leave me there then tomorrow it will timeout...
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 04, 2009, 08:30:49 AM
I removed you from the database yesterday before you where able to login on my server the first time.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 09:17:36 AM
oh I see.. how did you remove me? Just by changing the email address for my user?

If I try to delete my user row I get mysql errors.
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 04, 2009, 09:30:20 AM
I did it the hard way, I checked the user_id then deleted the all of the other fields in the database that had the same user_id then you can delete the the user.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 10:22:05 AM
ahah :)

ok I've done the same, so far so good but it may break tomorrow again!

are there any side-effects do you think? I will hide the error for now, unless it can be fixed?
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 04, 2009, 10:34:25 AM
I would teen to say that caching isn't going to work, however if it does fix the problem we can back track and find the point that its being called at and hopefully fine a better fix. If it doesn't work on your server check and see if does on mine, if it does then we will have more to work with.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 04, 2009, 11:17:46 AM
Righto, I'll report back tomorrow on my findings!
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 05, 2009, 06:01:44 AM
Skaero - both servers seem to be working as expected now... which is good!

The above error is presumably showing up in your logs too (and caching not working?). Where can we go from here?

Cheers
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 05, 2009, 08:33:48 AM
Well that's good news! I am not getting that error on my server, but it may be because my mixed versions. I have been looking at whats happening and it doesn't seem to break caching. What does seam to be affected is the message count, when you login on my server 3 IMAP.messagecount records are created and instead of updating it next time you login it makes 3 new ones. That's going to be a rather big problem for your database because it does it for each user. Does your server do the same thing? I am still looking into it and trying to track the problem.
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 05, 2009, 10:26:05 AM
If you mean there are a lot of duplicate entries in the message table for each email then yes, I get the same...

Oh, i see where you mean, in the cache table. Yep, I am getting 3 entries each time I login...
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 05, 2009, 11:19:37 AM
If you disable caching does the error message go away, and is it only when you login?
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 05, 2009, 12:19:25 PM
It does seem to only be on login... (i.e. if i refresh it goes away (when debug level is 4)).

It does not appear when caching is disabled...
Title: 500 Server Error for some users after working fine for a day.
Post by: no1knows on December 07, 2009, 10:04:23 AM
any ideas SKaero?
Title: 500 Server Error for some users after working fine for a day.
Post by: SKaero on December 15, 2009, 10:00:27 AM
Sorry for my delay in replying, I have look at the code and have run out of ideas. I would need to to the variables that are getting passed around to find out why if failing. You could try using the debug_logger plugin and see if it comes up I haven't used it before so I don't know how well it will work.