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)
|
}
|
}
|
Attachments
Issue Links
For Gerrit Dashboard: MB-43553 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
155357,2 | MB-43553: Close the pool used to initialize a Bucket instance | master | go-couchbase | Status: MERGED | +2 | +1 |
155695,3 | Revert "MB-43553: Close the pool used to initialize a Bucket instance" | master | go-couchbase | Status: MERGED | +2 | +1 |
155733,1 | MB-43553: [BP] Close the pool used to initialize a Bucket instance | mad-hatter | go-couchbase | Status: ABANDONED | -1 | 0 |
155752,5 | MB-43553: Conditionally closing Bucket's Pool instance | master | go-couchbase | Status: MERGED | +2 | +1 |
156049,3 | MB-43553: [BP] Conditionally closing Bucket's Pool instance | mad-hatter | go-couchbase | Status: MERGED | +2 | +1 |
156124,2 | MB-43553: [BP] Conditionally closing Bucket's Pool instance | cheshire-cat | go-couchbase | Status: MERGED | +2 | +1 |