php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63041 "Failed to set exception option" on connect when any gearman server is down
Submitted: 2012-09-07 22:03 UTC Modified: 2017-07-25 15:12 UTC
Votes:18
Avg. Score:4.3 ± 0.9
Reproduced:18 of 18 (100.0%)
Same Version:5 (27.8%)
Same OS:6 (33.3%)
From: me at re-becca dot org Assigned: kalle (profile)
Status: Closed Package: gearman (PECL)
PHP Version: 5.3.16 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: me at re-becca dot org
New email:
PHP Version: OS:

 

 [2012-09-07 22:03 UTC] me at re-becca dot org
Description:
------------
gearman support => enabled
extension version => 1.0.3
libgearman version => 0.37
Default TCP Host => localhost
Default TCP Port => 4730

See php_gearman.c: PHP_FUNCTION(gearman_client_run_tasks) and 
PHP_FUNCTION(gearman_worker_work) where they call *_set_server_option

Test script:
---------------
<?php
$gm = new GearmanWorker();
$gm->addServer();
$gm->addServer("127.0.0.1",1234);
$gm->addFunction("example", function () {});
$gm->work();


Expected result:
----------------
Assuming that you have a gearman server running on localhost on the default port:

I expect it to connect to that server and register the "example" function.


Actual result:
--------------
Fatal error: Uncaught exception 'GearmanException' with message 'Failed to set 
exception option' in /Users/bturner/pc/gme/test.php on line 5

GearmanException: Failed to set exception option in /Users/bturner/pc/gme/test.php 
on line 5

Call Stack:
    0.0003     636840   1. {main}() /Users/bturner/pc/gme/test.php:0
    0.0007     641160   2. GearmanWorker->work() /Users/bturner/pc/gme/test.php:6

Dump $_SERVER

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-24 01:22 UTC] hradtke@php.net
-Status: Open +Status: Feedback
 [2012-09-24 01:22 UTC] hradtke@php.net
Am I reading correctly that you are attempting to connect to port 1234 (not 4730)? 
The exception is being thrown because pecl/gearman is trying to talk to a server 
that it is unable to connect to.
 [2012-09-24 15:37 UTC] me at re-becca dot org
Yes, that's correct.  Note the two calls to addServer.

Even though it can't connect to the second server it should continue.  Actually, 
most gearman libraries won't even throw an exception if both servers are down, 
they'll just wait, trying to reconnect until a timeout is triggered.

It *certainly* should not throw a "Failed to set exception option" in any case.  
That's happening because the PECL library indiscriminately tries to set the 
"exception option" on every call to work() on each of the servers it was told to 
connect to, even if some of them didn't connect.

Should the option even be set at work time? I would expect at connect time, not 
work time, but not knowing the original intent, I'm not sure.
 [2012-09-24 15:37 UTC] me at re-becca dot org
-Status: Feedback +Status: Open
 [2012-09-24 20:23 UTC] hradtke@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: hradtke
 [2012-11-16 11:51 UTC] fruit dot dev at gmail dot com
PECL Gearman:
gearman support => enabled
extension version => 1.1.0
libgearman version => 1.1.3 (Compiled with --enable-assert and --enable-debug)
Default TCP Host => localhost
Default TCP Port => 4730
PHP: v5.4.8 (compiled with --enable-debug)

My worker test case is here: 
  http://pastie.org/5387047

And jobs were added every minute by calling: 
  gearman -b -f testcase_01 1010101

After 2 hours of normal working, suddenly I got same message "Failed to set 
exception option".

On request, I can attach geamand logs (with --verbose=DEBUG).

Here is gdb backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x0000000801e3160b in gearman_packet_free (packet=0x802466098) at 
libgearman/packet.cc:289
289	    if (packet->universal->packet_list == packet)
Current language:  auto; currently c++
#0  0x0000000801e3160b in gearman_packet_free (packet=0x802466098) at 
libgearman/packet.cc:289
#1  0x0000000801e2af28 in gearman_connection_st::free_private_packet 
(this=0x802466000) at libgearman/connection.cc:338
#2  0x0000000801e34e87 in connection_loop (universal=@0x80245ac60, 
message=@0x7fffffffc390, check=@0x7fffffffc4e0) at 
libgearman/universal.cc:511
#3  0x0000000801e34f85 in gearman_request_option (universal=@0x80245ac60, 
option=@0x7fffffffc560) at libgearman/universal.cc:576
#4  0x0000000801e36a11 in gearman_worker_set_server_option 
(worker_shell=0x801a505a8, option_arg=0x801d16d3e "exceptions", 
option_arg_size=10) at libgearman/worker.cc:1297
#5  0x0000000801d12a2c in zif_gearman_worker_work (ht=0, 
return_value=0x801a4f190, return_value_ptr=0x0, this_ptr=0x801a4c390, 
return_value_used=1)
    at /usr/home/fruit/make/php-ext-gearman-1.1.0/php_gearman.c:3646
#6  0x00000000007f27dc in zend_do_fcall_common_helper_SPEC 
(execute_data=0x801a170d8) at zend_vm_execute.h:642
#7  0x00000000007f39b5 in ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER 
(execute_data=0x801a170d8) at zend_vm_execute.h:752
#8  0x00000000007f1001 in execute (op_array=0x801a4d170) at 
zend_vm_execute.h:410
#9  0x00000000007b5a4a in zend_execute_scripts (type=8, retval=0x0, 
file_count=3) at /usr/home/fruit/make/php-
5.4.8/Zend/zend.c:1309
#10 0x0000000000729f03 in php_execute_script (primary_file=0x7fffffffe660) at 
/usr/home/fruit/make/php-5.4.8/main/main.c:2482
#11 0x0000000000902de4 in do_cli (argc=2, argv=0x7fffffffe928) at 
/usr/home/fruit/make/php-5.4.8/sapi/cli/php_cli.c:988
#12 0x0000000000903c79 in main (argc=2, argv=0x7fffffffe928) at 
/usr/home/fruit/make/php-5.4.8/sapi/cli/php_cli.c:1364
 [2012-11-16 11:55 UTC] fruit dot dev at gmail dot com
Probably I had to create a new but report or is it a similar bug!?
 [2012-11-16 21:34 UTC] me at re-becca dot org
You're also getting a segmentation fault, so I'd file a separate bug report of I 
were you.
 [2012-11-16 23:58 UTC] hradtke@php.net
I will update the extension to not try and set that option if the connection 
failed.
 [2012-11-29 13:49 UTC] fruit dot dev at gmail dot com
My separate bug report with solution was opened here: 
https://bugs.php.net/bug.php?id=63648
 [2013-04-25 16:38 UTC] me at re-becca dot org
fruit.dev, I think you linked to the wrong ticket? That one doesn't seem to be 
related, nor does it have a patch.
 [2013-04-25 23:12 UTC] fruit dot dev at gmail dot com
When I look at both tickets today, it seems to me, that they are totally 
different.
 [2017-01-10 08:22 UTC] kalle@php.net
-Status: Assigned +Status: Suspended -Assigned To: hradtke +Assigned To:
 [2017-01-10 08:22 UTC] kalle@php.net
The gearman extension have not had much activity in the past few years, so I'm taking the safe bet that this is no longer under active development (as I don't consider the typo fixes on the github repo an active development), besides that it also targets unsupported PHP versions. Please unsuspend this report in case it begins to blossom with life once more
 [2017-07-25 15:12 UTC] kalle@php.net
-Status: Suspended +Status: Closed -Assigned To: +Assigned To: kalle
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC