Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching free connections by new.Addr.String() makes some things impossible #117

Open
graywolf opened this issue Apr 5, 2020 · 0 comments

Comments

@graywolf
Copy link

graywolf commented Apr 5, 2020

I've been trying some weird setups with custom ServerList and I've run into bug due to https://github.com/bradfitz/gomemcache/blob/master/memcache/memcache.go#L209:

freelist := c.freeconn[addr.String()]

In other words, when I create my own ServerList which contains two addresses:

net.ResolveTCPAddr("tcp", "127.0.0.1:11211")
net.ResolveUnixAddr("unix", "127.0.0.1:11211")

Only one of them can be used due to both resolving to the same thing by .String(). I must say that I was not happy when I found this after like ~1h of debugging why is one of the memcached servers ignored.

I guess one solution would be to include type of the addr into the hash. So something like

freelist := c.freeconn[fmt.Sprintf("%T-%s", addr, addr)]

EDIT: Combined with the fact that idle connections cannot be disabled (since 0 means default, not 0) I'm currently just recreating client for each requests, which is strongly suboptimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant