Description
It looks like the driver is steadily leaking goroutines and memory. The following code demonstrates this. The number of goroutines steadily increases as does the memory, simply by holding an open bucket
package main
|
|
import (
|
"fmt"
|
"github.com/couchbaselabs/gocb"
|
"os"
|
"runtime"
|
"runtime/pprof"
|
"time"
|
"github.com/couchbaselabs/gocb/gocbcore"
|
)
|
|
func main() {
|
bucketName := "test"
|
|
gocbcore.SetLogger(gocbcore.DefaultStdOutLogger())
|
cluster, err := gocb.Connect("couchbase://localhost:8091")
|
if err != nil {
|
print(err.Error())
|
os.Exit(1)
|
}
|
|
bucket, err := cluster.OpenBucket(bucketName, "")
|
if err != nil {
|
print(err.Error())
|
os.Exit(1)
|
}
|
|
println("Connected to bucket %s", bucket)
|
|
var memStats runtime.MemStats
|
|
for {
|
println("\n\n\n")
|
println(fmt.Sprintf("Number of running goroutines: %d", runtime.NumGoroutine()))
|
|
runtime.ReadMemStats(&memStats)
|
println(fmt.Sprintf("Allocated memory still in use: %dk", memStats.Alloc/1024))
|
|
println("\n\nDump >>>>>>>>>>>>>>>>>>>>>>")
|
pprof.Lookup("goroutine").WriteTo(os.Stdout, 1)
|
|
time.Sleep(5 * time.Second)
|
}
|
|
}
|
|
Running the code shows that the goroutines are accumulating here:
github.com/couchbaselabs/gocb/gocbcore.(*memdQueue).drainTillSignal+0x13c
|
After enabling driver debugging, it seems to lose a goroutine every time whatever process outputs the following debug code runs
DEBUG: Auto DC!
|
DEBUG: HTTP, Setting http://127.0.0.1:8091 to iter 6
|
DEBUG: Pick Failed.
|
DEBUG: Looping again.
|
DEBUG: Http Picked: http://127.0.0.1:8091.
|
DEBUG: HTTP Hostname: http://127.0.0.1:8091.
|
DEBUG: Connected.
|
DEBUG: Got Block.
|
DEBUG: Got Config.
|
DEBUG: HTTP Config Update
|
DEBUG: Switching routing data (update)...
|
DEBUG: Revision ID: 0
|
DEBUG: Queues:
|
DEBUG: 0: Server 0
|
DEBUG: Servers:
|
DEBUG: 0: 127.0.0.1:11210 (ACTIVE)
|
DEBUG: Pending Servers:
|
DEBUG: 0: nil
|
DEBUG: Has WaitQueue? NO
|
DEBUG: Has DeadQueue? YES
|
DEBUG: Capi Eps:
|
DEBUG: - http://127.0.0.1:8092/ultron
|
DEBUG: Mgmt Eps:
|
DEBUG: - http://127.0.0.1:8091
|
DEBUG: N1ql Eps:
|
DEBUG: To new data...
|
DEBUG: Revision ID: 0
|
DEBUG: Queues:
|
DEBUG: 0: Server 0
|
DEBUG: Servers:
|
DEBUG: 0: 127.0.0.1:11210 (ACTIVE)
|
DEBUG: Pending Servers:
|
DEBUG: 0: nil
|
DEBUG: Has WaitQueue? NO
|
DEBUG: Has DeadQueue? YES
|
DEBUG: Capi Eps:
|
DEBUG: - http://127.0.0.1:8092/ultron
|
DEBUG: Mgmt Eps:
|
DEBUG: - http://127.0.0.1:8091
|
DEBUG: N1ql Eps:
|