Closed steedyu closed 5 years ago
Hi @steedyu, thanks for submitting an issue here. I'm afraid I don't fully understand your problem. NewCustom
makes a completely new Pool instance, which will not effect the first Pool in anyway, no matter what it's doing. I'm confused what you mean by:
So Empty() can't close all connection in pool in one goroutine and the other goroutine will add connection into pool.
Also, just a heads up, that radix.v2 is no longer really supported, so I won't be adding any new features to it. All future development is being done on radix/v3, which is faster, more feature-rich, and more flexible. Thanks!
Ok. Thank you for your reply. I will try to use radix/v3.
the condition is below: One app has multiple goroutines to deal with many requests. Every request operates the redis. After Issues happen in the network or environment, every request operate the redis falied and every time will re-init redis pool. Before re-init redis pool, one goroutine in the app firstly invoke Empty() and then NewCustom(). So Empty() can't close all connection in pool in one goroutine and the other goroutine will add connection into pool. because the code in pool.go below: mkConn := func() error { client, err := df(network, addr) if err == nil { p.pool <- client } return err }
i think the bold block code should replace p.Put(client) with p.pool <- client. It ensure when one goroutine invoke empty() ,anothers can't invoke NewCustom() to add client into the pool.