Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-43553

cbdatasource ConnectBucket leaks unclosable Pool reference

    XMLWordPrintable

Details

    • 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

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              abhinav Abhi Dangeti
              ben.brooks Ben Brooks
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                PagerDuty