No available N1QL nodes error

Hello!

Trying out the new SDK. Normal GET/INSERT op works but i cant get the N1QL Execution to work. The CLI cbq works as normal with N1QL queries on my cluster. I have also tried various connection strings/IP on ports on the connect method.

Searched the net and the nodejs SDK seems to have a “enable” method on buckets to enable n1ql nodes. For some reason the N1qlEps() in the agent packages failes to find any nodes or am i missing something (see a simple test below)?

package main

import (
"fmt"
"gopkg.in/couchbase/gocb.v1"
"log"
)

func main() {

cluster, err := gocb.Connect("couchbase://localhost:8091/")
if err != nil {
	log.Fatalf("Error connecting:  %v", err)
}

users, err := cluster.OpenBucket("activity", "")
if err != nil {
	log.Fatalf("Error open bucket:  %v", err)
}

var dummy interface{}
users.Get("icamovie_98392", &dummy)
fmt.Print(dummy)

query := gocb.NewN1qlQuery("SELECT * FROM activity")

rows, err := users.ExecuteN1qlQuery(query, nil)
if err != nil {
	fmt.Print(err)
}

var row interface{}
for rows.Next(&row) {
	fmt.Printf("Row: %+v\n", row)
}
rows.Close()
}

Hey Lundin,

What version of Couchbase Server are you using? The support for N1QL inside the Go SDK works only with Couchbase Server 4.0 which has N1QL integrated in the overall Server Package.

Cheers, Brett

Hi Brett!

Thanks for the reply, and nice work with the SDK!
The version is indeed 4.0, v.4.0.0-4047 on both machines. I have created the indexes using cbq tool
Definition: CREATE PRIMARY INDEX #primary ON activity USING GSI
Definition: CREATE INDEX subjectsid ON activity(subject_id) USING GSI

The panic msg is below as well as the error message.
No available N1QL nodes.

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x28 pc=0x260c]

goroutine 1 [running]:
main.main()
/Users/pontus/Applications/exchange/src/exchangeapp/workers/couchdbtest.go:36 +0x60c

goroutine 11 [select]:
net/http.(*persistConn).readLoop(0xc208080000)
/usr/local/go/src/net/http/transport.go:928 +0x9ce
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:660 +0xc9f

goroutine 13 [chan receive]:
github.com/couchbase/gocb/gocbcore.func·006()
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/agenthttpcfg.go:113 +0x56
created by github.com/couchbase/gocb/gocbcore.(*Agent).httpLooper
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/agenthttpcfg.go:116 +0xed3

goroutine 8 [IO wait]:
net.(*pollDesc).Wait(0xc208010140, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc208010140, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc2080100e0, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x598b20, 0xc20800b310)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc208038018, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc
net/http.noteEOFReader.Read(0x59a008, 0xc208038018, 0xc208080058, 0xc20807e000, 0x1000, 0x1000, 0xd9, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1270 +0x6e
net/http.(*noteEOFReader).Read(0xc20801e0c0, 0xc20807e000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
:125 +0xd4
bufio.(*Reader).fill(0xc2080524e0)
/usr/local/go/src/bufio/bufio.go:97 +0x1ce
bufio.(*Reader).ReadSlice(0xc2080524e0, 0xa, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bufio/bufio.go:295 +0x257
net/http/internal.readLine(0xc2080524e0, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:110 +0x5a
net/http/internal.(*chunkedReader).beginChunk(0xc20803ae70)
/usr/local/go/src/net/http/internal/chunked.go:47 +0x46
net/http/internal.(*chunkedReader).Read(0xc20803ae70, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/internal/chunked.go:77 +0xbb
net/http.(*body).readLocked(0xc208030280, 0xc208078004, 0xdfc, 0xdfc, 0xffffffff, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:584 +0x7a
net/http.(*body).Read(0xc208030280, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transfer.go:579 +0x115
net/http.(*bodyEOFSignal).Read(0xc208030300, 0xc208078004, 0xdfc, 0xdfc, 0x0, 0x0, 0x0)
/usr/local/go/src/net/http/transport.go:1193 +0x285
encoding/json.(*Decoder).readValue(0xc20806e000, 0xb026b, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:124 +0x5e1
encoding/json.(*Decoder).Decode(0xc20806e000, 0x2caa00, 0xc20801e580, 0x0, 0x0)
/usr/local/go/src/encoding/json/stream.go:44 +0x7b
github.com/couchbase/gocb/gocbcore.(*Agent).httpLooper(0xc208011c70, 0xc20801e9a0)
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/agenthttpcfg.go:121 +0xff7
created by github.com/couchbase/gocb/gocbcore.(*Agent).connect
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/agent.go:246 +0xa99

goroutine 12 [select]:
net/http.(*persistConn).writeLoop(0xc208080000)
/usr/local/go/src/net/http/transport.go:945 +0x41d
created by net/http.(*Transport).dialConn
/usr/local/go/src/net/http/transport.go:661 +0xcbc

goroutine 15 [select]:
github.com/couchbase/gocb/gocbcore.(*memdPipeline).ioLoop(0xc20807c100)
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdpipeline.go:196 +0x2e1
github.com/couchbase/gocb/gocbcore.(*memdPipeline).Run(0xc20807c100)
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdpipeline.go:220 +0x5e
created by github.com/couchbase/gocb/gocbcore.(*Agent).connectPipeline
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/agentrouting.go:111 +0x34f

goroutine 16 [IO wait]:
net.(*pollDesc).Wait(0xc2080103e0, 0x72, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:84 +0x47
net.(*pollDesc).WaitRead(0xc2080103e0, 0x0, 0x0)
/usr/local/go/src/net/fd_poll_runtime.go:89 +0x43
net.(*netFD).Read(0xc208010380, 0xc208056000, 0x1000, 0x1000, 0x0, 0x598b20, 0xc20800b070)
/usr/local/go/src/net/fd_unix.go:242 +0x40f
net.(*conn).Read(0xc2080380c8, 0xc208056000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
/usr/local/go/src/net/net.go:121 +0xdc
github.com/couchbase/gocb/gocbcore.(*memdConn).readBuffered(0xc20803acc0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdconn.go:141 +0x326
github.com/couchbase/gocb/gocbcore.(*memdConn).ReadPacket(0xc20803acc0, 0xc2080527e0, 0x0, 0x0)
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdconn.go:152 +0x54
github.com/couchbase/gocb/gocbcore.func·026()
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdpipeline.go:181 +0xcb
created by github.com/couchbase/gocb/gocbcore.(*memdPipeline).ioLoop
/Users/pontus/Applications/exchange/src/github.com/couchbase/gocb/gocbcore/memdpipeline.go:191 +0x10e
exit status 2

Hi again!

Sorry seems to be my misstake (or at least easily solvable) i simply removed the port from the connection string and then it found the topology so it seems because now it works!

Thanks!