Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nebula-go 3.4.0 query nothing from nebula server 3.4.1 #264

Open
supermario1990 opened this issue Mar 23, 2023 · 12 comments
Open

nebula-go 3.4.0 query nothing from nebula server 3.4.1 #264

supermario1990 opened this issue Mar 23, 2023 · 12 comments
Labels
type/question Type: question about the product

Comments

@supermario1990
Copy link

I updated nebula server from 3.2.0 to 3.4.1, when I use nebula-go client(3.4.0), I can not query anything. while when I use python client(3.4.0), I can query the right results

@wey-gu
Copy link
Contributor

wey-gu commented Mar 24, 2023

Could you provide how this "can not query anything" looks like? I guess something is wrong.

The nebula-console is based on nebula-go, you should verify quite easily actually that 3.4.0 works fine.

Thanks!

@supermario1990
Copy link
Author

Could you provide how this "can not query anything" looks like? I guess something is wrong.

The nebula-console is based on nebula-go, you should verify quite easily actually that 3.4.0 works fine.

Thanks!

thanks for reply. I will supply my code snippet to reproduce the problem.

@supermario1990
Copy link
Author

my nebula server info:

root@VM-16-10-ubuntu:~/download# /usr/local/nebula/scripts/nebula.service status all
[INFO] nebula-metad(a6dc673): Running as 7384, Listening on 9559
[INFO] nebula-graphd(a6dc673): Running as 7494, Listening on 9669
[INFO] nebula-storaged(a6dc673): Running as 7548, Listening on 9779
root@VM-16-10-ubuntu:~/download# 
root@VM-16-10-ubuntu:~/download# 
root@VM-16-10-ubuntu:~/download# /usr/local/nebula/bin/nebula-graphd -version
nebula-graphd version 3.4.1, Git: a6dc673, Build Time: Mar  6 2023 18:40:11
This source code is licensed under Apache 2.0 License.

@supermario1990
Copy link
Author

supermario1990 commented Mar 24, 2023

go code:

/*
 
 * Copyright (c) 2021 vesoft inc. All rights reserved.
 *
 * This source code is licensed under Apache 2.0 License.
 *
 */

package main

import (
	"fmt"

	nebula "github.com/vesoft-inc/nebula-go/v3"
)

const (
	address = "124.222.227.15"
	// The default port of NebulaGraph 2.x is 9669.
	// 3699 is only for testing.
	port     = 9669
	username = "root"
	password = "nebula"
)

// Initialize logger
var log = nebula.DefaultLogger{}

func main() {
	hostAddress := nebula.HostAddress{Host: address, Port: port}
	hostList := []nebula.HostAddress{hostAddress}
	// Create configs for connection pool using default values
	testPoolConfig := nebula.GetDefaultConf()

	// Initialize connection pool
	pool, err := nebula.NewConnectionPool(hostList, testPoolConfig, log)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to initialize the connection pool, host: %s, port: %d, %s", address, port, err.Error()))
	}
	// Close all connections in the pool
	defer pool.Close()

	// Create session
	session, err := pool.GetSession(username, password)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to create a new session from connection pool, username: %s, password: %s, %s",
			username, password, err.Error()))
	}
	// Release session and return connection back to connection pool
	defer session.Release()

	{
		// Prepare the query
		sql := `use manager;MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc 
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*0]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass;`

		// Execute a query
		resultSet, err := session.Execute(sql)
		if err != nil {
			fmt.Print(err.Error())
			return
		}
		fmt.Println(resultSet)
		for _, v := range resultSet.GetRows() {
			fmt.Println(string(v.GetValues()[0].SVal))
			fmt.Println(string(v.GetValues()[1].SVal))
			fmt.Println(string(v.GetValues()[2].SVal))
			fmt.Println(string(v.GetValues()[3].SVal))
			fmt.Println(string(v.GetValues()[4].SVal))
		}
	}

	fmt.Print("\n")
	log.Info("Nebula Go Client Basic Example Finished")
}

output:

&{0xc0000e60e0 [id name batchno process pass] map[batchno:2 id:0 name:1 pass:4 process:3] {0 [85 84 67]}}

@supermario1990
Copy link
Author

python code:

from nebula3.gclient.net import ConnectionPool
from nebula3.Config import Config

# define a config
config = Config()
config.max_connection_pool_size = 10
# init connection pool
connection_pool = ConnectionPool()
# if the given servers are ok, return true, else return false
ok = connection_pool.init([('124.222.227.15', 9669)], config)

# option 1 control the connection release yourself
# get session from the pool
session = connection_pool.get_session('root', 'nebula')

# select space
session.execute('USE manager')

# show tags
result = session.execute('''
MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc 
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*0]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass;
''')
print(result)

# release session
session.release()

# close the pool
connection_pool.close()

output:

ResultSet(keys: ['id', 'name', 'batchno', 'process', 'pass'], values: [52, "成品批号", "BF14CDZ1-210107A1-02", "粉碎", "1"])

@supermario1990
Copy link
Author

supermario1990 commented Mar 24, 2023

just run the code upper, the server in the code is available.
go client and python client are all 3.4.0 @wey-gu

@supermario1990
Copy link
Author

in addition, when i downgrade nebula server to 3.2.0, the go client can query the right results.

@wey-gu
Copy link
Contributor

wey-gu commented Mar 24, 2023

Allow me to ping @Aiee for taking a look at it.
thanks

@supermario1990
Copy link
Author

go code:

/*
 
 * Copyright (c) 2021 vesoft inc. All rights reserved.
 *
 * This source code is licensed under Apache 2.0 License.
 *
 */

package main

import (
	"fmt"

	nebula "github.com/vesoft-inc/nebula-go/v3"
)

const (
	address = "124.222.227.15"
	// The default port of NebulaGraph 2.x is 9669.
	// 3699 is only for testing.
	port     = 9669
	username = "root"
	password = "nebula"
)

// Initialize logger
var log = nebula.DefaultLogger{}

func main() {
	hostAddress := nebula.HostAddress{Host: address, Port: port}
	hostList := []nebula.HostAddress{hostAddress}
	// Create configs for connection pool using default values
	testPoolConfig := nebula.GetDefaultConf()

	// Initialize connection pool
	pool, err := nebula.NewConnectionPool(hostList, testPoolConfig, log)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to initialize the connection pool, host: %s, port: %d, %s", address, port, err.Error()))
	}
	// Close all connections in the pool
	defer pool.Close()

	// Create session
	session, err := pool.GetSession(username, password)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to create a new session from connection pool, username: %s, password: %s, %s",
			username, password, err.Error()))
	}
	// Release session and return connection back to connection pool
	defer session.Release()

	{
		// Prepare the query
		sql := `use manager;MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc 
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*0]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass;`

		// Execute a query
		resultSet, err := session.Execute(sql)
		if err != nil {
			fmt.Print(err.Error())
			return
		}
		fmt.Println(resultSet)
		for _, v := range resultSet.GetRows() {
			fmt.Println(string(v.GetValues()[0].SVal))
			fmt.Println(string(v.GetValues()[1].SVal))
			fmt.Println(string(v.GetValues()[2].SVal))
			fmt.Println(string(v.GetValues()[3].SVal))
			fmt.Println(string(v.GetValues()[4].SVal))
		}
	}

	fmt.Print("\n")
	log.Info("Nebula Go Client Basic Example Finished")
}

output:

&{0xc0000e60e0 [id name batchno process pass] map[batchno:2 id:0 name:1 pass:4 process:3] {0 [85 84 67]}}

问题已经解决。之前我写的sql是这样:

use manager;MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc;

注意上面是两个sql语句连在一起的,先是 use manager 指定空间,再是具体的业务sql。这样的写法在服务器版本3.2.0是可以正常工作的。

现在我升级到了服务器3.4.0,上面的写法就不行了。两句sql必须分开执行。不知这样的表现行为是有意这么设计,还是前后不兼容的bug?

@wey-gu
Copy link
Contributor

wey-gu commented Mar 27, 2023

ping @Aiee

@pythonsan
Copy link

pythonsan commented Mar 30, 2023

我使用的也是3.2.0版本,但是呢如果use和查询语句放在一起也是无法查询出来数据的 :-(
分开Execute()就可以查询出来,是因为use space有延时吗?

@QingZ11 QingZ11 added the type/question Type: question about the product label Oct 23, 2023
@QingZ11
Copy link

QingZ11 commented Oct 23, 2023

go code:

/*
 
 * Copyright (c) 2021 vesoft inc. All rights reserved.
 *
 * This source code is licensed under Apache 2.0 License.
 *
 */

package main

import (
	"fmt"

	nebula "github.com/vesoft-inc/nebula-go/v3"
)

const (
	address = "124.222.227.15"
	// The default port of NebulaGraph 2.x is 9669.
	// 3699 is only for testing.
	port     = 9669
	username = "root"
	password = "nebula"
)

// Initialize logger
var log = nebula.DefaultLogger{}

func main() {
	hostAddress := nebula.HostAddress{Host: address, Port: port}
	hostList := []nebula.HostAddress{hostAddress}
	// Create configs for connection pool using default values
	testPoolConfig := nebula.GetDefaultConf()

	// Initialize connection pool
	pool, err := nebula.NewConnectionPool(hostList, testPoolConfig, log)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to initialize the connection pool, host: %s, port: %d, %s", address, port, err.Error()))
	}
	// Close all connections in the pool
	defer pool.Close()

	// Create session
	session, err := pool.GetSession(username, password)
	if err != nil {
		log.Fatal(fmt.Sprintf("Fail to create a new session from connection pool, username: %s, password: %s, %s",
			username, password, err.Error()))
	}
	// Release session and return connection back to connection pool
	defer session.Release()

	{
		// Prepare the query
		sql := `use manager;MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc 
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc
				UNION
				MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})-[e:follow*0]->(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass;`

		// Execute a query
		resultSet, err := session.Execute(sql)
		if err != nil {
			fmt.Print(err.Error())
			return
		}
		fmt.Println(resultSet)
		for _, v := range resultSet.GetRows() {
			fmt.Println(string(v.GetValues()[0].SVal))
			fmt.Println(string(v.GetValues()[1].SVal))
			fmt.Println(string(v.GetValues()[2].SVal))
			fmt.Println(string(v.GetValues()[3].SVal))
			fmt.Println(string(v.GetValues()[4].SVal))
		}
	}

	fmt.Print("\n")
	log.Info("Nebula Go Client Basic Example Finished")
}

output:

&{0xc0000e60e0 [id name batchno process pass] map[batchno:2 id:0 name:1 pass:4 process:3] {0 [85 84 67]}}

问题已经解决。之前我写的sql是这样:

use manager;MATCH (v:node{batchno: "BF14CDZ1-210107A1-02"})<-[e:follow*]-(v2) RETURN 
				distinct v2.node.id as id, v2.node.name as name, 
				v2.node.batchno as batchno, v2.node.process as process, 
				v2.node.pass as pass ORDER BY id asc;

注意上面是两个sql语句连在一起的,先是 use manager 指定空间,再是具体的业务sql。这样的写法在服务器版本3.2.0是可以正常工作的。

现在我升级到了服务器3.4.0,上面的写法就不行了。两句sql必须分开执行。不知这样的表现行为是有意这么设计,还是前后不兼容的bug?

hi, @supermario1990 我记得之前有一个 bug 是用户 use space 和 rebuild index 的操作一起,触发了某个 bug,还有 use space 之后不能识别后面的语句(参考这个帖子:https://discuss.nebula-graph.com.cn/t/topic/12707/10?u=steam )所以应该是在某个版本开始,use space 要和具体的 query 语句分开了(抱歉我已经不大记得具体的版本号了) cc @wey-gu @pythonsan

Hi, @ supermario1990 I remember previously there was a bug where users use use space and rebuild index operations together, triggering a certain bug. Also after use space, the subsequent statements could not be recognized (refer to this post: https://discuss.nebula-graph.com.cn/t/topic/12707/10?u=steam) So it should be that starting from a certain version, use space needs to be separated from the specific query statements (sorry I don't really remember the exact version number anymore).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Type: question about the product
Projects
None yet
Development

No branches or pull requests

4 participants