Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-488

ClusterManager ops panic when using the couchbases:// scheme

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.6.2
    • 1.6.1
    • None
    • None
    • 1

    Description

      When connecting to Couchbase Server using the couchbases:// scheme, and attempting to use a ClusterManager method, getMgmtEp() panics as the length of the cluster manager hosts is zero. It works OK when using the couchbase:// scheme.

      A short repro:

      func TestCouchbasesManager(t *testing.T) {
         c, err := Connect("couchbases://foo.com,bar.com,baz.com")
         if err != nil {
            t.Fatalf("error from ac.FromConnStr: %v", err)
         }
       
         cm := c.Manager("Administrator", "password")
         if cm == nil {
            t.Fatalf("nil clusterManager")
         }
       
         _, err = cm.GetBuckets()
         if err != nil {
            t.Fatalf("error from GetBuckets: %v", err)
         }
      }
      

      panic: invalid argument to Intn [recovered]
      	panic: invalid argument to Intn
       
      goroutine 14 [running]:
      testing.tRunner.func1(0xc00019a300)
      	/Users/benbrooks/dev/go/go1.11.5/src/testing/testing.go:792 +0x387
      panic(0x134e400, 0x1438a20)
      	/Users/benbrooks/dev/go/go1.11.5/src/runtime/panic.go:513 +0x1b9
      math/rand.(*Rand).Intn(0xc000092210, 0x0, 0x13e7044)
      	/Users/benbrooks/dev/go/go1.11.5/src/math/rand/rand.go:169 +0x9c
      math/rand.Intn(0x0, 0xc000138e40)
      	/Users/benbrooks/dev/go/go1.11.5/src/math/rand/rand.go:329 +0x37
      github.com/couchbase/gocb.(*ClusterManager).getMgmtEp(0xc00013a8c0, 0xc0000170f0, 0xb)
      	/Users/benbrooks/dev/sync_gateway/master/godeps/src/github.com/couchbase/gocb/clustermgr.go:90 +0x2f
      github.com/couchbase/gocb.(*ClusterManager).mgmtRequest(0xc00013a8c0, 0x13d9739, 0x3, 0x13dfd7c, 0x16, 0x0, 0x0, 0x0, 0x0, 0xc00024df28, ...)
      	/Users/benbrooks/dev/sync_gateway/master/godeps/src/github.com/couchbase/gocb/clustermgr.go:98 +0x4d
      github.com/couchbase/gocb.(*ClusterManager).GetBuckets(0xc00013a8c0, 0x13dc0c9, 0xd, 0x13da92c, 0x8, 0xc00013a8c0)
      	/Users/benbrooks/dev/sync_gateway/master/godeps/src/github.com/couchbase/gocb/clustermgr.go:140 +0x77
      github.com/couchbase/gocb.TestCouchbasesManager(0xc00019a300)
      	/Users/benbrooks/dev/sync_gateway/master/godeps/src/github.com/couchbase/gocb/bucket_cluster_test.go:36 +0xf7
      testing.tRunner(0xc00019a300, 0x13f4ca0)
      	/Users/benbrooks/dev/go/go1.11.5/src/testing/testing.go:827 +0xbf
      created by testing.(*T).Run
      	/Users/benbrooks/dev/go/go1.11.5/src/testing/testing.go:878 +0x35c
      

      Attachments

        Issue Links

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

          Activity

            People

              charles.dixon Charles Dixon
              ben.brooks Ben Brooks
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty