Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

multiple workers cannot have names that start with the same letter #39

Open
brunnels opened this issue Apr 24, 2014 · 10 comments
Open

multiple workers cannot have names that start with the same letter #39

brunnels opened this issue Apr 24, 2014 · 10 comments

Comments

@brunnels
Copy link
Contributor

If you have multiple workers their names can't start with the same letter. It's case sensitive. Took me all morning before I tracked down what was causing the error.

This stems from using ftok which takes a single character string on line 538 of Mediator.php. Some error checking should be added to check for this scenario and throw an exception.

$this->guid = ftok($ftok, $this->alias[0]);
$this->worker('RecordWorker', new RecordWorker(), new Core_Worker_Via_SysV(128 * 1024 * 1024));
$this->worker('RecordUpdater', new RecordUpdateWorker(), new Core_Worker_Via_SysV(110 * 1024 * 1024));
[2014-04-24 11:39:48] 11498               Application Startup Complete. Starting Event Loop.
[2014-04-24 11:39:48] 11503 RecordUpdater  Worker Process Started

Warning: msg_send(): msgsnd failed: Identifier removed in /home/br64538/workspace/daemon/lib/vendor/PHP-Daemon/Core/Worker/Via/SysV.php on line 208

Call Stack:
    0.0002     233184   1. {main}() /home/br64538/workspace/daemon/lib/daemon/run.php:0
    0.9073    6718928   2. Core_Daemon->run() /home/br64538/workspace/daemon/lib/daemon/run.php:15
    0.9075    6720472   3. SNUpdateDaemon->execute() /home/br64538/workspace/daemon/lib/vendor/PHP-Daemon/Core/Daemon.php:414
    0.9075    6720704   4. Core_Worker_ObjectMediator->getStalexChanges() /home/br64538/workspace/daemon/lib/daemon/SNUpdateDaemon.class.php:105
    0.9075    6720992   5. Core_Worker_Mediator->__call() /home/br64538/workspace/daemon/lib/daemon/SNUpdateDaemon.class.php:105
    0.9077    6760544   6. Core_Worker_Mediator->call() /home/br64538/workspace/daemon/lib/vendor/PHP-Daemon/Core/Worker/Mediator.php:851
    0.9077    6761112   7. Core_Worker_Via_SysV->put() /home/br64538/workspace/daemon/lib/vendor/PHP-Daemon/Core/Worker/Mediator.php:824
    0.9078    6763192   8. msg_send() /home/br64538/workspace/daemon/lib/vendor/PHP-Daemon/Core/Worker/Via/SysV.php:208

[2014-04-24 11:39:48] 11498 RecordWorker  SysV::put() Failed for call_id 2: Retrying. Error Code: 43
[2014-04-24 11:39:48] 11503 RecordUpdater  getStalexChanges() is Not Callable.
@shaneharter
Copy link
Owner

It is insane to me that I've used this for 2 years -- a half dozen projects -- and have never had 2 workers that start w/ the same letter!

@brunnels
Copy link
Contributor Author

That's how it always happens to me. My code works great for me but as soon as someone else starts using it bring on the bugs.

Another option if you want to support duplicate starting letters is do a mapping for the worker array key sequence to an alpha value. This would make the max number of workers 52 per daemon but that would be crazy to have anywhere close to that.

@shaneharter
Copy link
Owner

Ben, I spent some time working on this over the weekend. I have a point release I'm preparing with the changes we already discovered -- still need to replace ftok with a solution the way you describe.

@edwinxie
Copy link

It happens to me too.
SysV::put() Failed for call_id 208: Retrying. Error Code: 11
Sooo many errors...
Maybe PHP-Daemon is not a stable tool.

@brunnels
Copy link
Contributor Author

I have it fairly stable now but I had to scrap the SysV inter-process
communication and go with a file in the filesystem. I wrote a class to
handle locking and such and integrated it all in. I can contribute back my
changes if Shane or someone else is interested in testing it more and
cleaning it up if needed. I've moved to a different role in my job and I'm
not working with PHP now so I don't have the time or need to work on it any
further.

On Wed, Oct 29, 2014 at 1:48 AM, edwinxie [email protected] wrote:

It happens to me too.
SysV::put() Failed for call_id 208: Retrying. Error Code: 11
Sooo many errors...
Maybe PHP-Daemon is not a stable tool.


Reply to this email directly or view it on GitHub
#39 (comment)
.

@defusiondev
Copy link

@brunnels bit of a late reply but I'm having the same problems as mention in this ticket, care to share the code for your solution?

@brunnels
Copy link
Contributor Author

We're using this in production for a while now but I have been out of that particular group for 2+years. I can get the current code and send it to you if you would like?

@defusiondev
Copy link

yes that'd be great thanks

@brunnels
Copy link
Contributor Author

Here you go. If there's anything missing let me know.
PHP-Daemon.zip

@defusiondev
Copy link

Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants