I'm attempting to query memcache on localhost every 10 minutes. The first Get("key") works fine, but the one 10 minutes later results in an error. The cycle repeats, so every other query succeeds. tcpdump shows that the memcache server attempted to close the TCP connection after about 30 seconds.
The errors I get are either of the following.
panic: write tcp 127.0.0.1:13590->127.0.0.1:11211: write: broken pipe
EOF
I've found I can work around this problem by calling Ping() and ignoring the returned error immediately before any Get() call.
I've boiled down a minimal repro of the problem I'm facing.
package main
import (
"github.com/bradfitz/gomemcache/memcache"
"fmt"
"time"
)
func query(mc *memcache.Client) {
// This Ping() call mitigates the problem
// err := mc.Ping()
// fmt.Printf("Ping(): %v\n", err)
r, err := mc.Get("key")
if err != nil {
panic(err)
}
fmt.Printf("%v\n", string(r.Value))
}
func main() {
mc := memcache.New("127.0.0.1:11211")
query(mc)
fmt.Printf("Sleeping...\n")
time.Sleep(35 * time.Second)
// This second query call results in an error from mc.Get("key")
query(mc)
}
I'm attempting to query memcache on localhost every 10 minutes. The first
Get("key")works fine, but the one 10 minutes later results in an error. The cycle repeats, so every other query succeeds.tcpdumpshows that the memcache server attempted to close the TCP connection after about 30 seconds.The errors I get are either of the following.
I've found I can work around this problem by calling
Ping()and ignoring the returned error immediately before anyGet()call.I've boiled down a minimal repro of the problem I'm facing.