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

Unable to use cluster.Manager without opening existing bucket first

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 1.6.6
    • 1.6.5
    • library
    • None
    • 1

    Description

      As of v1.6.5, it's not possible to use gocb's cluster.Manager to perform any operations without knowing the name of, and opening one already existing bucket.

      Use case

      I want to connect to an empty cluster, and create a new bucket using the SDK, and then open it to perform SDK operations on it.

      This is caused by the change for GOCBC-794. Is this new behaviour intentional?
      If so, what is the proposed workaround for the given use case?

      Minimal repro

      package main
       
      import (
      	"github.com/couchbase/gocb"
      )
       
      func main() {
      	cluster, err := gocb.Connect("couchbase://192.168.1.20")
      	errPanic(err)
      	defer cluster.Close()
       
      	errPanic(cluster.Authenticate(gocb.PasswordAuthenticator{
      		Username: "Administrator",
      		Password: "password",
      	}))
       
      	clusterMgr := cluster.Manager("Administrator", "password")
       
      	errPanic(clusterMgr.InsertBucket(&gocb.BucketSettings{
      		Name:          "testbucket",
      		Quota:         100,
      		Type:          gocb.Couchbase,
      		FlushEnabled:  true,
      		IndexReplicas: false,
      		Replicas:      0,
      	}))
      }
       
      func errPanic(err error) {
      	if err != nil {
      		panic(err)
      	}
      }
      

       

      ✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test 
      13:52 $ go run main.go
       
      ✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test 
      13:52 $ # switch from gocb v1.6.4 to gocb v1.6.5
       
      ✔ ~/dev/go/src/github.com/bbrks/gocb-bucketloop-test 
      13:52 $ go run main.go
      panic: You must open a bucket before you can perform cluster level operations.
       
      goroutine 1 [running]:
      main.errPanic(...)
              /Users/benbrooks/dev/go/src/github.com/bbrks/gocb-bucketloop-test/main.go:31
      main.main()
              /Users/benbrooks/dev/go/src/github.com/bbrks/gocb-bucketloop-test/main.go:19 +0x32e
      exit status 2
      

      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:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty