core icon indicating copy to clipboard operation
core copied to clipboard

Owncloud 5: server is spawning apache workers till it drops

Open halfgaar opened this issue 13 years ago • 16 comments

We upgraded to owncloud 5 and with only 4 users, I had 16 apache workers using all 4 cores of my server to 100%. And for the fourth user I installed, the sync client said "waiting to synchronise" a lot longer (500 seconds or so) than the first one (almost immediately). It was like it kept waiting for the server.

Currently, the server has been running for a few hours and all 30 available apache slots are used up (nothing works anymore because of it):

Apache Server Status for localhost

Server Version: Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.6 with Suhosin-Patch
    mod_ssl/2.2.22 OpenSSL/1.0.1
Server Built: Nov 8 2012 21:37:30

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Current Time: Thursday, 21-Mar-2013 16:22:59 CET
Restart Time: Wednesday, 20-Mar-2013 23:23:09 CET
Parent Server Generation: 0
Server uptime: 16 hours 59 minutes 49 seconds
Total accesses: 25346 - Total Traffic: 13.3 MB
CPU Usage: u26116.8 s423.89 cu.12 cs0 - 43.4% CPU load
.414 requests/sec - 227 B/second - 549 B/request
30 requests currently being processed, 0 idle workers

WWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

Load average: 20.36, 20.58, 15.62

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  622 mysql     20   0 2341m  99m 3680 S   32  6.7  34:24.14 mysqld
 8921 www-data  20   0  326m  40m 5352 R   19  2.7   2:59.74 apache2
 7026 www-data  20   0  312m  28m 6808 R   18  1.9   2:31.51 apache2
19249 www-data  20   0  362m  75m 4864 R   18  5.1 150:16.33 apache2
 7025 www-data  20   0  322m  38m 6796 R   17  2.6   3:51.95 apache2
 3974 www-data  20   0  337m  53m 6792 R   16  3.6   6:34.39 apache2
24111 www-data  20   0  349m  63m 5024 S   16  4.3  12:10.70 apache2
 1192 www-data  20   0  319m  33m 5468 S   16  2.3   3:21.62 apache2
 3149 www-data  20   0  339m  55m 6588 R   16  3.7   6:49.68 apache2
 7046 www-data  20   0  327m  41m 5180 R   16  2.8   3:18.51 apache2
 9536 www-data  20   0  318m  32m 5364 R   16  2.2   1:50.98 apache2
 1191 www-data  20   0  313m  29m 6820 R   15  2.0   3:41.87 apache2
 6970 www-data  20   0  322m  37m 5180 R   15  2.5   2:40.62 apache2
19242 www-data  20   0  319m  33m 7764 R   15  2.3   3:14.12 apache2
19248 www-data  20   0  333m  48m 5580 R   15  3.2   6:17.33 apache2
19250 www-data  20   0  581m 292m 4800 R   15 19.6  99:21.09 apache2
 9492 www-data  20   0  316m  30m 5412 R   15  2.0   1:33.28 apache2
 5947 www-data  20   0  341m  56m 5180 R   15  3.8   6:46.88 apache2
 6453 www-data  20   0  306m  22m 6816 R   14  1.5   0:48.47 apache2
19245 www-data  20   0  331m  45m 5332 R   14  3.1 125:02.16 apache2
 1190 www-data  20   0  350m  66m 6684 R   14  4.5  70:26.11 apache2
 2695 www-data  20   0  346m  61m 5384 R   14  4.1   7:41.66 apache2
19247 www-data  20   0  349m  65m 6812 R   14  4.4   9:55.37 apache2
 9494 www-data  20   0  320m  35m 5356 R   13  2.4   2:17.18 apache2
 7185 www-data  20   0  328m  41m 5088 R   13  2.8   3:36.00 apache2

When I did a graceful restart on apache, apache status shows a lot of workers hanging in 'gracefully restarting' a long time, so I guess the processes are hanging.

We're making use of shared files a lot. One user has files, the others only access those files through the sharing mechanism.

I wish I could tell you more, but attaching a debugger to a mod_php apache process is kind of hard...

PHP 5.3.10-1ubuntu3.6 Ubuntu 12.04 LTS Syncclient 1.2.1, on windows.

Edit: I've been gracefully restarting my apache for about 15 minutes now, and they're all stuck in "G" (gracefully restarting).

halfgaar avatar Mar 21 '13 15:03 halfgaar

I have the same problem. It happens when i'm trying to sync a folder, which one is never sync : owncloud adds and removes its files and never sync the whole folder.

dadall avatar Mar 21 '13 16:03 dadall

I have the same problem, heres my post where I explain all the details:

http://forum.owncloud.org/viewtopic.php?f=23&t=9403&p=23268#p23268

I think the problem is close_wait which never gets its ACK because of a bug somewhere in owncloud.

dednenes avatar Mar 21 '13 19:03 dednenes

Similar problem here, hat to restart apache over and over again.

ajeitler avatar Mar 21 '13 19:03 ajeitler

