Details
-
Bug
-
Resolution: Fixed
-
Critical
-
6.5.1, 6.6.0, 6.6.1, 6.6.2, 6.5.2, 6.5.0, 7.0.0, 7.0.1, Cheshire-Cat
-
Untriaged
-
No
Description
The default ConnectBucket function in cbdatasource leaks an unclosable reference to Pool upon each invocation. This can seriously add up if ConnectBucket is called a lot of times (which can be the case under adverse network conditions causing lots of reconnects).
Seen originally via a Sync Gateway CBSE where the DCP feed was constantly reconnecting due to some network issues, resulting in 6GB+ memory leaks until OOM/restarts.
Minimal repro, you can use pprof to look at the heap profile:
type basicAuth struct{ username, password string }
|
|
func (a basicAuth) GetCredentials() (string, string, string) {
|
return a.username, a.password, ""
|
}
|
|
func TestConnectBucketPoolLeak(t *testing.T) {
|
for i := 0; i < 1000; i++ {
|
b, err := ConnectBucket("http://192.168.1.21:8091", "default", "default", basicAuth{"Administrator", "password"})
|
if err != nil {
|
t.Fatalf("Error connecting to bucket: %v", err)
|
}
|
b.Close()
|
}
|
|
heapProfile, err := os.Create("heap.pb.gz")
|
if err != nil {
|
t.Fatalf("Unable to create profile file: %v", err)
|
}
|
if err := pprof.WriteHeapProfile(heapProfile); err != nil {
|
t.Fatalf("Unable to write heap profile: %v", err)
|
}
|
}
|