6.0.0-git
2019-03-19

[#13032] ActiveSync: Too many connections due to MySQL sleep processes
Summary ActiveSync: Too many connections due to MySQL sleep processes
Queue Synchronization
Queue Version Git master
Type Bug
State Resolved
Priority 3. High
Owners mrubinsk (at) horde (dot) org
Requester chrissi (at) amusing (dot) de
Created 2014-03-11 (1834 days ago)
Due
Updated 2014-03-13 (1832 days ago)
Assigned 2014-03-13 (1832 days ago)
Resolved 2014-03-13 (1832 days ago)
Milestone
Patch No

History
2014-03-13 06:34:34 chrissi (at) amusing (dot) de Comment #9 Reply to this comment
Yes, it worked! I didn't see the typo either, but after your comment I 
inserted the "hb" manually yesterday and it ran smoothly the hole night!

Thanks a lot, Michael! Your ActiveSync module rocks :D
2014-03-13 04:55:25 Michael Rubinsky Comment #8
State ⇒ Resolved
Reply to this comment
Almost positive this was the issue. I released a new package since 
I'll be mostly unavailable for the next week or so. Please reopen 
ticket if the problem persists.
2014-03-13 04:07:29 Michael Rubinsky Comment #7
State ⇒ Feedback
Reply to this comment
Does this fix?
2014-03-13 04:07:08 Git Commit Comment #6 Reply to this comment
Changes have been made in Git (master):

commit 1288a7436ba2d95159814f04e3c69264d5fa319e
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date:   Thu Mar 13 00:06:35 2014 -0400

     Fix variable name.

     Possible fix for Bug: 13032

  .../ActiveSync/lib/Horde/ActiveSync/SyncCache.php  |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

http://git.horde.org/horde-git/-/commit/1288a7436ba2d95159814f04e3c69264d5fa319e
2014-03-12 15:18:00 Michael Rubinsky Priority ⇒ 3. High
 
2014-03-12 15:17:46 Michael Rubinsky Comment #5
Assigned to Michael Rubinsky
State ⇒ Assigned
Reply to this comment
Doh. Good catch.

That's a simple typo. I'll fix when I'm back in my office.
2014-03-12 09:30:20 chrissi (at) amusing (dot) de Comment #4 Reply to this comment
Hello Michael,

I did a litte debugging by myself and stumbled across a diff in the 
Horde/ActiveSync/SyncCache.php file:

165c165
<             ($cache['lasthbsyncstarted'] > 
$this->_data['lasthbsyncstarted'])) {
---
             (!empty($cache['lastsyncstarted']) && 
$cache['lasthbsyncstarted'] > $this->_data['lasthbsyncstarted'])) {
When I use the line form the previous version

($cache['lasthbsyncstarted'] > $this->_data['lasthbsyncstarted'])) {

everything works like a charm, I tested it for 3 hours. As soon as I 
use the line from the latest version

(!empty($cache['lastsyncstarted']) && $cache['lasthbsyncstarted'] > 
$this->_data['lasthbsyncstarted'])) {

5 minutes after restarting the webserver the connection pool hits the 
150 connections limit again.

I hope this information is useful to you!

Regards, Christian

2014-03-11 15:24:04 chrissi (at) amusing (dot) de Comment #3 Reply to this comment
OK... any ideas on how to investigate this issue? My MySQL server has 
the default max_connections limit of 150, it takes about 5 minutes to 
exceed it after the update. We've got about 15 ActiveSync devices, 
Android and Apple. I could set a higher max_connections limit, but I 
don't think that's necessary, it worked just fine before the update.

Christian
2014-03-11 14:21:40 Michael Rubinsky Comment #2
State ⇒ Feedback
Priority ⇒ 1. Low
Reply to this comment
Reducing the maxheartbeat time will reduce the time the client is 
allowed to remain connected to the server. This causes the client to 
have more disconnect/reconnect cycles and uses up more battery power.

Not sure why you are seeing a change though. Nothing in the ActiveSync 
code, at least, has changed regarding the number of database 
connections required per request.
2014-03-11 10:58:53 chrissi (at) amusing (dot) de Comment #1
Type ⇒ Bug
State ⇒ Unconfirmed
Priority ⇒ 2. Medium
Summary ⇒ ActiveSync: Too many connections due to MySQL sleep processes
Queue ⇒ Synchronization
Milestone ⇒
Patch ⇒ No
Reply to this comment
Hello,

today I updated my horde packages through pear. These are the updated 
packages:

upgrade ok: channel://pear.horde.org/Horde_Browser-2.0.5
upgrade ok: channel://pear.horde.org/Horde_Url-2.2.2
upgrade ok: channel://pear.horde.org/Horde_Mime-2.3.0
upgrade ok: channel://pear.horde.org/Horde_Group-2.0.3
upgrade ok: channel://pear.horde.org/Horde_Date-2.0.8
upgrade ok: channel://pear.horde.org/Horde_Css_Parser-1.0.4
upgrade ok: channel://pear.horde.org/Horde_Http-2.0.5
upgrade ok: channel://pear.horde.org/Horde_Vfs-2.2.0
upgrade ok: channel://pear.horde.org/Horde_Autoloader-2.1.0
upgrade ok: channel://pear.horde.org/Horde_Auth-2.1.2
upgrade ok: channel://pear.horde.org/Horde_SessionHandler-2.2.4
upgrade ok: channel://pear.php.net/File_Find-1.3.3
upgrade ok: channel://pear.php.net/Text_CAPTCHA-1.0.2
upgrade ok: channel://pecl.php.net/pecl_http-1.7.6
upgrade ok: channel://pear.horde.org/Horde_Db-2.1.0
upgrade ok: channel://pear.horde.org/Horde_Form-2.0.7
upgrade ok: channel://pear.horde.org/Horde_Editor-2.0.4
upgrade ok: channel://pear.horde.org/Horde_ActiveSync-2.13.1
upgrade ok: channel://pear.horde.org/Horde_Alarm-2.1.0
upgrade ok: channel://pear.horde.org/Horde_Timezone-1.0.5
upgrade ok: channel://pear.horde.org/Horde_Crypt-2.4.1
upgrade ok: channel://pear.horde.org/Horde_Imap_Client-2.19.0
upgrade ok: channel://pear.horde.org/Horde_Dav-1.0.4
upgrade ok: channel://pear.horde.org/horde-5.1.6
upgrade ok: channel://pear.horde.org/Horde_Share-2.0.5
upgrade ok: channel://pear.horde.org/imp-6.1.7
upgrade ok: channel://pear.horde.org/nag-4.1.4
upgrade ok: channel://pear.horde.org/ingo-3.1.4
upgrade ok: channel://pear.horde.org/kronolith-4.1.5
upgrade ok: channel://pear.horde.org/turba-4.1.4
upgrade ok: channel://pear.horde.org/gollem-3.0.2
upgrade ok: channel://pear.horde.org/mnemo-4.1.3
upgrade ok: channel://pear.horde.org/webmail-5.1.4

Soon after upgrading I got the error message
"Could not instantiate PDO with DSN 
"mysql:protocol=unix;dbname=horde". PDOException: SQLSTATE[HY000] 
[1040] Too many connections"
After restarting Apache it worked, but after some minutes the error 
reappeared.
So I had a look at the MySQL processes, there were many "Sleep" 
processes originating from horde, just like this:

| 165103 | horde     | localhost       | horde       | Sleep   |  256 
|       | NULL                  |

I had a look into the ActiveSync configuration and set 
"$conf[activesync][ping][heartbeatmax]" to 120 (default was 2700), 
after that the sleeping connections were terminated after 120 seconds 
and the "too many connections" error disappeared. After resetting it 
to 2700 the problem reappears.

I'm not sure if it is a problem with ActiveSync, maybe the updated 
Horde_Db package is responsible?
Is it a problem to set the heartbeatmax value to 120 seconds? What 
could be the cause of the connection problem?

Thanks a lot in advance,
Christian Hailer

Saved Queries