Comment 3 for bug 405732

Revision history for this message
Eric Day (eday) wrote :

Hi Kim,

I'm seeing the exception objects being sent back to the client. For example, with the latest Perl API from the Danga SVN server:

use Gearman::Client;
my $client = Gearman::Client->new(('exceptions' => true));
$client->job_servers('127.0.0.1:4730');
$ref= $client->do_task('reverse', 'test');
print "$$ref\n";

 INFO Accepted connection from ::7042:6300:0:0%3358815836:38061
 INFO [ 0] ::7042:6300:0:0%3358815836:38061 Connected
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Received OPTION_REQ
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Sent OPTION_RES
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Received SUBMIT_JOB
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Sent JOB_CREATED
DEBUG [ 0] ::7042:6300:0:0%3358815836:38040 Sent NOOP
DEBUG [ 0] ::7042:6300:0:0%3358815836:38040 Received GRAB_JOB
DEBUG [ 0] ::7042:6300:0:0%3358815836:38040 Sent JOB_ASSIGN
DEBUG [ 0] ::7042:6300:0:0%3358815836:38040 Received WORK_EXCEPTION
DEBUG [ 0] ::7042:6300:0:0%3358815836:38040 Received WORK_FAIL
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Sent WORK_EXCEPTION
DEBUG [ 0] ::7042:6300:0:0%3358815836:38061 Sent WORK_FAIL
...
 INFO [ 0] ::7042:6300:0:0%3358815836:38061 Disconnected

As you can see, the C job server both receives and forwards on the WORK_EXCEPTION packet. You can confirm this with tcpdump.

The WORK_EXCEPTION packet was a bit of a hack that was added in specifically for Perl originally, which means it only sends serialized Perl exception objects. This obviously was not that portable, and would just lead to confusion in heterogeneous environments. I did not not this as deprecated in the protocol document, but lately as people have asked me about it, I tend to tell people to shy away from it. I could be wrong though. :)

One option is to re-purpose the command so that it can be used in a heterogeneous environment. Basically, don't let the API do any object serialization, and instead let the developer package and send exceptions back. I would also like to remove the need to OPTION_REQ, since this is an extra round trip just to let the job server know to forward the packets. Instead, I think it makes more sense to always forward the packets on and the API can ignore packets it doesn't understand (drop the EXCEPTION packet, but still terminate the job with a FAIL packet). Thoughts?

We should probably propose such changes to the mailing list to get feedback from a wider audience.

-Eric