Bug 62816

Summary: MaxConnectionsPerChild kills active connections
Product: Apache httpd-2 Reporter: Jason Brunette <jb9244>
Component: mpm_eventAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 2.4.35   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description Jason Brunette 2018-10-10 21:11:49 UTC
MaxConnectionsPerChild will kill any active connections/threads on the child that reaches maximum connections.

OS version:
Red Hat Enterprise Linux Server release 6.9 (Santiago)

Apache version:
Server version: Apache/2.4.35 (happens on older versions of 2.4)
Event MPM
PHP (only used for its sleep() function below)

Setup

Apache httpd.conf (yes the values are unreasonably low, but they more easily demonstrate the problem.  The problem still exists with reasonable values as long as MaxConnectionsPerChild != 0):
===================
<IfModule event.c>
ServerLimit           1
StartServers          1
ThreadsPerChild       2
MaxConnectionsPerChild 2
</IfModule>
===================

PHP test.php:
===================
<?php
sleep(100);
===================

How to reproduce (IE11 recommended, if not that then Chrome):
1. Access http://<yourserver>/test.php.  It will spin while the sleep executes.
2. Open a new browser tab and access http://<yourserver>/anythingelse. 
3. Both tabs will immediately show "Can't reach this page" or something equivalent.

IE11 demonstrates this most effectively, with both pages down for the count.

In Chrome 69, the first tab will show ERR_EMPTY_RESPONSE but will attempt to refresh itself and the second page doesn't show an error, just refreshing immediately.

Again, this isn't just because of the ridiculous httpd.conf above.  The issue still occurs with more servers, threads, etc.  The issue just occurs sporatically.
Comment 1 Phil O 2019-02-14 23:37:23 UTC
Seeing this same problem in CentOS 7.6 on Apache 2.4.38.  In our case, it actually cuts off file transfers midstream whenever the MaxConnectionsPerChild is hit.  We had it set to 1000, so it was hard to pinpoint, but if I set it to 1, a 200K file is cutoff after 24K on every request.  Looking at a packet capture, the server sends a FIN:

09:34:40.081002 IP 10.16.130.112.80 > 10.16.130.5.38958: Flags [FP.], seq 23169:24617, ack 187, win 30016, options [nop,nop,TS val 4108912187 ecr 3977453522], length 1448: HTTP

When the file transfers successfully, we reach the end:

09:34:39.972768 IP 10.16.130.112.80 > 10.16.130.5.38956: Flags [P.], seq 231681:241445, ack 187, win 30016, options [nop,nop,TS val 4108912079 ecr 3977453414], length 9764: HTTP
09:34:40.011109 IP 10.16.130.112.80 > 10.16.130.5.38956: Flags [F.], seq 241445, ack 188, win 30016, options [nop,nop,TS val 4108912117 ecr 3977453452], length 0

We are also using the Event MPM.
Comment 2 Phil O 2019-02-15 00:18:58 UTC
Just discovered that if I change this:

EnableSendfile On

to Off, the problem goes away.