I was experiencing this same issue earlier as well but have not seen it re-appear in several hours after having implemented the patched updater.php and group_ldap.php files found in issue 2474. I don't believe the issues they were intended to fix had anything to do with the sync client, specifically, but my symptoms were nearly identical to the ones you describe above. After running for 4 hours I observed 171 apache processes and mysqld was utilizing 4GB of RAM and 100% CPU.

tedwardd avatar Mar 21 '13 19:03 tedwardd

It seems very plausible that #2474 is this bug, because we share everything to groups. I'll see about applying the patch.

halfgaar avatar Mar 22 '13 12:03 halfgaar

@halfgaar btw, thanks for your good bug reports ;) there are far to less good ones.

BernhardPosselt avatar Mar 22 '13 23:03 BernhardPosselt

It quite alright. I just apologize for my eternal stuggle in bug trackers to never find duplicates. Depite my searching, it still happens.

Anyway, I applied the patch (only the update.php one; I don't use ldap) and the server remains stable. The shares seem to sync as well.

halfgaar avatar Mar 23 '13 06:03 halfgaar

This issue continues to exist in version 5.0.3. Just had to restart apache

lazev3do avatar Apr 05 '13 08:04 lazev3do

@halfgaar thanks for your report. Important infos like more detailed setup and logs are missing, please add. Best, make use of the template – Thank You!

https://github.com/owncloud/core/blob/master/CONTRIBUTING.md

blizzz avatar Apr 05 '13 11:04 blizzz

Well, because the problem no longer happens for me, I think @lazev3do is a better person to supply this information.

halfgaar avatar Apr 05 '13 13:04 halfgaar

I have been seeing this issue with 5.0.8 which already has 2474 applied. Instead of sharing based on LDAP group I was instead sharing based on LDAP user. That seemed slightly better but I still ran into this issue and problems with my clients not syncing correctly every time. Disabling LDAP completely and instead settle up local accounts all my issues seem to have disappeared.

mlg9000 avatar Jul 14 '13 17:07 mlg9000

I seems that the Apache processes wait for the LDAP server, or something else. Is there something in the ldap, owncloud, apache logs? does the ownCloud work correctly beside this issue? I assume that there is a configuration error somewhere.

karlitschek avatar Jul 15 '13 07:07 karlitschek

There is nothing in the LDAP logs and it continues to work fine for the dozen other things I have configured to use it. Owncloud works fine with LDAP functionally but never closes connections and eventually kills apache. The clients will also fail to update ~50-75% of the time. There is nothing in the owncloud logs up until around the time it crashes:

{"app":"user_ldap","message":"Bind failed: -1: Can't contact LDAP server","level":3,"time":1373668869} {"app":"user_ldap","message":"Connection could not be established","level":3,"time":1373668869}

The LDAP is up and running when these were logged.

mlg9000 avatar Jul 15 '13 19:07 mlg9000

ownCloud closes the LDAP connection in the destructor of the respective class https://github.com/owncloud/core/blob/stable5/apps/user_ldap/lib/connection.php#L87

@mig9000 how to reproduce the behaviour?

blizzz avatar Jul 15 '13 22:07 blizzz

To reproduce the issue I only have to enable LDAP and leave a client running that uses an LDAP account. The client will error out frequently but still work and it will eventually knock apache over without producing anything useful in a log file that could be used to narrow the issue down. Apache shows "server reached MaxRequestWorkers setting" in the logs, which is a result of owncloud connections not closing, not load or config settings being too low. LDAP logs show nothing and seem totally unaffected by any of this as the dozen other things that use it for auth all work. Owncloud shows nothing in the logs right up until the end, just showing the above errors that don't really make sense unless it's trying to connect to a backup ldap server which I do not have configured.

As far as LDAP goes this is a 389 directory server. The config settings as pulled from MySQL are listed below (sanitized). If it's not listed it's empty. These config settings all appear to work fully.

ldap_backup_port=389 ldap_base=dc=example,dc=com ldap_base_groups=dc=example,dc=com ldap_cache_ttl=600 ldap_display_name=cn ldap_email_attr=mail ldap_expert_username_attr=uid ldap_group_display_name=cn ldap_group_filter=objectClass=posixGroup ldap_group_member_assoc_attribute=uniqueMember ldap_host=127.0.0.1 ldap_login_filter=uid=%uid ldap_port=389 ldap_tls=1 ldap_turn_off_cert_check=1 ldap_userlist_filter=postalCode=55555 ldap_uuid_attribute=nsuniqueid

mlg9000 avatar Jul 16 '13 05:07 mlg9000

This sounds like an configuration issue. Is it possible that the ldap server has a limit of maximum connections that is lower than the maximum number of apache/php/owncloud processed? The ldap server connection ttl has to be taken into account too. This works just fine in a lot of other scenarios so I assume the LDAP server here is somehow slowing down php/owncloud which will lead to the high number of blocking processes/connections.

karlitschek avatar Oct 17 '13 13:10 karlitschek