Strange PHP Client Failover Issues.

136 views
Skip to first unread message

Urda

unread,
Jan 25, 2010, 9:29:25 AM1/25/10
to gearman
Problem:

If I have Gearman Servers added from a MySQL table (so I don't have to
update client code all over the place for new servers) and the last
added Gearman Job server is down we have problems. However if we hard
code the servers, the PHP extension and client fail over perfectly to
the second gearman Job server. If we add print statements to the while
loop from when the MySQL client is adding servers, we clearly see that
two and only two servers are added to the client.

Obviously we would prefer to run the Clients and create the clients by
having the Gearman Job servers in a MySQL table, but if we cannot get
around this goofy bug we may have to hard code it. Any help?

Source Codes:
---------------
http://pastebin.ca/1765166 (source code)

http://pastebin.ca/1761941 (strace for failure, Server 10.58 is down,
Server 10.141 is up but never gets the job)

http://pastebin.ca/1761942 (strace for Success, Server 10.58 is up,
Server
10.141 is up. 10.58 gets all jobs, server 10.141 gets zero, which is
correctly done)

Expected result:
----------------
Assuming Server #1 (10.58) is down, runTasks() should fire, send all
the
tasks to server #2, and finish running.

Actual result:
--------------
Script stops and hangs at runTasks(), and never finishes. Job server
#2
gets zero jobs and zero connections from the client script.

Urda

unread,
Jan 25, 2010, 11:45:54 AM1/25/10
to gearman
The PHP code seems to also not failover when I hard code the servers
in

E.g.
$client->addServer("192.168.10.58","4730");
$client->addServer("192.168.10.141","4730");

and if the last server added (141) is down, then the script will not
fire run tasks and close, but sometimes gets one job to the gearman
server, and freezes up.

On Jan 25, 9:29 am, Urda <peter.u...@gmail.com> wrote:
> Problem:
>
> If I have Gearman Servers added from a MySQL table (so I don't have to
> update client code all over the place for new servers) and the last
> added Gearman Job server is down we have problems. However if we hard
> code the servers, the PHP extension and client fail over perfectly to
> the second gearman Job server. If we add print statements to the while
> loop from when the MySQL client is adding servers, we clearly see that
> two and only two servers are added to the client.
>
> Obviously we would prefer to run the Clients and create the clients by
> having the Gearman Job servers in a MySQL table, but if we cannot get
> around this goofy bug we may have to hard code it. Any help?
>
> Source Codes:
> ---------------http://pastebin.ca/1765166(source  code)
>

> http://pastebin.ca/1761941(strace for failure, Server 10.58 is down,


> Server 10.141 is up but never gets the job)
>

> http://pastebin.ca/1761942(strace for Success, Server 10.58 is up,

Urda

unread,
Jan 25, 2010, 11:49:06 AM1/25/10
to gearman
So in review. I tried the following:

Adding servers by looping through MySQL Database results.
Adding servers by "hard coding" them into the PHP script.
Adding servers by using variables I added inside my gearmanServers.php
file

In all three situations the addTasks does not fail over to the second
server that is running when the last added server to the client is
down and not accepting new jobs. This seems like a really bad program
flaw and defeats the purpose of having two gearman servers running if
PHP clients are involved. Any patches, tips, or repairs available for
this? I cannot get it to work.

On Jan 25, 11:45 am, Urda <peter.u...@gmail.com> wrote:
> The PHP code seems to also not failover when I hard code the servers
> in
>
> E.g.
> $client->addServer("192.168.10.58","4730");
> $client->addServer("192.168.10.141","4730");
>
> and if the last server added (141) is down, then the script will not
> fire run tasks and close, but sometimes gets one job to the gearman
> server, and freezes up.
>
> On Jan 25, 9:29 am, Urda <peter.u...@gmail.com> wrote:
>
> > Problem:
>
> > If I have Gearman Servers added from a MySQL table (so I don't have to
> > update client code all over the place for new servers) and the last
> > added Gearman Job server is down we have problems. However if we hard
> > code the servers, the PHP extension and client fail over perfectly to
> > the second gearman Job server. If we add print statements to the while
> > loop from when the MySQL client is adding servers, we clearly see that
> > two and only two servers are added to the client.
>
> > Obviously we would prefer to run the Clients and create the clients by
> > having the Gearman Job servers in a MySQL table, but if we cannot get
> > around this goofy bug we may have to hard code it. Any help?
>
> > Source Codes:
> > ---------------http://pastebin.ca/1765166(source code)
>

> >http://pastebin.ca/1761941(stracefor failure, Server 10.58 is down,


> > Server 10.141 is up but never gets the job)
>

> >http://pastebin.ca/1761942(stracefor Success, Server 10.58 is up,

Urda

unread,
Jan 26, 2010, 8:15:18 AM1/26/10
to gearman
After working with some IRC users yesterday, one of the users that
work on the PECL package confirmed it as a bug. Here is the bug report
in the package at this time:

http://pecl.php.net/bugs/bug.php?id=17024

> > >http://pastebin.ca/1761941(straceforfailure, Server 10.58 is down,


> > > Server 10.141 is up but never gets the job)
>

> > >http://pastebin.ca/1761942(straceforSuccess, Server 10.58 is up,

Reply all
Reply to author
Forward
0 new messages