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

应用程序使用go连接器,查询时报错,程序异常退出(ARM32位处理器)。 #15846

Closed
wild-River2016 opened this issue Aug 8, 2022 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@wild-River2016
Copy link

Bug Description
应用程序使用go连接器,查询时报错,程序异常退出(ARM32位处理器)。

To Reproduce
Steps to reproduce the behavior:

  1. 应用程序和TDengine都在ARM32位处理器上。
  2. TDengine在ARM32处理器上,通过taos可正常数据写入和查询。
  3. 通过应用程序将数据写入TDenginer正常。
  4. 通过应用程序查询数据时,go连接器报错,导致程序结束。

Expected Behavior
希望查询能正常返回数据。
请问目前go版本的连接器(github.com/taosdata/driver-go/v2)是否支持arm32位处理器。

Screenshots
下图为报错信息
image
下图为go连接器报错位置
image

Environment (please complete the following information):

  • OS: Linux version 3.10.108
  • Memory: 2G
  • CPU: ARMv7 Processor rev 5 (v7l)
  • current Disk Space: 1.5g
  • TDengine Version:TDengine-server-2.6.0.12

Additional Context
Add any other context about the problem here.

@wild-River2016 wild-River2016 added the bug Something isn't working label Aug 8, 2022
@fenghuazzm
Copy link
Contributor

请确认一下在 ARM32 处理器的机器上,通过 taos shell 能正常数据写入和查询吗?

@wild-River2016
Copy link
Author

@fenghuazzm 通过taos shell使用sql可以正常写入和查询。

@wild-River2016
Copy link
Author

应用程序通过go连接器,如果查询的时间范围没有数据,就不会报错。如果查询的时间范围有数据就会在github.com/taosdata/driver-go/v2/wrapper.convertFloat(0x9c90053d, 0x0, 0x4, {0xd857b8, 0x1, 0x1})这里类型转换这里报错。

@huskar-t
Copy link
Contributor

huskar-t commented Aug 9, 2022

@wild-River2016 driver-go 的版本提供下

@wild-River2016
Copy link
Author

@huskar-t github.com/taosdata/driver-go/v2 v2.0.4这个版本的。

@huskar-t
Copy link
Contributor

huskar-t commented Aug 9, 2022

@wild-River2016 请使用如下代码进行测试

package main

import (
	"database/sql"
	"fmt"
	"time"

	_ "github.com/taosdata/driver-go/v2/taosSql"
)

