Skip to content
Go client for beanstalkd
Go
Branch: master
Clone or download
mrngm and kr conn.go: ensure EndRequest runs when c.cmd returns (#29)
We discovered a problem in this library that causes the client to hang
indefinitely. This patch makes sure that the locking part
(`net.textproto.Pipeline.StopRequest`) is executed whenever the function
returns.

Steps to reproduce:

1. Establish a normal connection with `beanstalkd` and keep the connection open
2. Reserve a job through `TubeSet.Reserve(...)`
3. Exit the server
4. Reserve a job through `TubeSet.Reserve(...)`. The expected error is:
`reserve-with-timeout: read tcp srcip:srcport->dstip:dstport: read: connection
reset by peer`
5. Reserve a job through `TubeSet.Reserve(...)`. The expected error is:
`reserve-with-timeout: write tcp srcip:srcport->dstip:dstport: write: broken
pipe`

After step 3, `t.Conn.cmd(...)` (in `tubeset.go:30`) is executed without error,
because writes to a half-closed socket are accepted. Step 4, then, fails with
the error mentioned. In step 5, the write fails and `t.Conn.cmd(...)` returns
early in `conn.go:76`.

However, `c.c.StartRequest(r.id)` is not properly ended and this causes jobs
with an `id` larger than `r.id` to wait indefinitely to be processed.

Cc: @Minnozz
Fixes: #21
Fixes: #37
Latest commit 390b03b May 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
License add license Apr 11, 2012
Readme.md Update Readme.md (#33) Aug 22, 2018
common_test.go
conn.go conn.go: ensure EndRequest runs when c.cmd returns (#29) May 15, 2019
conn_test.go add kick-job support (#19) Feb 27, 2019
doc.go document synchronization; fixes #6 Feb 18, 2013
err.go return correct error types in all cases Jan 14, 2013
example_test.go
name.go init Apr 11, 2012
parse.go return correct error types in all cases Jan 14, 2013
parse_test.go
time.go init Apr 11, 2012
time_test.go init Apr 11, 2012
tube.go
tube_test.go gofmt Apr 11, 2012
tubeset.go better document the timeout error (see #4) Jan 15, 2013
tubeset_test.go return correct error types in all cases Jan 14, 2013

Readme.md

Beanstalk

Go client for beanstalkd.

Install

$ go get github.com/beanstalkd/go-beanstalk

Use

Produce jobs:

c, err := beanstalk.Dial("tcp", "127.0.0.1:11300")
id, err := c.Put([]byte("hello"), 1, 0, 120*time.Second)

Consume jobs:

c, err := beanstalk.Dial("tcp", "127.0.0.1:11300")
id, body, err := c.Reserve(5 * time.Second)
You can’t perform that action at this time.