gearman-go icon indicating copy to clipboard operation
gearman-go copied to clipboard

WorkerConnection freezes due to racecondition.

Open lath opened this issue 10 years ago • 3 comments

Hello.

I've noticed that the worker-connection sometimes freezes. The reason for this is an unhandled io.ErrShortWrite error caused inside agent.write().

The writer throws this error when a worker-go-routine writes "dtWorkComplete" just after the main-thread receives a "dtNoop" but before sending "dtPreSleep". In other words:

dtNoop dtWorkComplete dtPreSleep

This causes the issue because the go-routine is missing a synclock inside worker.exec(). I've solved this by changing:

inpack.a.write(outpack)

into

inpack.a.Lock()
err := inpack.a.write(outpack)
inpack.a.Unlock()

lath avatar Jan 09 '15 17:01 lath

Is this closed?

parkr avatar Sep 18 '15 17:09 parkr

Already fixed, but I think it still needs more testing.

mikespook avatar Sep 19 '15 06:09 mikespook

I have not updated my codebase for a long time but the patch has worked for me without any problems since I implemented it.

Best regards

lath avatar Sep 21 '15 11:09 lath