Bug 57746

Summary: Apache hangs on startup using MPM event
Product: Apache httpd-2 Reporter: john.swan
Component: mpm_eventAssignee: Apache HTTPD Bugs Mailing List <bugs>
Status: NEW ---    
Severity: normal CC: ylavic.dev
Priority: P2    
Version: 2.4.12   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description john.swan 2015-03-23 20:08:42 UTC
Apache threads are hanging after starting when Apache is started via one of
our daemons (Apache is forked off) and Apache is invoked with the -DFOREGROUND option.

This is on a Linux system and the event MPM is used.

It's spinning in the ap_mpm_podx_check, doing a read on a bad file descriptor
It's trying to read from FD 2, which is the error_log

#0  0x000000321ec0d9eb in read () from /lib64/libpthread.so.0
#1  0x00000000004988e1 in ap_mpm_podx_check (pod=0x1d6e43a8) at mpm_unix.c:535
#2  0x00000000005dbd67 in child_main (child_num_arg=2) at worker.c:1341
#3  0x00000000005dbf1a in make_child (s=0x1d69fa08, slot=2) at worker.c:1427
#4  0x00000000005dbfb7 in startup_children (number_to_start=1) at worker.c:1452
#5  0x00000000005dcad5 in worker_run (_pconf=0x1d674138, plog=0x1d6a7648, s=0x1d69fa08) at worker.c:1811
#6  0x0000000000466b72 in ap_run_mpm (pconf=0x1d674138, plog=0x1d6a7648, s=0x1d69fa08) at mpm_common.c:94
#7  0x000000000045ed8c in main (argc=5, argv=0x7fff8be62ac8) at main.c:777

Strace output:
read(2, 0x7fff8be625fb, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7fff8be625fb, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7fff8be625fb, 1)              = -1 EBADF (Bad file descriptor)
read(2, 0x7fff8be625fb, 1)              = -1 EBADF (Bad file descriptor)

If we run using the preform MPM everything works fine.  If Apache is run from the command line, using the event MPM, everything works fine.  It's only when we
fork off Apache from our own daemon, use the -DFOREGROUND option, and use the event MPM.
Comment 1 john.swan 2015-03-23 20:34:19 UTC
This is using Apache 2.4.12.
Comment 2 Leho Kraav @lkraav 2015-09-04 20:24:19 UTC
I seem to have something similar. Apache 2.4.16 starts spinning wheels at one unidentified point in time. Requests are still served, but the process hogs 100% CPU.

Without debug symbols

(gdb) bt
#0  0x00007f1134eccf2d in read () from /lib64/libpthread.so.0
#1  0x00000000004577b4 in ap_mpm_podx_check ()
#2  0x000000000042a474 in ?? ()
#3  0x00000000004694c7 in ?? ()
#4  0x0000000000469c12 in ?? ()
#5  0x000000000043161e in ap_run_mpm ()
#6  0x000000000042af02 in main ()

http://serverfault.com/questions/487530/find-out-what-high-cpu-usage-apache-process-is-actually-doing points me to /server-status but I can't read anything meaningful out of it just yet. Hints welcome.
Comment 3 Yann Ylavic 2015-09-04 20:52:36 UTC
What is the output of gdb's "thread apply all bt"?