func main() {
	db, err := sql.Open("taosSql", "root:taosdata@tcp(localhost:6030)/")
	if err != nil {
		panic(err)
	}
	defer db.Close()
	_, err = db.Exec("create database if not exists example_taos_sql")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("create table if not exists example_taos_sql.stb(ts timestamp," +
		"c1 bool," +
		"c2 tinyint," +
		"c3 smallint," +
		"c4 int," +
		"c5 bigint," +
		"c6 tinyint unsigned," +
		"c7 smallint unsigned," +
		"c8 int unsigned," +
		"c9 bigint unsigned," +
		"c10 float," +
		"c11 double," +
		"c12 binary(20)," +
		"c13 nchar(20)" +
		") tags (info json)")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("create table if not exists example_taos_sql.tb1 using example_taos_sql.stb tags ('{\"name\":\"tb1\"}')")
	if err != nil {
		panic(err)
	}
	now := time.Now()
	_, err = db.Exec(fmt.Sprintf("insert into example_taos_sql.tb1 values ('%s',true,2,3,4,5,6,7,8,9,10.123,11.123,'binary','nchar')", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	rows, err := db.Query(fmt.Sprintf("select * from example_taos_sql.tb1 where ts = '%s'", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	for rows.Next() {
		var (
			ts  time.Time
			c1  bool
			c2  int8
			c3  int16
			c4  int32
			c5  int64
			c6  uint8
			c7  uint16
			c8  uint32
			c9  uint64
			c10 float32
			c11 float64
			c12 string
			c13 string
		)
		err = rows.Scan(
			&ts,
			&c1,
			&c2,
			&c3,
			&c4,
			&c5,
			&c6,
			&c7,
			&c8,
			&c9,
			&c10,
			&c11,
			&c12,
			&c13,
		)
		if err != nil {
			panic(err)
		}
		fmt.Println("ts:", ts.Local())
		fmt.Println("c1:", c1)
		fmt.Println("c2:", c2)
		fmt.Println("c3:", c3)
		fmt.Println("c4:", c4)
		fmt.Println("c5:", c5)
		fmt.Println("c6:", c6)
		fmt.Println("c7:", c7)
		fmt.Println("c8:", c8)
		fmt.Println("c9:", c9)
		fmt.Println("c10:", c10)
		fmt.Println("c11:", c11)
		fmt.Println("c12:", c12)
		fmt.Println("c13:", c13)
	}
}

@wild-River2016
Copy link
Author

@huskar-t 您好,运行结果如下。
image

@huskar-t
Copy link
Contributor

huskar-t commented Aug 9, 2022

@wild-River2016 请提供出错时的样本和示例程序

@wild-River2016
Copy link
Author

wild-River2016 commented Aug 9, 2022

@wild-River2016 您好,查询代码如下,使用的是tdengine_gorm
image
下图为查询异常创建的表结构和写入的数据。
表结构
image
写入数据
image
表中数据
image

@wild-River2016
Copy link
Author

wild-River2016 commented Aug 9, 2022

@huskar-t 您好,根据您提供的测试代码,我把其他的数据类型都去掉了,只保留了float类型。数据表的创建和数据写入正常,查询还是报相同的错误。

数据库信息如下。
image
查询报错信息如下。
image

测试代码如下


import (
	"database/sql"
	"fmt"
	_ "github.com/taosdata/driver-go/v2/taosSql"
	"time"
)

func main() {
	db, err := sql.Open("taosSql", "root:taosdata@tcp(localhost:6030)/")
	if err != nil {
		panic(err)
	}
	defer db.Close()
	_, err = db.Exec("create database if not exists example_taos_sql3")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("create table if not exists example_taos_sql3.stb(ts timestamp," +
		"c1 float," +
		"c2 float," +
		"c3 float," +
		"c4 float," +
		"c5 float," +
		"c6 float," +
		"c7 float" +
		") tags (info json)")
	if err != nil {
		panic(err)
	}

	_, err = db.Exec("create table if not exists example_taos_sql3.tb1 using example_taos_sql3.stb tags ('{\"name\":\"tb1\"}')")
	if err != nil {
		panic(err)
	}
	now := time.Now()
	_, err = db.Exec(fmt.Sprintf("insert into example_taos_sql3.tb1 values ('%s',1.123,2.123,3.123,4.123,5.123,6.123,7.123)", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	rows, err := db.Query(fmt.Sprintf("select * from example_taos_sql3.tb1 where ts = '%s'", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	for rows.Next() {
		var (
			ts time.Time
			c1 float32
			c2 float32
			c3 float32
			c4 float32
			c5 float32
			c6 float32
			c7 float32
		)
		rows.Scan(
			&ts,
			&c1,
			&c2,
			&c3,
			&c4,
			&c5,
			&c6,
			&c7,
		)
		if err != nil {
			panic(err)
		}
		fmt.Println("ts:", ts.Local())
		fmt.Println("c1:", c1)
		fmt.Println("c2:", c2)
		fmt.Println("c3:", c3)
		fmt.Println("c4:", c4)
		fmt.Println("c5:", c5)
		fmt.Println("c6:", c6)
		fmt.Println("c7:", c7)
	}
}








@wild-River2016
Copy link
Author

wild-River2016 commented Aug 9, 2022

@huskar-t 我又基于您提供的测试用例,将其中的部分数据类型删除掉,建表和数据写入正常,查询的时候还是报错。非常奇怪,感觉查询的时候表里缺少某些数据类型,就会报错。
报错信息
image

测试代码如下:


import (
	"database/sql"
	"fmt"
	_ "github.com/taosdata/driver-go/v2/taosSql"
	"time"
)

func main() {
	db, err := sql.Open("taosSql", "root:taosdata@tcp(localhost:6030)/")
	if err != nil {
		panic(err)
	}
	defer db.Close()
	_, err = db.Exec("create database if not exists example_taos_sql8")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("create table if not exists example_taos_sql8.stb(ts timestamp," +
		"c1 bool," +
		"c2 tinyint," +
		"c3 float," +
		"c4 double," +
		"c5 nchar(20)" +
		") tags (info json)")
	if err != nil {
		panic(err)
	}
	_, err = db.Exec("create table if not exists example_taos_sql8.tb1 using example_taos_sql8.stb tags ('{\"name\":\"tb1\"}')")
	if err != nil {
		panic(err)
	}
	now := time.Now()
	_, err = db.Exec(fmt.Sprintf("insert into example_taos_sql8.tb1 values ('%s',true,2,10.123,11.123,'nchar')", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	rows, err := db.Query(fmt.Sprintf("select * from example_taos_sql8.tb1 where ts = '%s'", now.Format(time.RFC3339Nano)))
	if err != nil {
		panic(err)
	}
	for rows.Next() {
		var (
			ts time.Time
			c1 bool
			c2 int8
			c3 float32
			c4 float64
			c5 string
		)
		err = rows.Scan(
			&ts,
			&c1,
			&c2,
			&c3,
			&c4,
			&c5,
		)
		if err != nil {
			panic(err)
		}
		fmt.Println("ts:", ts.Local())
		fmt.Println("c1:", c1)
		fmt.Println("c2:", c2)
		fmt.Println("c3:", c3)
		fmt.Println("c4:", c4)
		fmt.Println("c5:", c5)
	}
}

@huskar-t
Copy link
Contributor

@wild-River2016 请使用 driver-go/v2 v2.0.5 再试下

@wild-River2016
Copy link
Author

@huskar-t 可以了,多谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants