kakserpom / phpdaemon

Asynchronous server-side framework for network applications implemented in PHP using libevent
http://daemon.io/
GNU Lesser General Public License v3.0
1.53k stars 231 forks source link

Warning: shmop_open(): unable to attach or create shared memory segment in (критичный баг) #194

Closed setis closed 8 years ago

setis commented 9 years ago

[Tue, 13 Jan 2015 06:04:26.594018 +0400] read 1024 from segno #4070 [Tue, 13 Jan 2015 06:04:26.594896 +0400] Warning: shmop_open(): unable to attach or create shared memory segment in /home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:83

1 PHPDaemon\Core\Daemon::errorHandler()

2 shmop_open() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:83]

3 PHPDaemon\Utils\ShmEntity->open() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Utils/ShmEntity.php:155]

4 PHPDaemon\Utils\ShmEntity->read() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Daemon.php:626]

5 PHPDaemon\Core\Daemon::getStateOfWorkers() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:139]

6 PHPDaemon\Thread\Master->callMPM() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:96]

7 PHPDaemon\Thread\Master->PHPDaemon\Thread{closure}()

8 call_user_func() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Timer.php:81]

9 PHPDaemon\Core\Timer->eventCall()

10 EventBase->dispatch() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Worker.php:254]

11 PHPDaemon\Thread\Worker->run() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Generic.php:126]

12 PHPDaemon\Thread\Generic->__invoke() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/bin/phpd:69]

[Tue, 13 Jan 2015 06:04:26.594980 +0400] Stopping 2 worker(s) [Tue, 13 Jan 2015 06:04:26.595051 +0400] --2-- #1 PHPDaemon\Thread\Master->stopWorkers() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:176]

2 PHPDaemon\Thread\Master->callMPM() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Master.php:96]

3 PHPDaemon\Thread\Master->PHPDaemon\Thread{closure}()

4 call_user_func() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Core/Timer.php:81]

5 PHPDaemon\Core\Timer->eventCall()

6 EventBase->dispatch() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Worker.php:254]

7 PHPDaemon\Thread\Worker->run() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/PHPDaemon/Thread/Generic.php:126]

8 PHPDaemon\Thread\Generic->__invoke() called at [/home/alex/NetBeansProjects/grabber/vendor/phpdaemon/bin/phpd:69]

из-за этой ошибки иногда он вешается на мертво только killall -9 php спасает, правда если приложение легкое то он нормально работает так как после 1k вызов он автоматом перезагружается приложение... но вмоем случае это критический баг он тупа открывает сегметы до 4070 смотреть выше(лог) , может я что не понимаю, или где не прочел инструкцию. я и вручную gc запускал после выполнение запроса, через htop выдно что cpu под 100% ,каждый воркер жрал а вмоем случаю 2,выснул и не на что не отвечал для разработчиков матерал №1 для разработчиков материал №2 Version PHP-5.5.9

Constants PHP Prefix: /home/alex/.phpbrew/php/php-5.5.9 PHP Binary: /home/alex/.phpbrew/php/php-5.5.9/bin/php PHP Default Include path: .:/home/alex/.phpbrew/php/php-5.5.9/lib/php PHP Include path: .:/home/alex/.phpbrew/php/php-5.5.9/lib/php

General Info phpinfo() PHP Version => 5.5.9

System => Linux alex-P5QL-PRO 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 Build Date => Jan 11 2015 00:29:11 Configure Command => './configure' '--prefix=/home/alex/.phpbrew/php/php-5.5.9' '--with-config-file-path=/home/alex/.phpbrew/php/php-5.5.9/etc' '--with-config-file-scan-dir=/home/alex/.phpbrew/php/php-5.5.9/var/db' '--with-pear=/home/alex/.phpbrew/php/php-5.5.9/lib/php' '--disable-all' '--enable-phar' '--enable-session' '--enable-short-tags' '--enable-tokenizer' '--with-zlib=/usr' '--enable-libxml' '--enable-simplexml' '--enable-xml' '--enable-xmlreader' '--enable-xmlwriter' '--with-xsl' '--with-libxml-dir=/usr' '--with-pcre-regex' '--with-pcre-dir=/usr' '--enable-sockets' '--with-mhash=/usr' '--enable-json' '--with-curl=/usr' '--enable-shmop' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-posix' '--enable-dom' '--enable-ctype' '--enable-mbstring' '--enable-mbregex' '--with-mcrypt=/usr' '--enable-filter' '--with-openssl=/usr' '--enable-pcntl' '--enable-pdo' '--with-libdir=lib/x86_64-linux-gnu' '--enable-maintainer-zts' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd' Server API => Command Line Interface Virtual Directory Support => enabled Configuration File (php.ini) Path => /home/alex/.phpbrew/php/php-5.5.9/etc Loaded Configuration File => /home/alex/.phpbrew/php/php-5.5.9/etc/php.ini Scan this dir for additional .ini files => /home/alex/.phpbrew/php/php-5.5.9/var/db Additional .ini files parsed => /home/alex/.phpbrew/php/php-5.5.9/var/db/eio.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/event.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/gd.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/gearman.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/inotify.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/mongo.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/proctitle.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/redis.ini, /home/alex/.phpbrew/php/php-5.5.9/var/db/runkit.ini

PHP API => 20121113 PHP Extension => 20121212 Zend Extension => 220121212 Zend Extension Build => API220121212,TS PHP Extension Build => API20121212,TS Debug Build => no Thread Safety => enabled Zend Signal Handling => disabled Zend Memory Manager => enabled Zend Multibyte Support => provided by mbstring IPv6 Support => enabled DTrace Support => disabled

Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, sslv3, tls Registered Stream Filters => zlib., mcrypt., mdecrypt._, string.rot13, string.toupper, string.tolower, string.striptags, convert., consumed, dechunk

This program makes use of the Zend Scripting Language Engine: Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Extensions Core, date, ereg, libxml, openssl, pcre, zlib, ctype, curl, dom, filter, hash, json, mbstring, mcrypt, SPL, session, pcntl, standard, PDO, mysqlnd, Phar, posix, Reflection, pdo_mysql, shmop, SimpleXML, sockets, mysqli, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter, xsl, eio, event, gd, gearman, inotify, mongo, proctitle, redis, runkit, mhash

Database Extensions PDO mysqlnd pdo_mysql mysqli

p.s.: если что-то нужно скинуть скажите skype:setis-0 jid:setis-0@rows.io

vodvud commented 7 years ago

Hi all! I have same problem with last version of phpdaemon.

[PHPD] Warning: shmop_open(): unable to attach or create shared memory segment in /var/www/phpdaemon/PHPDaemon/Utils/ShmEntity.php:90
#1  PHPDaemon\Core\Daemon::errorHandler()
#2  shmop_open() called at [/var/www/phpdaemon/PHPDaemon/Utils/ShmEntity.php:90]
#3  PHPDaemon\Utils\ShmEntity->open() called at [/var/www/phpdaemon/PHPDaemon/Utils/ShmEntity.php:62]
#4  PHPDaemon\Utils\ShmEntity->__construct() called at [/var/www/phpdaemon/PHPDaemon/Core/Daemon.php:438]
#5  PHPDaemon\Core\Daemon::init() called at [/var/www/phpdaemon/PHPDaemon/Core/Bootstrap.php:487]
#6  PHPDaemon\Core\Bootstrap::start() called at [/var/www/phpdaemon/PHPDaemon/Core/Bootstrap.php:309]
#7  PHPDaemon\Core\Bootstrap::init() called at [/var/www/phpdaemon/bizcontrol.php:67]

[PHPD] Couldn't open IPC-wstate  shared memory segment (key=1946224022, segsize=1024, uid=33, path = /tmp/phpd.pid).

it when I try start, daemon can't start.

php version

$ php -v
PHP 5.6.30-12~ubuntu14.04.1+deb.sury.org+1 (cli) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies

How to fix it?

tombouctou commented 7 years ago

Please check open shared memory segments ipcs -m (you could have reached shm limits, /proc/sys/kernel/shmmax//proc/sys/kernel/shmall) and permissions, can your user open /tmp/phpd.pid (possibly you run it under root previously).

vodvud commented 7 years ago

Hi! Yes, It solved problem, daemon running already.

But have one more problem with WebSocket

[Mon, 26 Jun 2017 17:25:18.797322 +0700] M#21494 \PHPDaemon\Core\Pool:Servers\WebSocket up.
[Mon, 26 Jun 2017 17:25:18.801996 +0700] M#21494 \PHPDaemon\Core\Pool:Clients\Asterisk up.
[Mon, 26 Jun 2017 17:25:18.802840 +0700] M#21494 \PHPDaemon\Core\Pool:Clients\MySQL\Pool up.
[Mon, 26 Jun 2017 17:25:18.808694 +0700] Warning: EventListener::__construct(): valid PHP stream resource expected in /var/www/phpdaemon/PHPDaemon/Core/EventLoop.php:91
#1  PHPDaemon\Core\Daemon::errorHandler()
#2  EventListener->__construct() called at [/var/www/phpdaemon/PHPDaemon/Core/EventLoop.php:91]
#3  PHPDaemon\Core\EventLoop->listener() called at [/var/www/phpdaemon/PHPDaemon/BoundSocket/Generic.php:360]
#4  PHPDaemon\BoundSocket\Generic->enable() called at [/var/www/phpdaemon/PHPDaemon/Structures/ObjectStorage.php:27]
#5  PHPDaemon\Structures\ObjectStorage->each() called at [/var/www/phpdaemon/PHPDaemon/Network/Server.php:190]
#6  PHPDaemon\Network\Server->onEnable() called at [/var/www/phpdaemon/PHPDaemon/Network/Pool.php:215]
#7  PHPDaemon\Network\Pool->enable() called at [/var/www/phpdaemon/PHPDaemon/Network/Pool.php:109]
#8  PHPDaemon\Network\Pool->onReady() called at [/var/www/phpdaemon/PHPDaemon/IPCManager/IPCManager.php:42]
#9  PHPDaemon\IPCManager\IPCManager->init() called at [/var/www/phpdaemon/PHPDaemon/Core/AppInstance.php:111]
#10 PHPDaemon\Core\AppInstance->__construct() called at [/var/www/phpdaemon/PHPDaemon/Core/AppResolver.php:89]
#11 PHPDaemon\Core\AppResolver->getInstance() called at [/var/www/phpdaemon/PHPDaemon/Core/AppResolver.php:158]
#12 PHPDaemon\Core\AppResolver->getInstanceByAppName() called at [/var/www/phpdaemon/PHPDaemon/Thread/IPC.php:101]
#13 PHPDaemon\Thread\IPC->run() called at [/var/www/phpdaemon/PHPDaemon/Thread/Generic.php:146]
#14 PHPDaemon\Thread\Generic->__invoke() called at [/var/www/phpdaemon/bizcontrol.php:64]

Unable to bind TCP-socket 127.0.0.1:9000

But it worked before moving the server

I have not idea...

kakserpom commented 7 years ago

pecl-event needs to be compiled with --enable-sockets, otherwise it only supports streams

tombouctou commented 7 years ago

@kakserpom welcome back, bro!

vodvud commented 7 years ago

Hi! Can't compiled with --enable-sockets

checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
configure: WARNING: unrecognized options: --enable-sockets
vodvud commented 7 years ago

Sorry. --enable-event-sockets Enable sockets support in Event

vodvud commented 7 years ago

Ok, sockets already open.

But I have one more error

Uncaught PHPDaemon\Exceptions\UndefinedMethodCalled (0): Call to undefined method PHPDaemon\Clients\Asterisk\Connection->command.
#0 /var/www/phpdaemon/PHPDaemon/Applications/BizSocket.php(799): PHPDaemon\Network\IOStream->__call('command', Array)
#1 /var/www/phpdaemon/PHPDaemon/Applications/BizSocket.php(799): PHPDaemon\Clients\Asterisk\Connection->command(Object(Asterisk_Action), Object(Closure))
#2 /var/www/phpdaemon/PHPDaemon/Core/CallbackWrapper.php(194): PHPDaemon\Applications\BizSocketRoute->PHPDaemon\Applications\{closure}(Object(PHPDaemon\Clients\Asterisk\Connection))
#3 /var/www/phpdaemon/PHPDaemon/Structures/StackCallbacks.php(88): PHPDaemon\Core\CallbackWrapper->__invoke(Object(PHPDaemon\Clients\Asterisk\Connection))
#4 /var/www/phpdaemon/PHPDaemon/Clients/Asterisk/Connection.php(238): PHPDaemon\Structures\StackCallbacks->executeAll(Object(PHPDaemon\Clients\Asterisk\Connection))
#5 /var/www/phpdaemon/PHPDaemon/Network/IOStream.php(784): PHPDaemon\Clients\Asterisk\Connection->onRead()
#6 [internal function]: PHPDaemon\Network\IOStream->onReadEv(Object(EventBufferEvent), NULL)
#7 /var/www/phpdaemon/PHPDaemon/Core/EventLoop.php(149): EventBase->dispatch()
#8 /var/www/phpdaemon/PHPDaemon/Thread/Worker.php(215): PHPDaemon\Core\EventLoop->run()
#9 /var/www/phpdaemon/PHPDaemon/Thread/Generic.php(146): PHPDaemon\Thread\Worker->run()
#10 /var/www/phpdaemon/bizcontrol.php(64): PHPDaemon\Thread\Generic->__invoke()
#11 {main}
kakserpom commented 7 years ago

Make sure you are calling an existing method in your application.

vodvud commented 7 years ago

You are right it is protected method https://github.com/kakserpom/phpdaemon/blob/master/PHPDaemon/Clients/Asterisk/Connection.php#L670

Ok, I'll check in my code.

Thank you.