Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 369635 - pecl-apc later than 3.1.6 need better locking when used with apache "worker" MPS
Summary: pecl-apc later than 3.1.6 need better locking when used with apache "worker" MPS
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: AMD64 Linux
: Normal critical (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-01 11:47 UTC by Zdravko Spoljar
Modified: 2012-04-11 16:38 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch which add handling to threads USE case (pecl-apc-3.1.9-r2.patch,581 bytes, text/plain)
2011-08-03 13:23 UTC, Zdravko Spoljar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdravko Spoljar 2011-06-01 11:47:17 UTC
i have problems when use pecl-apc greater than 3.1.6, that lock php engine in worker MPS. if used shm functions (of pecl-apc) then apache stop responding for php related content (other content may work well).
i tested both MPS (prefork and worker) with pecl-apc and found solution.
if MPS="worker" (and php is compiled with USE="threads") then is necessary to pecl-apc is compiled with option "--enable-apc-pthreadrwlocks". after that addition php/apc shm works without problem.

Reproducible: Always

Steps to Reproduce:
1. compile apache + php whith threads (apache worker mode) + pecl-apc
2. copy /usr/share/php/apc/apc.php somewhere in url space of apache
3. run: ab -n 1000 -c 30 <url to apc.php script above> # increase load if nececery

Actual Results:  
check if apc.php can be loaded from browser. in my case it just waits and never show page.



Expected Results:  
load normal apc.php page

using stable current apache/php/pecl-apc on amd64 (no multilib). tested on one dual proc/quad core server , and dual core laptop (both pure 64bit).
Comment 1 Josh G 2011-08-01 14:35:29 UTC
I see the same behavior when under load.  Also, option "--enable-mmap" should be enabled for mmap to work but isn't.

-J


Portage 2.1.10.3 (default/linux/amd64/10.0, gcc-4.4.5, glibc-2.12.2-r0, 2.6.37-gentoo-r4 x86_64)
=================================================================
System uname: Linux-2.6.37-gentoo-r4-x86_64-Intel-R-_Xeon-R-_CPU_E5410_@_2.33GHz-with-gentoo-2.0.3
Timestamp of tree: Mon, 01 Aug 2011 08:15:01 +0000
app-shells/bash:          4.1_p9
dev-lang/python:          2.6.6-r2, 2.7.1-r1, 3.1.3-r1
dev-util/cmake:           2.8.4-r1
dev-util/pkgconfig:       0.26
sys-apps/baselayout:      2.0.3
sys-apps/openrc:          0.8.3-r1
sys-apps/sandbox:         2.4
sys-devel/autoconf:       2.68
sys-devel/automake:       1.11.1
sys-devel/binutils:       2.20.1-r1
sys-devel/gcc:            4.4.5
sys-devel/gcc-config:     1.4.1-r1
sys-devel/libtool:        2.2.10
sys-devel/make:           3.82
sys-kernel/linux-headers: 2.6.36.1 (virtual/os-headers)
sys-libs/glibc:           2.12.2
Repositories: gentoo x-portage
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.2/ext-active/ /etc/php/apache2-php5.3/ext-active/ /etc/php/cgi-php5.2/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/cli-php5.2/ext-active/ /etc/php/cli-php5.3/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs buildpkg distlocks ebuild-locks fixlafiles fixpackages news parallel-fetch protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
LINGUAS="en"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.us.gentoo.org/gentoo-portage"
USE="acl alsa amd64 apache2 bzip2 cdr cli cracklib crypt ctype cxx dri fortran gdbm gpm iconv imap innodb jpeg jpeg2k mmx modules mudflap multilib mysql ncurses nls nptl nptlonly openmp oss pam pcre perl png pppd python raw readline sasl session spl sse sse2 ssl sysfs tcpd tiff unicode vhosts xorg zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="braindump flow karbon kexi kpresenter krita tables words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en" PHP_TARGETS="php5-2" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fbdev glint intel mach64 mga neomagic nouveau nv r128 radeon savage sis tdfx trident vesa via vmware dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 2 Josh G 2011-08-02 18:42:25 UTC
Here's my working ebuild that changes the locking mechanism to rwlocks which gets around the issue of apc hanging.

-J


# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-php/pecl-apc/pecl-apc-3.1.9-r1.ebuild,v 1.1 2011/07/22 12:20:48 olemarkus Exp $

EAPI=2

PHP_EXT_NAME="apc"
PHP_EXT_PECL_PKG="APC"
PHP_EXT_INI="yes"
PHP_EXT_ZENDEXT="no"
DOCS="CHANGELOG INSTALL NOTICE TECHNOTES.txt TODO"

PHP_EXT_INIFILE="${PN}.ini"

inherit php-ext-pecl-r2 confutils eutils

KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"

DESCRIPTION="A free, open, and robust framework for caching and optimizing PHP code."
LICENSE="PHP-3.01"
SLOT="0"
IUSE="mmap"

DEPEND="!dev-php/eaccelerator !dev-php/xcache"
RDEPEND="${DEPEND}"

src_configure() {
        my_conf="--enable-apc --enable-apc-pthreadrwlocks"
        enable_extension_enable "apc-mmap" "mmap" 0

        php-ext-source-r2_src_configure
}

src_install() {
        php-ext-pecl-r2_src_install

        dodir "${PHP_EXT_SHARED_DIR}"
        insinto "${PHP_EXT_SHARED_DIR}"
        doins apc.php
}

pkg_postinst() {
        elog "The apc.php file shipped with this release of PECL-APC was"
        elog "installed into ${PHP_EXT_SHARED_DIR}/."
}
Comment 3 Josh G 2011-08-02 18:43:57 UTC
Oh, regarding my first comment, I somehow didn't have the mmap use flag set. So ignore that concern.  The hangs due to locking is still valid & solved with the ebuild I posted.

-J
Comment 4 Zdravko Spoljar 2011-08-03 13:23:31 UTC
Created attachment 281951 [details]
patch which add handling to threads USE case

this patch works for me.
Comment 5 Ole Markus With (RETIRED) gentoo-dev 2011-08-03 17:05:09 UTC
apc below 3.1.9 or so caused a deadlock with certain MPMs. Do you experience this issue also with 3.1.9?

I would imagine there would be more noise if this is as common a problem as it should be based on the descriptions in this bug.
Comment 6 Josh G 2011-08-03 22:00:25 UTC
Yes, it still deadlocks under load on 3.1.9. I can replicate it every time with an "ab -n 1000 -c 50 http://address/" on all three of my server clusters - each one has it's own Gentoo build box with individualized USE flags.

I don't bother with other Apache MPM's beyond worker.  If worker is insufficient, I use Nginx.

One other thing of note is that I am running a threaded Apache & PHP environment.

-J

(In reply to comment #5)
> apc below 3.1.9 or so caused a deadlock with certain MPMs. Do you experience
> this issue also with 3.1.9?
> 
> I would imagine there would be more noise if this is as common a problem as it
> should be based on the descriptions in this bug.
Comment 7 Zdravko Spoljar 2011-08-10 09:18:31 UTC
(In reply to comment #5)
> apc below 3.1.9 or so caused a deadlock with certain MPMs. Do you experience
> this issue also with 3.1.9?
> 
> I would imagine there would be more noise if this is as common a problem as it
> should be based on the descriptions in this bug.

3.1.9 too. my proposed patch is against it.
it is not actual problem with apc code, it is problem that insufficient options  are not active (ebuild configuration).

problem arise actually only in specific circumstances:
- loaded web server
- worker mode
- apc caching 
(possibly, use shm operations in additions to just op-code caching, not tested that theory)

realistically gentoo is rare on servers (IMHO that is best usage, as you get well optimized and secure machine) which is bit rare, most ppl also don't use worker model as php is still advertised as not thread safe (really no php problem but included libraries... but ppl don't understand details), and people use other caching code (i like xcache most). that IMHO explain lack of more complaints.
Comment 8 Ole Markus With (RETIRED) gentoo-dev 2011-09-09 12:04:16 UTC
I'll add a revbump which supports the various locks.
Comment 9 Ole Markus With (RETIRED) gentoo-dev 2011-09-09 13:02:13 UTC
Try newly-committed pecl-apc-3.1.9-r2
Comment 10 Ole Markus With (RETIRED) gentoo-dev 2011-10-15 10:25:46 UTC
No complaints, so assuming this is fixed then.
Comment 11 Jonas Lihnell 2012-04-11 10:32:21 UTC
I'd like to add that switching locking mechanism by using the USE flag also solved the very same issue for me. Unless there is a good reason not to do so it would be good to set the default locking mechanism when using a threaded environment to "pthread read/write Locks locking".
Comment 12 Ole Markus With (RETIRED) gentoo-dev 2012-04-11 16:38:34 UTC
(In reply to comment #11)
> I'd like to add that switching locking mechanism by using the USE flag also
> solved the very same issue for me. Unless there is a good reason not to do
> so it would be good to set the default locking mechanism when using a
> threaded environment to "pthread read/write Locks locking".

Unfortunately there is no way to set a default USE flag based on how other packages are configured.