Git Product home page Git Product logo

driver-go's Introduction

Go Connector for TDengine

Build Status

English | 简体中文

[TDengine] provides Go database/sql driver as [taosSql][driver-go].

Remind

v2 is not compatible with v3 version and corresponds to the TDengine version as follows:

driver-go version TDengine version major features
v3.5.1 3.2.1.0+ / 3.1.1.13+ native stmt query and geometry support
v3.5.0 3.0.5.0+ tmq: get assignment and seek offset
v3.3.1 3.0.4.1+ schemaless insert over websocket
v3.1.0 3.0.2.2+ provide tmq apis close to kafka
v3.0.4 3.0.2.2+ add request id
v3.0.3 3.0.1.5+ statement insert over websocket
v3.0.2 3.0.1.5+ bulk pulling over websocket
v3.0.1 3.0.0.0+ tmq over websocket
v3.0.0 3.0.0.0+ adapt to TDengine 3.0 query and insert

Install

Go 1.14+ is highly recommended for newly created projects.

go mod init taos-demo

import taosSql:

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

Use go mod for module management:

go mod tidy

Or go get to directly install it:

go get github.com/taosdata/driver-go/v3/taosSql

Usage

database/sql Standard

A simple use case:

package main

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

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

func main() {
    var taosUri = "root:taosdata@tcp(localhost:6030)/"
    taos, err := sql.Open("taosSql", taosUri)
    if err != nil {
        fmt.Println("failed to connect TDengine, err:", err)
        return
    }
    defer taos.Close()
    taos.Exec("create database if not exists test")
    taos.Exec("use test")
    taos.Exec("create table if not exists tb1 (ts timestamp, a int)")
    _, err = taos.Exec("insert into tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
    if err != nil {
        fmt.Println("failed to insert, err:", err)
        return
    }
    rows, err := taos.Query("select * from tb1")
    if err != nil {
        fmt.Println("failed to select from table, err:", err)
        return
    }

    defer rows.Close()
    for rows.Next() {
        var r struct {
            ts time.Time
            a  int
        }
        err := rows.Scan(&r.ts, &r.a)
        if err != nil {
            fmt.Println("scan error:\n", err)
            return
        }
        fmt.Println(r.ts, r.a)
    }
}

APIs that are worthy to have a check:

  • sql.Open(DRIVER_NAME string, dataSourceName string) *DB

    This API will create a database/sql DB object, results with type *DB. DRIVER_NAME should be set as taosSql, and dataSourceName should be a URI like user:password@tcp(host:port)/dbname. For HA use case, use user:password@cfg(/etc/taos)/dbname to apply configs in /etc/taos/taos.cfg.

  • func (db *DB) Exec(query string, args ...interface{}) (Result, error)

    Execute non resultset SQLs, like create, alter etc.

  • func (db *DB) Query(query string, args ...interface{}) (*Rows, error)

    Execute a query with resultset.

  • func (db *DB) Close() error

    Close an DB object and disconnect.

Subscription

Create consumer:

func NewConsumer(conf *tmq.ConfigMap) (*Consumer, error)

Subscribe single topic:

func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error

Subscribe topics:

func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) error

Poll message:

func (c *Consumer) Poll(timeoutMs int) tmq.Event

Commit message:

func (c *Consumer) Commit() ([]tmq.TopicPartition, error)

Get assignment:

func (c *Consumer) Assignment() (partitions []tmq.TopicPartition, err error)

Seek offset:

func (c *Consumer) Seek(partition tmq.TopicPartition, ignoredTimeoutMs int) error

Unsubscribe:

func (c *Consumer) Unsubscribe() error

Close consumer:

func (c *Consumer) Close() error

Example code: examples/tmq/main.go.

schemaless

InfluxDB format:

func (conn *Connector) InfluxDBInsertLines(lines []string, precision string) error

Example code: examples/schemaless/influx/main.go.

OpenTSDB telnet format:

func (conn *Connector) OpenTSDBInsertTelnetLines(lines []string) error

Example code: examples/schemaless/telnet/main.go.

OpenTSDB json format:

func (conn *Connector) OpenTSDBInsertJsonPayload(payload string) error

Example code: examples/schemaless/json/main.go.

stmt insert

Prepare sql:

func (stmt *InsertStmt) Prepare(sql string) error

Set the child table name:

func (stmt *InsertStmt) SetSubTableName(name string) error

Set the table name:

func (stmt *InsertStmt) SetTableName(name string) error

Set the subtable name and tags:

func (stmt *InsertStmt) SetTableNameWithTags(tableName string, tags *param.Param) error

Bind parameters:

func (stmt *InsertStmt) BindParam(params []*param.Param, bindType *param.ColumnType) error

Add batch:

func (stmt *InsertStmt) AddBatch() error

implement:

func (stmt *InsertStmt) Execute() error

Get the number of affected rows:

func (stmt *InsertStmt) GetAffectedRows() int

Close stmt:

func (stmt *InsertStmt) Close() error

Example code: examples/stmtinsert/main.go.

restful implementation of the database/sql standard interface

A simple use case:

package main

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

    _ "github.com/taosdata/driver-go/v3/taosRestful"
)

func main() {
    var taosDSN = "root:taosdata@http(localhost:6041)/"
    taos, err := sql.Open("taosRestful", taosDSN)
    if err != nil {
        fmt.Println("failed to connect TDengine, err:", err)
        return
    }
    defer taos.Close()
    taos.Exec("create database if not exists test")
    taos.Exec("create table if not exists test.tb1 (ts timestamp, a int)")
    _, err = taos.Exec("insert into test.tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
    if err != nil {
        fmt.Println("failed to insert, err:", err)
        return
    }
    rows, err := taos.Query("select * from test.tb1")
    if err != nil {
        fmt.Println("failed to select from table, err:", err)
        return
    }

    defer rows.Close()
    for rows.Next() {
        var r struct {
            ts time.Time
            a  int
        }
        err := rows.Scan(&r.ts, &r.a)
        if err != nil {
            fmt.Println("scan error:\n", err)
            return
        }
        fmt.Println(r.ts, r.a)
    }
}

Usage of taosRestful

import

import (
    "database/sql"
    _ "github.com/taosdata/driver-go/v3/taosRestful"
)

The driverName of sql.Open is taosRestful

The DSN format is:

database username:database password@connection-method(domain or ip:port)/[database][? Parameter]

Example:

root:taosdata@http(localhost:6041)/test?readBufferSize=52428800

Parameters:

  • disableCompression Whether to accept compressed data, default is true Do not accept compressed data, set to false if the transferred data is compressed using gzip.
  • readBufferSize The default size of the buffer for reading data is 4K (4096), which can be adjusted upwards when there is a lot of data in the query result.

Usage restrictions

Since the restful interface is stateless, the use db syntax will not work, you need to put the db name into the sql statement, e.g. create table if not exists tb1 (ts timestamp, a int) to create table if not exists test.tb1 (ts timestamp, a int) otherwise it will report an error [0x217] Database not specified or available.

You can also put the db name in the DSN by changing root:taosdata@http(localhost:6041)/ to root:taosdata@http(localhost:6041)/test. Executing the create database statement when the specified db does not exist will not report an error, while executing other queries or inserts will report an error. The example is as follows:

package main

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

    _ "github.com/taosdata/driver-go/v3/taosRestful"
)

func main() {
    var taosDSN = "root:taosdata@http(localhost:6041)/test"
    taos, err := sql.Open("taosRestful", taosDSN)
    if err != nil {
        fmt.Println("failed to connect TDengine, err:", err)
        return
    }
    defer taos.Close()
    taos.Exec("create database if not exists test")
    taos.Exec("create table if not exists tb1 (ts timestamp, a int)")
    _, err = taos.Exec("insert into tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
    if err != nil {
        fmt.Println("failed to insert, err:", err)
        return
    }
    rows, err := taos.Query("select * from tb1")
    if err != nil {
        fmt.Println("failed to select from table, err:", err)
        return
    }

    defer rows.Close()
    for rows.Next() {
        var r struct {
            ts time.Time
            a  int
        }
        err := rows.Scan(&r.ts, &r.a)
        if err != nil {
            fmt.Println("scan error:\n", err)
            return
        }
        fmt.Println(r.ts, r.a)
    }
}

websocket implementation of the database/sql standard interface

A simple use case:

package main

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

    _ "github.com/taosdata/driver-go/v3/taosWS"
)

func main() {
    var taosDSN = "root:taosdata@ws(localhost:6041)/"
    taos, err := sql.Open("taosWS", taosDSN)
    if err != nil {
        fmt.Println("failed to connect TDengine, err:", err)
        return
    }
    defer taos.Close()
    taos.Exec("create database if not exists test")
    taos.Exec("create table if not exists test.tb1 (ts timestamp, a int)")
    _, err = taos.Exec("insert into test.tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)")
    if err != nil {
        fmt.Println("failed to insert, err:", err)
        return
    }
    rows, err := taos.Query("select * from test.tb1")
    if err != nil {
        fmt.Println("failed to select from table, err:", err)
        return
    }

    defer rows.Close()
    for rows.Next() {
        var r struct {
            ts time.Time
            a  int
        }
        err := rows.Scan(&r.ts, &r.a)
        if err != nil {
            fmt.Println("scan error:\n", err)
            return
        }
        fmt.Println(r.ts, r.a)
    }
}

Usage of websocket

import

import (
    "database/sql"
    _ "github.com/taosdata/driver-go/v3/taosWS"
)

The driverName of sql.Open is taosWS

The DSN format is:

database username:database password@connection-method(domain or ip:port)/[database][? parameter]

Example:

root:taosdata@ws(localhost:6041)/test?writeTimeout=10s&readTimeout=10m

Parameters:

  • writeTimeout The timeout to send data via websocket.
  • readTimeout The timeout to receive response data via websocket.
  • enableCompression Whether to compress the transmitted data, the default is false and no compressed data is sent.

Using tmq over websocket

Use tmq over websocket. The server needs to start taoAdapter.

Configure related API

  • func NewConfig(url string, chanLength uint) *Config

Create a configuration, pass in the websocket address and the length of the sending channel.

  • func (c *Config) SetConnectUser(user string) error

Set username.

  • func (c *Config) SetConnectPass(pass string) error

Set password.

  • func (c *Config) SetClientID(clientID string) error

Set the client ID.

  • func (c *Config) SetGroupID(groupID string) error

Set the subscription group ID.

  • func (c *Config) SetWriteWait(writeWait time.Duration) error

Set the waiting time for sending messages.

  • func (c *Config) SetMessageTimeout(timeout time.Duration) error

Set the message timeout.

  • func (c *Config) SetErrorHandler(f func(consumer *Consumer, err error))

Set the error handler.

  • func (c *Config) SetCloseHandler(f func())

Set the close handler.

Subscription related API

  • func NewConsumer(conf *tmq.ConfigMap) (*Consumer, error)

Create a consumer.

  • func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error

Subscribe a topic.

  • func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) error

Subscribe to topics.

  • func (c *Consumer) Poll(timeoutMs int) tmq.Event

Poll messages.

  • func (c *Consumer) Commit() ([]tmq.TopicPartition, error)

Commit message.

  • func (c *Consumer) Assignment() (partitions []tmq.TopicPartition, err error)

Get assignment.

  • func (c *Consumer) Seek(partition tmq.TopicPartition, ignoredTimeoutMs int) error

Seek offset.

  • func (c *Consumer) Close() error

Close the connection.

Example code: examples/tmqoverws/main.go.

Parameter binding via WebSocket

Use stmt via websocket. The server needs to start taoAdapter.

Configure related API

  • func NewConfig(url string, chanLength uint) *Config

    Create a configuration item, pass in the websocket address and the length of the sending pipe.

  • func (c *Config) SetCloseHandler(f func())

    Set close handler.

  • func (c *Config) SetConnectDB(db string) error

    Set connect DB.

  • func (c *Config) SetConnectPass(pass string) error

    Set password.

  • func (c *Config) SetConnectUser(user string) error

    Set username.

  • func (c *Config) SetErrorHandler(f func(connector *Connector, err error))

    Set error handler.

  • func (c *Config) SetMessageTimeout(timeout time.Duration) error

    Set the message timeout.

  • func (c *Config) SetWriteWait(writeWait time.Duration) error

    Set the waiting time for sending messages.

Parameter binding related API

  • func NewConnector(config *Config) (*Connector, error)

    Create a connection.

  • func (c *Connector) Init() (*Stmt, error)

    Initialize the parameters.

  • func (c *Connector) Close() error

    Close the connection.

  • func (s *Stmt) Prepare(sql string) error

    Parameter binding preprocessing SQL statement.

  • func (s *Stmt) SetTableName(name string) error

    Bind the table name parameter.

  • func (s *Stmt) SetTags(tags *param.Param, bindType *param.ColumnType) error

    Bind tags.

  • func (s *Stmt) BindParam(params []*param.Param, bindType *param.ColumnType) error

    Parameter bind multiple rows of data.

  • func (s *Stmt) AddBatch() error

    Add to a parameter-bound batch.

  • func (s *Stmt) Exec() error

    Execute a parameter binding.

  • func (s *Stmt) GetAffectedRows() int

    Gets the number of affected rows inserted by the parameter binding.

  • func (s *Stmt) Close() error

    Closes the parameter binding.

For a complete example of parameter binding, see GitHub example file

Directory structure

driver-go
├── af //advanced function
├── common //common function and constants
├── errors // error type
├── examples //examples
├── taosRestful // database operation standard interface (restful)
├── taosSql // database operation standard interface
├── types // inner type
├── wrapper // cgo wrapper
└── ws // websocket

Link

driver-go: https://github.com/taosdata/driver-go

TDengine: https://github.com/taosdata/TDengine

driver-go's People

Contributors

afwerar avatar chenquan avatar fanweixiao avatar gccgdb1234 avatar huolibo avatar huskar-t avatar jiacy-jcy avatar liuyq-617 avatar localvar avatar nanjj avatar plum-lihui avatar sangshuduo avatar sunpe avatar yihaodeng avatar zitsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

driver-go's Issues

调用数据查询接口偶尔会出现这个错误,导致程序崩溃

从异常日志看是调用Rows.Next()方法遍历数据的时候出错了,不清楚是为什么?

taos服务端没有任何异常日志,go异常日志如下,
goroutine 579 [syscall]:
github.com/taosdata/driver-go/v2/wrapper._Cfunc_taos_fetch_block(0x15a7f075c50, 0xc000f98038, 0x0)
_cgo_gotypes.go:257 +0x4f
github.com/taosdata/driver-go/v2/wrapper.TaosFetchBlock.func1(0x15a7f075c50, 0xc000f98038, 0xc000000000)
D:/works/gospace/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper/taosc.go:92 +0xaa
github.com/taosdata/driver-go/v2/wrapper.TaosFetchBlock(0x15a7f075c50, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper/taosc.go:92 +0x85
github.com/taosdata/driver-go/v2/taosSql.(*rows).taosFetchBlock(0xc000f6c270)
D:/works/gospace/pkg/mod/github.com/taosdata/driver-go/[email protected]/taosSql/rows.go:75 +0x4a
github.com/taosdata/driver-go/v2/taosSql.(*rows).Next(0xc000f6c270, 0xc000f8bc80, 0x8, 0x8, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/taosdata/driver-go/[email protected]/taosSql/rows.go:53 +0x356
database/sql.(*Rows).nextLocked(0xc000f8bc00, 0x100000000)
C:/Program Files/Go/src/database/sql/sql.go:2865 +0x182
database/sql.(*Rows).Next.func1()
C:/Program Files/Go/src/database/sql/sql.go:2843 +0x4d
database/sql.withLock(0x18c86b0, 0xc000f8bc30, 0xc000d06828)
C:/Program Files/Go/src/database/sql/sql.go:3294 +0x7e
database/sql.(*Rows).Next(0xc000f8bc00, 0xc00010e300)
C:/Program Files/Go/src/database/sql/sql.go:2842 +0xd2
iotStation/database.SelectBalancevalveInterval(0xc00120ca00, 0x138b, 0x0, 0x0, 0x0, 0xc0000ae360, 0x13, 0x0, 0x0, 0xc00015a197, ...)
D:/works/zoolon_iot/热力项目/iotstation/database/balancevalve.go:203 +0xba6
iotStation/northapi.(*HTTPServer).getGridData(0xc00002e1c0, 0x18d4078, 0xc00069a000, 0x0, 0x0)
D:/works/zoolon_iot/热力项目/iotstation/northapi/dashboard.go:265 +0xfbd
github.com/labstack/echo/v4/middleware.KeyAuthWithConfig.func1.1(0x18d4078, 0xc00069a000, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/middleware/key_auth.go:125 +0x57c
github.com/labstack/echo/v4.(*Echo).add.func1(0x18d4078, 0xc00069a000, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:552 +0xaa
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x18d4078, 0xc00069a000, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/middleware/cors.go:118 +0x447
github.com/labstack/echo/v4/middleware.RecoverWithConfig.func1.1(0x18d4078, 0xc00069a000, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/middleware/recover.go:98 +0x1a3
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00017c240, 0x18cc830, 0xc000172028, 0xc000670300)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:662 +0x1e2
net/http.serverHandler.ServeHTTP(0xc000c281c0, 0x18cc830, 0xc000172028, 0xc000670300)
C:/Program Files/Go/src/net/http/server.go:2887 +0x22b
net/http.initALPNRequest.ServeHTTP(0x18cd460, 0xc0000c5230, 0xc000016a80, 0xc000c281c0, 0x18cc830, 0xc000172028, 0xc000670300)
C:/Program Files/Go/src/net/http/server.go:3459 +0x149
net/http.(*http2serverConn).runHandler(0xc00064c780, 0xc000172028, 0xc000670300, 0xc0011c6ed0)
C:/Program Files/Go/src/net/http/h2_bundle.go:5723 +0xc5
created by net/http.(*http2serverConn).processHeaders
C:/Program Files/Go/src/net/http/h2_bundle.go:5453 +0x95b

goroutine 1 [semacquire]:
sync.runtime_Semacquire(0xc000694088)
C:/Program Files/Go/src/runtime/sema.go:56 +0x49
sync.(*WaitGroup).Wait(0xc000694080)
C:/Program Files/Go/src/sync/waitgroup.go:130 +0xd7
main.main()
D:/works/zoolon_iot/热力项目/iotstation/main.go:53 +0x4fe

goroutine 9 [IO wait]:
internal/poll.runtime_pollWait(0x15a7d3c6048, 0x72, 0xc00015ccc8)
C:/Program Files/Go/src/runtime/netpoll.go:222 +0x65
internal/poll.(*pollDesc).wait(0xc00015ce38, 0x72, 0xde8500, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_poll_runtime.go:87 +0xa5
internal/poll.execIO(0xc00015cc98, 0xc000d0b2a8, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:175 +0x2ad
internal/poll.(*FD).acceptOne(0xc00015cc80, 0x2b4, 0xc000d100f0, 0x2, 0x2, 0xc00015cc98, 0x0, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:810 +0xed
internal/poll.(*FD).Accept(0xc00015cc80, 0xc000fb36a0, 0x0, 0x0, 0x0, 0x0, 0x100000000000000, 0x0, 0x0, 0x0, ...)
C:/Program Files/Go/src/internal/poll/fd_windows.go:844 +0x3ca
net.(*netFD).accept(0xc00015cc80, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/fd_windows.go:139 +0xeb
net.(*TCPListener).accept(0xc000c22330, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/tcpsock_posix.go:139 +0x68
net.(*TCPListener).AcceptTCP(0xc000c22330, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/tcpsock.go:248 +0x85
github.com/labstack/echo/v4.tcpKeepAliveListener.Accept(0xc000c22330, 0x0, 0x0, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:971 +0x59
crypto/tls.(*listener).Accept(0xc000c22348, 0x0, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/tls.go:67 +0x6b
net/http.(*Server).Serve(0xc000c281c0, 0x18cbf30, 0xc000c22348, 0x0, 0x0)
C:/Program Files/Go/src/net/http/server.go:2981 +0x43a
github.com/labstack/echo/v4.(*Echo).StartTLS(0xc00017c240, 0xc0000ae547, 0xd, 0x178a320, 0x18ba490, 0x178a320, 0x18ba4a0, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:713 +0x648
iotStation/northapi.(*HTTPServer).webThread(0xc00002e1c0)
D:/works/zoolon_iot/热力项目/iotstation/northapi/httpServer.go:106 +0x208
created by iotStation/northapi.(*HTTPServer).Httpinit
D:/works/zoolon_iot/热力项目/iotstation/northapi/httpServer.go:100 +0x12cf

goroutine 50 [syscall]:
os/signal.signal_recv(0x0)
C:/Program Files/Go/src/runtime/sigqueue.go:168 +0xaf
os/signal.loop()
C:/Program Files/Go/src/os/signal/signal_unix.go:23 +0x2d
created by os/signal.Notify.func1.1
C:/Program Files/Go/src/os/signal/signal.go:151 +0x48

goroutine 51 [chan receive]:
main.handleCtrlC(0xc000656120, 0xc000694080)
D:/works/zoolon_iot/热力项目/iotstation/main.go:18 +0xae
created by main.main
D:/works/zoolon_iot/热力项目/iotstation/main.go:37 +0x1dc

goroutine 21 [select]:
iotStation/southapi.(*CeebicIot).workThread(0x1b3b080, 0x0)
D:/works/zoolon_iot/热力项目/iotstation/southapi/ceebic.go:294 +0x528
created by iotStation/southapi.(*CeebicIot).StartUp
D:/works/zoolon_iot/热力项目/iotstation/southapi/ceebic.go:452 +0xab4

goroutine 22 [IO wait]:
internal/poll.runtime_pollWait(0x15a7d3c6130, 0x72, 0xc00008e7c8)
C:/Program Files/Go/src/runtime/netpoll.go:222 +0x65
internal/poll.(*pollDesc).wait(0xc00008e938, 0x72, 0xde8500, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_poll_runtime.go:87 +0xa5
internal/poll.execIO(0xc00008e798, 0xc0001774e0, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:175 +0x2ad
internal/poll.(*FD).acceptOne(0xc00008e780, 0x2a4, 0xc000c4a000, 0x2, 0x2, 0xc00008e798, 0x0, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:810 +0xed
internal/poll.(*FD).Accept(0xc00008e780, 0xc0001778d8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
C:/Program Files/Go/src/internal/poll/fd_windows.go:844 +0x3ca
net.(*netFD).accept(0xc00008e780, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/fd_windows.go:139 +0xeb
net.(*TCPListener).accept(0xc0000a09d8, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/tcpsock_posix.go:139 +0x68
net.(*TCPListener).AcceptTCP(0xc0000a09d8, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/tcpsock.go:248 +0x85
github.com/labstack/echo/v4.tcpKeepAliveListener.Accept(0xc0000a09d8, 0x0, 0x0, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:971 +0x59
net/http.(*Server).Serve(0xc0006c4000, 0x18cc1a0, 0xc0000d8020, 0x0, 0x0)
C:/Program Files/Go/src/net/http/server.go:2981 +0x43a
github.com/labstack/echo/v4.(*Echo).Start(0xc00017c000, 0xc0000ae58d, 0xd, 0x0, 0x0)
D:/works/gospace/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:679 +0x187
iotStation/southapi.(*CeebicIot).StartUp.func1(0x1b3b080, 0xc0000ae58d, 0xd)
D:/works/zoolon_iot/热力项目/iotstation/southapi/ceebic.go:459 +0x1aa
created by iotStation/southapi.(*CeebicIot).StartUp
D:/works/zoolon_iot/热力项目/iotstation/southapi/ceebic.go:456 +0xb29

goroutine 10 [chan receive]:
github.com/natefinch/lumberjack.(*Logger).millRun(0xc000120480)
D:/works/gospace/pkg/mod/github.com/natefinch/[email protected]+incompatible/lumberjack.go:379 +0x4e
created by github.com/natefinch/lumberjack.(*Logger).mill.func1
D:/works/gospace/pkg/mod/github.com/natefinch/[email protected]+incompatible/lumberjack.go:390 +0x92

goroutine 11 [select]:
database/sql.(*DB).connectionOpener(0xc0006904e0, 0x18cd3b8, 0xc00002e300)
C:/Program Files/Go/src/database/sql/sql.go:1133 +0xd7
created by database/sql.OpenDB
C:/Program Files/Go/src/database/sql/sql.go:740 +0x265

goroutine 12 [select]:
net/http.(*http2serverConn).serve(0xc00064c780)
C:/Program Files/Go/src/net/http/h2_bundle.go:4428 +0xc7f
net/http.(*http2Server).ServeConn(0xc00002e340, 0x18d0ff8, 0xc000016a80, 0xc0006697c8)
C:/Program Files/Go/src/net/http/h2_bundle.go:4038 +0xdeb
net/http.http2ConfigureServer.func1(0xc000c281c0, 0xc000016a80, 0x18c55e0, 0xc000c26200)
C:/Program Files/Go/src/net/http/h2_bundle.go:3864 +0x1d1
net/http.(*conn).serve(0xc00006c320, 0x18cd460, 0xc0000c5230)
C:/Program Files/Go/src/net/http/server.go:1861 +0xb3c
created by net/http.(*Server).Serve
C:/Program Files/Go/src/net/http/server.go:3013 +0x974

goroutine 39 [IO wait]:
internal/poll.runtime_pollWait(0x15a7d3c5f60, 0x72, 0xc00015cf18)
C:/Program Files/Go/src/runtime/netpoll.go:222 +0x65
internal/poll.(*pollDesc).wait(0xc00015d0b8, 0x72, 0xde8500, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_poll_runtime.go:87 +0xa5
internal/poll.execIO(0xc00015cf18, 0x188cf30, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:175 +0x2ad
internal/poll.(*FD).Read(0xc00015cf00, 0xc000d8c700, 0x664, 0x664, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/internal/poll/fd_windows.go:441 +0x56d
net.(*netFD).Read(0xc00015cf00, 0xc000d8c700, 0x664, 0x664, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/fd_posix.go:55 +0x85
net.(*conn).Read(0xc0001722a0, 0xc000d8c700, 0x664, 0x664, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/net.go:183 +0xbc
crypto/tls.(*atLeastReader).Read(0xc0011c6ee8, 0xc000d8c700, 0x664, 0x664, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/conn.go:776 +0xd2
bytes.(*Buffer).ReadFrom(0xc000016cf8, 0x18c3bc0, 0xc0011c6ee8, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/bytes/buffer.go:204 +0x166
crypto/tls.(*Conn).readFromUntil(0xc000016a80, 0x15a7d4b28b8, 0xc0001722a0, 0x5, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/conn.go:798 +0x197
crypto/tls.(*Conn).readRecordOrCCS(0xc000016a80, 0xc000016a00, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/conn.go:605 +0x245
crypto/tls.(*Conn).readRecord(0xc000016a80, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/conn.go:573 +0x3f
crypto/tls.(*Conn).Read(0xc000016a80, 0xc0006c42d8, 0x9, 0x9, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/crypto/tls/conn.go:1276 +0x1db
io.ReadAtLeast(0x15a7d330c98, 0xc000016a80, 0xc0006c42d8, 0x9, 0x9, 0x9, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/io/io.go:328 +0x164
io.ReadFull(0x15a7d330c98, 0xc000016a80, 0xc0006c42d8, 0x9, 0x9, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/io/io.go:347 +0xb1
net/http.http2readFrameHeader(0xc0006c42d8, 0x9, 0x9, 0x15a7d330c98, 0xc000016a80, 0x0, 0xc000000000, 0x0, 0x0)
C:/Program Files/Go/src/net/http/h2_bundle.go:1477 +0xd3
net/http.(*http2Framer).ReadFrame(0xc0006c42a0, 0x0, 0x0, 0x0, 0x0)
C:/Program Files/Go/src/net/http/h2_bundle.go:1735 +0x14e
net/http.(*http2serverConn).readFrames(0xc00064c780)
C:/Program Files/Go/src/net/http/h2_bundle.go:4314 +0xf9
created by net/http.(*http2serverConn).serve
C:/Program Files/Go/src/net/http/h2_bundle.go:4420 +0x9bf

goroutine 573 [select]:
database/sql.(*DB).connectionOpener(0xc000c2a5b0, 0x18cd3b8, 0xc000c8b980)
C:/Program Files/Go/src/database/sql/sql.go:1133 +0xd7
created by database/sql.OpenDB
C:/Program Files/Go/src/database/sql/sql.go:740 +0x265

goroutine 371 [select]:
database/sql.(*DB).connectionCleaner(0xc00002c4e0, 0x174876e800)
C:/Program Files/Go/src/database/sql/sql.go:1005 +0x125
created by database/sql.(*DB).startCleanerLocked
C:/Program Files/Go/src/database/sql/sql.go:992 +0x12a

goroutine 383 [select]:
github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc00071afc0, 0xc00122e5a0, 0xc00071e6c0)
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:614 +0x110
created by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:611 +0xef

goroutine 207 [select]:
database/sql.(*DB).connectionOpener(0xc00002c4e0, 0x18cd3b8, 0xc000658740)
C:/Program Files/Go/src/database/sql/sql.go:1133 +0xd7
created by database/sql.OpenDB
C:/Program Files/Go/src/database/sql/sql.go:740 +0x265

goroutine 525 [select]:
github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc000d900c0, 0xc001080120, 0xc000660180)
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:614 +0x110
created by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:611 +0xef

goroutine 512 [select]:
github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher.func1(0xc000120b40, 0xc0006a6240, 0xc000f422a0)
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:614 +0x110
created by github.com/go-sql-driver/mysql.(*mysqlConn).startWatcher
D:/works/gospace/pkg/mod/github.com/go-sql-driver/[email protected]/connection.go:611 +0xef
rax 0xffffffffffffabad
rbx 0xc000d06448
rcx 0xfffffffffffd528d
rdi 0x15a7f4fd000
rsi 0x15a7f6a59a0
rbp 0x198b7ff8a0
rsp 0x198b7ff230
r8 0x42
r9 0x8
r10 0x15a56580000
r11 0x198b7feef8
r12 0x15a7d45c5e8
r13 0xaaaaaaaaaaaaaa
r14 0x10
r15 0x10
rip 0x7ff87918dfab
rflags 0x10282
cs 0x33
fs 0x53
gs 0x2b

在arm64中编译错误

 go get github.com/taosdata/driver-go/v2/taosSql
go: downloading github.com/taosdata/driver-go/v2 v2.0.1
package github.com/taosdata/driver-go/v2/taosSql
        imports github.com/taosdata/driver-go/v2/wrapper: build constraints exclude all Go files in /home/xxxx/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper

GOARCH="arm64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"

快速连续插入时,出现:fatal error: invalid pointer found on stack,程序强制退出

执行插入部分代码如下:
func insertDateToTDengine(c *OpcClientManager) { var cols []string var vals []string for col, val := range c.dataMap { cols = append(cols, col) vals = append(vals, strconv.Itoa(int(val))) } sql := fmt.Sprintf("INSERT INTO %s (ts,%s) values (now,%s)", c.Config.TableName, strings.Join(cols, ","), strings. Join(vals, ",")) //fmt.Println(sql) result, err := taos.Exec(sql) if utils.HasError(err) { fmt.Println(err) } _, err = result.RowsAffected() if utils.HasError(err) { fmt.Println(err) } //fmt.Println(affected) }
控制台打印错误如下:
runtime: bad pointer in frame github.com/taosdata/driver-go/v3/wrapper.TaosQueryA.func2 at 0xc000ba1510: 0xd8
fatal error: invalid pointer found on stack

runtime stack:
runtime.throw({0xe48ddc?, 0xd10a20?})
C:/Program Files/Go/src/runtime/panic.go:1047 +0x65 fp=0x7fa86ff628 sp=0x7fa86ff5f8 pc=0x989ea5
runtime.adjustpointers(0x7fa86ffa30?, 0xee68c?, 0x113662e?, {0x11dc6b0?, 0xd10a20?})
C:/Program Files/Go/src/runtime/stack.go:630 +0x1d0 fp=0x7fa86ff690 sp=0x7fa86ff628 pc=0x99eeb0
runtime.adjustframe(0x7fa86ffa30, 0x7fa86ffb20)
C:/Program Files/Go/src/runtime/stack.go:672 +0xc9 fp=0x7fa86ff720 sp=0x7fa86ff690 pc=0x99efc9
runtime.gentraceback(0x0?, 0x0?, 0x0?, 0x7ff9a6bbb8cd?, 0x0, 0x0, 0x7fffffff, 0xef6ae0, 0x0?, 0x0)
C:/Program Files/Go/src/runtime/traceback.go:334 +0xd0f fp=0x7fa86ffa98 sp=0x7fa86ff720 pc=0x9aab6f
runtime.copystack(0xc000414680, 0x7fa86ffc88?)
C:/Program Files/Go/src/runtime/stack.go:932 +0x2f5 fp=0x7fa86ffc50 sp=0x7fa86ffa98 pc=0x99f7d5
runtime.shrinkstack(0xc000414680)
C:/Program Files/Go/src/runtime/stack.go:1214 +0x126 fp=0x7fa86ffc70 sp=0x7fa86ffc50 pc=0x9a06a6
runtime.newstack()
C:/Program Files/Go/src/runtime/stack.go:1062 +0x3aa fp=0x7fa86ffe28 sp=0x7fa86ffc70 pc=0x99fc6a
runtime.morestack()
C:/Program Files/Go/src/runtime/asm_amd64.s:570 +0x93 fp=0x7fa86ffe30 sp=0x7fa86ffe28 pc=0x9b5913

goroutine 14 [running]:
runtime.cgoCheckPointer({0xd92d60, 0xd8}, {0x0, 0x0})
C:/Program Files/Go/src/runtime/cgocall.go:394 +0x196 fp=0xc000ba14f0 sp=0xc000ba14e8 pc=0x9551b6
github.com/taosdata/driver-go/v3/wrapper.TaosQueryA.func2(0x2637b694b80?, 0x8f?, 0xc00027d578?)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper/taosc.go:147 +0x52 fp=0xc000ba1538 sp=0xc000ba14f0 pc=0xcf52f2
github.com/taosdata/driver-go/v3/wrapper.TaosQueryA(0xc00027d5b8?, {0xc000468750?, 0xdb6460?}, 0xdf44e0?)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/wrapper/taosc.go:147 +0x6d fp=0xc000ba1588 sp=0xc000ba1538 pc=0xcf522d
github.com/taosdata/driver-go/v3/taosSql.(*taosConn).taosQuery(0xc00089a910, {0xc000468750, 0x8f}, 0xc00062cff0)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/taosSql/connection.go:169 +0x65 fp=0xc000ba15c0 sp=0xc000ba1588 pc=0xcf7685
github.com/taosdata/driver-go/v3/taosSql.(*taosConn).Exec(0xc00089a910, {0xc000468750?, 0x0?}, {0x123bf00?, 0x0?, 0xc00027d708?})
C:/Users/HN-LPC-229/go/pkg/mod/github.com/taosdata/driver-go/[email protected]/taosSql/connection.go:93 +0x17d fp=0xc000ba1688 sp=0xc000ba15c0 pc=0xcf731d
database/sql.ctxDriverExec({0xf82790, 0xc00001a0a8}, {0x0?, 0x0?}, {0x263796a3fe8, 0xc00089a910}, {0xc000468750, 0x8f}, {0x123bf00, 0x0, ...})
C:/Program Files/Go/src/database/sql/ctxutil.go:43 +0x189 fp=0xc000ba1710 sp=0xc000ba1688 pc=0xce29e9
database/sql.(*DB).execDC.func2()
C:/Program Files/Go/src/database/sql/sql.go:1679 +0x175 fp=0xc000ba17d8 sp=0xc000ba1710 pc=0xce78d5
database/sql.withLock({0xf810f0, 0xc0000f01b0}, 0xc00027d988)
C:/Program Files/Go/src/database/sql/sql.go:3439 +0x8c fp=0xc000ba1818 sp=0xc000ba17d8 pc=0xce7f4c
database/sql.(*DB).execDC(0x1000000d92c01?, {0xf82790, 0xc00001a0a8}, 0xc0000f01b0, 0x9cf7de?, {0xc000468750, 0x8f}, {0x0, 0x0, 0x0})
C:/Program Files/Go/src/database/sql/sql.go:1674 +0x266 fp=0xc000ba1a28 sp=0xc000ba1818 pc=0xce7226
database/sql.(*DB).exec(0xa23a4a?, {0xf82790, 0xc00001a0a8}, {0xc000468750, 0x8f}, {0x0, 0x0, 0x0}, 0x8f?)
C:/Program Files/Go/src/database/sql/sql.go:1659 +0xe8 fp=0xc000ba1aa0 sp=0xc000ba1a28 pc=0xce6f48
database/sql.(*DB).ExecContext(0xe5c6a6?, {0xf82790, 0xc00001a0a8}, {0xc000468750, 0x8f}, {0x0, 0x0, 0x0})
C:/Program Files/Go/src/database/sql/sql.go:1633 +0xe5 fp=0xc000ba1b28 sp=0xc000ba1aa0 pc=0xce6d25
database/sql.(*DB).Exec(...)
C:/Program Files/Go/src/database/sql/sql.go:1651
TDengineTest/src/client.insertDateToTDengine(0xc0000f80e0)
D:/work/go-workspace/TDengineTest/src/client/opc_client.go:127 +0x389 fp=0xc000ba1cb8 sp=0xc000ba1b28 pc=0xcfd9c9
TDengineTest/src/client.(*OpcClientManager).OpcReadMsg(0xc0000f80e0)
D:/work/go-workspace/TDengineTest/src/client/opc_client.go:113 +0x6a5 fp=0xc000ba1ea0 sp=0xc000ba1cb8 pc=0xcfd5c5
TDengineTest/src/client.(*OpcClientManager).StartOpcClient(0xc0000f80e0)
D:/work/go-workspace/TDengineTest/src/client/opc_client.go:61 +0x1ae fp=0xc000ba1fc8 sp=0xc000ba1ea0 pc=0xcfce2e
TDengineTest/src/client.StartAllOpcClient.func1()
D:/work/go-workspace/TDengineTest/src/client/client_manager.go:20 +0x26 fp=0xc000ba1fe0 sp=0xc000ba1fc8 pc=0xcfc7a6
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000ba1fe8 sp=0xc000ba1fe0 pc=0x9b7b41
created by TDengineTest/src/client.StartAllOpcClient
D:/work/go-workspace/TDengineTest/src/client/client_manager.go:20 +0x21c

goroutine 1 [semacquire, 6 minutes]:
runtime.gopark(0x0?, 0xc00035d400?, 0xc0?, 0xd2?, 0xc000902db0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc00094fea0 sp=0xc00094fe80 pc=0x98c976
runtime.goparkunlock(...)
C:/Program Files/Go/src/runtime/proc.go:369
runtime.semacquire1(0x123c068, 0x0?, 0x1, 0x0)
C:/Program Files/Go/src/runtime/sema.go:150 +0x20f fp=0xc00094ff08 sp=0xc00094fea0 pc=0x99be0f
sync.runtime_Semacquire(0xc00035d2c0?)
C:/Program Files/Go/src/runtime/sema.go:62 +0x25 fp=0xc00094ff38 sp=0xc00094ff08 pc=0x9b33e5
sync.(*WaitGroup).Wait(0x100d8e420?)
C:/Program Files/Go/src/sync/waitgroup.go:139 +0x52 fp=0xc00094ff60 sp=0xc00094ff38 pc=0x9d0812
main.main()
D:/work/go-workspace/TDengineTest/main.go:80 +0x45 fp=0xc00094ff80 sp=0xc00094ff60 pc=0xcfe1c5
runtime.main()
C:/Program Files/Go/src/runtime/proc.go:250 +0x1fe fp=0xc00094ffe0 sp=0xc00094ff80 pc=0x98c5de
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00094ffe8 sp=0xc00094ffe0 pc=0x9b7b41

goroutine 2 [force gc (idle), 6 minutes]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000053fb0 sp=0xc000053f90 pc=0x98c976
runtime.goparkunlock(...)
C:/Program Files/Go/src/runtime/proc.go:369
runtime.forcegchelper()
C:/Program Files/Go/src/runtime/proc.go:302 +0xb1 fp=0xc000053fe0 sp=0xc000053fb0 pc=0x98c811
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000053fe8 sp=0xc000053fe0 pc=0x9b7b41
created by runtime.init.6
C:/Program Files/Go/src/runtime/proc.go:290 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000055f90 sp=0xc000055f70 pc=0x98c976
runtime.goparkunlock(...)
C:/Program Files/Go/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
C:/Program Files/Go/src/runtime/mgcsweep.go:297 +0xd7 fp=0xc000055fc8 sp=0xc000055f90 pc=0x9762d7
runtime.gcenable.func1()
C:/Program Files/Go/src/runtime/mgc.go:178 +0x26 fp=0xc000055fe0 sp=0xc000055fc8 pc=0x96ae26
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000055fe8 sp=0xc000055fe0 pc=0x9b7b41
created by runtime.gcenable
C:/Program Files/Go/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0x190bdc2684914?, 0x20a954?, 0x0?, 0x0?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000065f70 sp=0xc000065f50 pc=0x98c976
runtime.goparkunlock(...)
C:/Program Files/Go/src/runtime/proc.go:369
runtime.(*scavengerState).park(0x11e6c20)
C:/Program Files/Go/src/runtime/mgcscavenge.go:389 +0x53 fp=0xc000065fa0 sp=0xc000065f70 pc=0x974313
runtime.bgscavenge(0x0?)
C:/Program Files/Go/src/runtime/mgcscavenge.go:622 +0x65 fp=0xc000065fc8 sp=0xc000065fa0 pc=0x974925
runtime.gcenable.func2()
C:/Program Files/Go/src/runtime/mgc.go:179 +0x26 fp=0xc000065fe0 sp=0xc000065fc8 pc=0x96adc6
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000065fe8 sp=0xc000065fe0 pc=0x9b7b41
created by runtime.gcenable
C:/Program Files/Go/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait, 6 minutes]:
runtime.gopark(0x11e7220?, 0xc000050ea0?, 0x0?, 0x0?, 0xc000057f70?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000057e28 sp=0xc000057e08 pc=0x98c976
runtime.goparkunlock(...)
C:/Program Files/Go/src/runtime/proc.go:369
runtime.runfinq()
C:/Program Files/Go/src/runtime/mfinal.go:180 +0x10f fp=0xc000057fe0 sp=0xc000057e28 pc=0x969f2f
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000057fe8 sp=0xc000057fe0 pc=0x9b7b41
created by runtime.createfing
C:/Program Files/Go/src/runtime/mfinal.go:157 +0x45

goroutine 18 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x1?, 0x7c?, 0xb3?, 0x9573e9?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000067f50 sp=0xc000067f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc000067fe0 sp=0xc000067f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000067fe8 sp=0xc000067fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 34 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000061f50 sp=0xc000061f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc000061fe0 sp=0xc000061f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000061fe8 sp=0xc000061fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 35 [GC worker (idle)]:
runtime.gopark(0x190be3a0bafec?, 0x3?, 0x0?, 0x0?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000063f50 sp=0xc000063f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc000063fe0 sp=0xc000063f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000063fe8 sp=0xc000063fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 19 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x1?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0004a1f50 sp=0xc0004a1f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0004a1fe0 sp=0xc0004a1f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0004a1fe8 sp=0xc0004a1fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 7 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc00049df50 sp=0xc00049df30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00049dfe0 sp=0xc00049df50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00049dfe8 sp=0xc00049dfe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 8 [GC worker (idle)]:
runtime.gopark(0x190be3a0bafec?, 0x1?, 0x78?, 0x9e?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc00049ff50 sp=0xc00049ff30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc00049ffe0 sp=0xc00049ff50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc00049ffe8 sp=0xc00049ffe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 20 [GC worker (idle)]:
runtime.systemstack_switch()
C:/Program Files/Go/src/runtime/asm_amd64.s:459 fp=0xc0004a3f50 sp=0xc0004a3f48 pc=0x9b57c0
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1295 +0x209 fp=0xc0004a3fe0 sp=0xc0004a3f50 pc=0x96d149
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0004a3fe8 sp=0xc0004a3fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 9 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003d7f50 sp=0xc0003d7f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003d7fe0 sp=0xc0003d7f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003d7fe8 sp=0xc0003d7fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 21 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003d3f50 sp=0xc0003d3f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003d3fe0 sp=0xc0003d3f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003d3fe8 sp=0xc0003d3fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 10 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0xa4?, 0x80?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003d9f50 sp=0xc0003d9f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003d9fe0 sp=0xc0003d9f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003d9fe8 sp=0xc0003d9fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 22 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003d5f50 sp=0xc0003d5f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003d5fe0 sp=0xc0003d5f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003d5fe8 sp=0xc0003d5fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 11 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0xa4?, 0x80?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003dff50 sp=0xc0003dff30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003dffe0 sp=0xc0003dff50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003dffe8 sp=0xc0003dffe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 23 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0xa4?, 0x80?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003dbf50 sp=0xc0003dbf30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003dbfe0 sp=0xc0003dbf50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003dbfe8 sp=0xc0003dbfe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 12 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003e1f50 sp=0xc0003e1f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003e1fe0 sp=0xc0003e1f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003e1fe8 sp=0xc0003e1fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 24 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x3?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003ddf50 sp=0xc0003ddf30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003ddfe0 sp=0xc0003ddf50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003ddfe8 sp=0xc0003ddfe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 13 [GC worker (idle)]:
runtime.gopark(0x123d4a0?, 0x1?, 0x7c?, 0xb3?, 0x0?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003e7f50 sp=0xc0003e7f30 pc=0x98c976
runtime.gcBgMarkWorker()
C:/Program Files/Go/src/runtime/mgc.go:1235 +0xf1 fp=0xc0003e7fe0 sp=0xc0003e7f50 pc=0x96d031
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003e7fe8 sp=0xc0003e7fe0 pc=0x9b7b41
created by runtime.gcBgMarkStartWorkers
C:/Program Files/Go/src/runtime/mgc.go:1159 +0x25

goroutine 50 [select, 6 minutes]:
runtime.gopark(0xc0003e3f88?, 0x2?, 0x11?, 0x0?, 0xc0003e3f84?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0003e3e10 sp=0xc0003e3df0 pc=0x98c976
runtime.selectgo(0xc0003e3f88, 0xc0003e3f80, 0x0?, 0x0, 0x0?, 0x1)
C:/Program Files/Go/src/runtime/select.go:328 +0x7dc fp=0xc0003e3f50 sp=0xc0003e3e10 pc=0x99ad1c
database/sql.(*DB).connectionOpener(0xc000634340, {0xf82758, 0xc000629380})
C:/Program Files/Go/src/database/sql/sql.go:1224 +0x8d fp=0xc0003e3fb8 sp=0xc0003e3f50 pc=0xce542d
database/sql.OpenDB.func1()
C:/Program Files/Go/src/database/sql/sql.go:792 +0x2e fp=0xc0003e3fe0 sp=0xc0003e3fb8 pc=0xce436e
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0003e3fe8 sp=0xc0003e3fe0 pc=0x9b7b41
created by database/sql.OpenDB
C:/Program Files/Go/src/database/sql/sql.go:792 +0x18d

goroutine 67 [IO wait]:
runtime.gopark(0x0?, 0xc000622518?, 0xc8?, 0x25?, 0xc000622548?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0009516a8 sp=0xc000951688 pc=0x98c976
runtime.netpollblock(0x0?, 0xf87380?, 0x0?)
C:/Program Files/Go/src/runtime/netpoll.go:526 +0xf7 fp=0xc0009516e0 sp=0xc0009516a8 pc=0x983177
internal/poll.runtime_pollWait(0x2637b790f08, 0x72)
C:/Program Files/Go/src/runtime/netpoll.go:305 +0x89 fp=0xc000951700 sp=0xc0009516e0 pc=0x9b1a09
internal/poll.(*pollDesc).wait(0x96e436?, 0x4b69f8?, 0x0)
C:/Program Files/Go/src/internal/poll/fd_poll_runtime.go:84 +0x32 fp=0xc000951728 sp=0xc000951700 pc=0xa16632
internal/poll.execIO(0xc000622518, 0xef6840)
C:/Program Files/Go/src/internal/poll/fd_windows.go:175 +0xe5 fp=0xc000951780 sp=0xc000951728 pc=0xa16dc5
internal/poll.(*FD).Read(0xc000622500, {0xc000b44000, 0x8, 0xffff})
C:/Program Files/Go/src/internal/poll/fd_windows.go:441 +0x26b fp=0xc000951810 sp=0xc000951780 pc=0xa17c4b
net.(*netFD).Read(0xc000622500, {0xc000b44000?, 0x1010163539b0eb8?, 0x26379562b98?})
C:/Program Files/Go/src/net/fd_posix.go:55 +0x29 fp=0xc000951858 sp=0xc000951810 pc=0xaac289
net.(*conn).Read(0xc0009001a0, {0xc000b44000?, 0xc0002798d8?, 0x99d7b2?})
C:/Program Files/Go/src/net/net.go:183 +0x45 fp=0xc0009518a0 sp=0xc000951858 pc=0xab8d45
io.ReadAtLeast({0xf7fce0, 0xc0000f6b40}, {0xc000b44000, 0x8, 0xffff}, 0x8)
C:/Program Files/Go/src/io/io.go:332 +0x9a fp=0xc0009518e8 sp=0xc0009518a0 pc=0x9f211a
io.ReadFull(...)
C:/Program Files/Go/src/io/io.go:351
github.com/gopcua/opcua/uacp.(*Conn).Receive(0xc0000f6b40?)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uacp/conn.go:349 +0x91 fp=0xc000951a48 sp=0xc0009518e8 pc=0xcc3431
github.com/gopcua/opcua/uasc.(*SecureChannel).readChunk(0xc000020750)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:342 +0x3d fp=0xc000951c20 sp=0xc000951a48 pc=0xccfbdd
github.com/gopcua/opcua/uasc.(*SecureChannel).receive(0xc000020750, {0xf82758, 0xc000090b80})
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:246 +0x7b fp=0xc000951e48 sp=0xc000951c20 pc=0xccef3b
github.com/gopcua/opcua/uasc.(*SecureChannel).dispatcher(0xc000020750)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:187 +0xce fp=0xc000951fc8 sp=0xc000951e48 pc=0xcce8ce
github.com/gopcua/opcua/uasc.(*SecureChannel).open.func1.1()
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:479 +0x26 fp=0xc000951fe0 sp=0xc000951fc8 pc=0xcd11a6
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000951fe8 sp=0xc000951fe0 pc=0x9b7b41
created by github.com/gopcua/opcua/uasc.(*SecureChannel).open.func1
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:479 +0x5a

goroutine 68 [select, 6 minutes]:
runtime.gopark(0xc0008a9f38?, 0x2?, 0xf8?, 0x9d?, 0xc0008a9f04?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0008a9d70 sp=0xc0008a9d50 pc=0x98c976
runtime.selectgo(0xc0008a9f38, 0xc0008a9f00, 0x0?, 0x0, 0x0?, 0x1)
C:/Program Files/Go/src/runtime/select.go:328 +0x7dc fp=0xc0008a9eb0 sp=0xc0008a9d70 pc=0x99ad1c
github.com/gopcua/opcua/uasc.(*SecureChannel).scheduleRenewal(0xc000020750, 0xc000166000)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:599 +0x2e5 fp=0xc0008a9fc0 sp=0xc0008a9eb0 pc=0xcd1c65
github.com/gopcua/opcua/uasc.(*SecureChannel).handleOpenSecureChannelResponse.func2()
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:581 +0x2a fp=0xc0008a9fe0 sp=0xc0008a9fc0 pc=0xcd18ea
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0008a9fe8 sp=0xc0008a9fe0 pc=0x9b7b41
created by github.com/gopcua/opcua/uasc.(*SecureChannel).handleOpenSecureChannelResponse
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:581 +0x49f

goroutine 69 [select, 6 minutes]:
runtime.gopark(0xc0008abf40?, 0x2?, 0xa0?, 0xbd?, 0xc0008abec4?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0008abd18 sp=0xc0008abcf8 pc=0x98c976
runtime.selectgo(0xc0008abf40, 0xc0008abec0, 0x0?, 0x0, 0x0?, 0x1)
C:/Program Files/Go/src/runtime/select.go:328 +0x7dc fp=0xc0008abe58 sp=0xc0008abd18 pc=0x99ad1c
github.com/gopcua/opcua/uasc.(*SecureChannel).scheduleExpiration(0xc000020750, 0xc000166000)
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:631 +0x30c fp=0xc0008abfc0 sp=0xc0008abe58 pc=0xcd22ac
github.com/gopcua/opcua/uasc.(*SecureChannel).handleOpenSecureChannelResponse.func3()
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:582 +0x2a fp=0xc0008abfe0 sp=0xc0008abfc0 pc=0xcd188a
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0008abfe8 sp=0xc0008abfe0 pc=0x9b7b41
created by github.com/gopcua/opcua/uasc.(*SecureChannel).handleOpenSecureChannelResponse
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/uasc/secure_channel.go:582 +0x4fb

goroutine 70 [select, 6 minutes]:
runtime.gopark(0xc000953f88?, 0x2?, 0x0?, 0x0?, 0xc000953d74?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc000953b60 sp=0xc000953b40 pc=0x98c976
runtime.selectgo(0xc000953f88, 0xc000953d70, 0x0?, 0x0, 0x0?, 0x1)
C:/Program Files/Go/src/runtime/select.go:328 +0x7dc fp=0xc000953ca0 sp=0xc000953b60 pc=0x99ad1c
github.com/gopcua/opcua.(*Client).monitor(0xc0000f81c0, {0xf82758, 0xc0006281c0?})
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client.go:245 +0x22d fp=0xc000953fb8 sp=0xc000953ca0 pc=0xcd70cd
github.com/gopcua/opcua.(*Client).Connect.func1.1()
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client.go:215 +0x2e fp=0xc000953fe0 sp=0xc000953fb8 pc=0xcd6e6e
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc000953fe8 sp=0xc000953fe0 pc=0x9b7b41
created by github.com/gopcua/opcua.(*Client).Connect.func1
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client.go:215 +0x9b

goroutine 71 [select, 6 minutes]:
runtime.gopark(0xc0008a7f40?, 0x3?, 0x0?, 0x0?, 0xc0008a7eb6?)
C:/Program Files/Go/src/runtime/proc.go:363 +0xd6 fp=0xc0008a7d30 sp=0xc0008a7d10 pc=0x98c976
runtime.selectgo(0xc0008a7f40, 0xc0008a7eb0, 0x0?, 0x0, 0x0?, 0x1)
C:/Program Files/Go/src/runtime/select.go:328 +0x7dc fp=0xc0008a7e70 sp=0xc0008a7d30 pc=0x99ad1c
github.com/gopcua/opcua.(*Client).monitorSubscriptions(0xc0000f81c0, {0xf82758, 0xc0006281c0})
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client_sub.go:362 +0x405 fp=0xc0008a7fb8 sp=0xc0008a7e70 pc=0xcdd885
github.com/gopcua/opcua.(*Client).Connect.func1.2()
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client.go:216 +0x2e fp=0xc0008a7fe0 sp=0xc0008a7fb8 pc=0xcd6e0e
runtime.goexit()
C:/Program Files/Go/src/runtime/asm_amd64.s:1594 +0x1 fp=0xc0008a7fe8 sp=0xc0008a7fe0 pc=0x9b7b41
created by github.com/gopcua/opcua.(*Client).Connect.func1
C:/Users/HN-LPC-229/go/pkg/mod/github.com/gopcua/[email protected]/client.go:216 +0x105

进程 已完成,退出代码为 2

macos cannot use this package

this is error info msg:
../../vendor/github.com/taosdata/driver-go/v2/wrapper/row.go:47:8: could not determine kind of name for C.TSDB_DATA_TYPE_JSON

insert test data return [0x15] err

var taosuri = "root:taosdata/tcp(10.233.65.65:6030)/"
s, err := sql.Open("taosSql", taosuri)

if err != nil {
fmt.Errorf("failed to connect TDengine, err:%v", err)
return nil, nil, err
}
fmt.Println(s.Ping())
fmt.Println(s.Exec(`insert into test.tb1 values(now+1s, 2)`))
数据库名:  test
创建时间:  2022-03-01 00:56:00.249
可更新:  否
cache(MB):  16
cachelast:  0
comp:  2
days:  10
fsync:  3000
keep0,keep1,keep(D):  undefined
maxrows:  4096
minrows:  100
ntables:  1
quorum:  1
replica:  1
status:  ready
vgroups:  1
wallevel:  1
precision:  ms

taos_connect() fail!

数据库版本是 1.6.6.0,golang驱动也是最新的。
golang代码:

var DB *sql.DB
var err error
DB, err = sql.Open("taosSql", "root:taosdata@/tcp(127.0.0.1:0)/mirror")
if err != nil {
    log.Fatalf("Open database error: %s\n", err)
}

服务启动后监听的端口情况:

[root@localhost taosdata]# lsof -i | grep 12532
taosd    12532   root   10u  IPv4  71329      0t0  UDP *:6030 
taosd    12532   root   11u  IPv4  72272      0t0  TCP *:6030 (LISTEN)
taosd    12532   root   13u  IPv4  71330      0t0  UDP localhost.localdomain:48878 
taosd    12532   root   14u  IPv4  71331      0t0  UDP localhost.localdomain:33532 
taosd    12532   root   15u  IPv4  71332      0t0  UDP localhost.localdomain:45830 
taosd    12532   root   16u  IPv4  71333      0t0  UDP *:6035 
taosd    12532   root   17u  IPv4  72274      0t0  TCP *:6035 (LISTEN)
taosd    12532   root   21u  IPv4  72732      0t0  TCP *:6020 (LISTEN)
taosd    12532   root   22u  IPv4  72733      0t0  TCP localhost.localdomain:6020->gateway:56364 (ESTABLISHED)

错误日志:

07/02 14:21:14.352996 12532 7f6f6929b700 MND pConn:0x7f6f71bc2490 is rebuild, destIp:0x6438a8c0:192.168.56.100 publicIp:0x6438a8c0:192.168.56.100 usePublicIp:1
07/02 14:21:14.353310 12532 7f6f6929b700 MND user:root login from 0.0.0.0, code:31

当 rows.Next(values),没有查询到数据时,程序会阻塞

conn, err := af.Open(config.Host, config.User, config.Pwd, config.DbName, config.Port)
if err != nil {
logx.Error(err)
return nil, err
}
defer conn.Close()

rows, err := conn.Query(queryStr)
if err != nil {
	logx.Error(err)
	return nil, err
}
defer rows.Close()

columns := rows.Columns()
logx.Info("columns:", columns)
values := make([]driver.Value, len(columns))
// fmt.Println("rows:",rows.Next(values))
// **没有查询到数据时,程序阻塞了**
if err := rows.Next(values); err != nil {		
	logx.Info("err:", err)		
	return nil, err
}

row := make(map[string]interface{})
for k, v := range columns {
	row[v] = values[k]
}
logx.Info("rowData:", row)
return row, nil

part error|maxSQLLength

go版本:1.18
td版本:2.6.0.12
driver-go版本:github.com/taosdata/driver-go/v2 v2.0.5

尝试在通过客户端配置maxSQLLength连接参数,配置格式如下:
var taosUri = fmt.Sprintf("%s:%s@tcp(%s)/log?maxSQLLength=%d", td2.User, td2.Password, td2.Url, td2.MaxSQLLength)

客户端连接程序启动之后报错:
2022-11-14T18:12:35.912+0800 ERROR tdengine2/tdengine2.go:114 part error|maxSQLLength {"storage": "tdengine2"}

报错所在行程序如图,供参考:
image

build driver-go on windows error

1. enviroments:

C:\TDengine\connector\go\taosSql> go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\msn\AppData\Local\go-build
set GOENV=C:\Users\msn\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\msn\go\pkg\mod
set GONOPROXY=github.com/go-playground/*
set GONOSUMDB=github.com/go-playground/*
set GOOS=windows
set GOPATH=C:\Users\msn\go
set GOPRIVATE=github.com/go-playground/*
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.16.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\TDengine\connector\go\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\msn\AppData\Local\Temp\go-build38272060=/tmp/go-build -gno-record-gcc-switches

2. build details:

C:\TDengine\connector\go\taosSql> go build -x
WORK=C:\Users\msn\AppData\Local\Temp\go-build3526579924
mkdir -p $WORK\b001
cd C:\TDengine\connector\go\taosSql
TERM='dumb' CGO_LDFLAGS='"-g" "-O2" "-LC:/TDengine/driver" "-ltaos"' "c:\go\pkg\tool\windows_amd64\cgo.exe" -objdir "$WORK\b001\" -importpath github.com/taosdata/driver-go/taosSql -- -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" "C:\TDengine\connector\go\taosSql\connection.go" "C:\TDengine\connector\go\taosSql\ctaos.go" "C:\TDengine\connector\go\taosSql\result.go" "C:\TDengine\connector\go\taosSql\rows.go" "C:\TDengine\connector\go\taosSql\taosSqlCgo.go" "C:\TDengine\connector\go\taosSql\types.go" "C:\TDengine\connector\go\taosSql\utils.go"
cd $WORK
gcc -fno-caret-diagnostics -c -x c - -o "$WORK\3977173656" || true
gcc -Qunused-arguments -c -x c - -o "$WORK\737271862" || true
gcc -fdebug-prefix-map=a=b -c -x c - -o "$WORK\3186236235" || true
gcc -gno-record-gcc-switches -c -x c - -o "$WORK\1282230556" || true
cd $WORK\b001
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x001.o" -c _cgo_export.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x002.o" -c connection.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x003.o" -c ctaos.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x004.o" -c result.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x005.o" -c rows.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x006.o" -c taosSqlCgo.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x007.o" -c types.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_x008.o" -c utils.cgo2.c
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -I "$WORK\b001\" -g -O2 -IC:/TDengine/include "-IC:\TDengine\connector\go\taosSql\usr\include" -o "$WORK\b001\_cgo_main.o" -c _cgo_main.c
cd C:\TDengine\connector\go\taosSql
TERM='dumb' gcc -I "C:\TDengine\connector\go\taosSql" -m64 -mthreads -fmessage-length=0 "-fdebug-prefix-map=$WORK\b001=/tmp/go-build" -gno-record-gcc-switches -o "$WORK\b001\cgo.o" "$WORK\b001\_cgo_main.o" "$WORK\b001\_x001.o" "$WORK\b001\_x002.o" "$WORK\b001\_x003.o" "$WORK\b001\_x004.o" "$WORK\b001\_x005.o" "$WORK\b001\_x006.o" "$WORK\b001\_x007.o" "$WORK\b001\_x008.o" -g -O2 -LC:/TDengine/driver -ltaos
# github.com/taosdata/driver-go/taosSql
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001_x003.o: in function _cgo_63e5e3757176_Cfunc_taosGetErrno': /tmp/go-build/cgo-gcc-prolog:63: undefined reference to taosGetErrno'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001_x003.o: in function _cgo_63e5e3757176_Cfunc_taos_is_null': /tmp/go-build/cgo-gcc-prolog:278: undefined reference to taos_is_null'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001_x003.o: in function _cgo_63e5e3757176_Cfunc_taos_stmt_is_insert': /tmp/go-build/cgo-gcc-prolog:470: undefined reference to taos_stmt_is_insert'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b001_x003.o: in function _cgo_63e5e3757176_Cfunc_tstrerror': /tmp/go-build/cgo-gcc-prolog:581: undefined reference to tstrerror'
collect2.exe: error: ld returned 1 exit status

[email protected]\wrapper\block.go:19:17: could not determine kind of name for C.taos_fetch_raw_block

func TaosFetchRawBlock(result unsafe.Pointer) (int, int, unsafe.Pointer) {
var cSize int
size := unsafe.Pointer(&cSize)
var block unsafe.Pointer
errCode := int(C.taos_fetch_raw_block(result, (*C.int)(size), &block))
return cSize, errCode, block
}

func TaosWriteRawBlock(conn unsafe.Pointer, numOfRows int, pData unsafe.Pointer, tableName string) int {
cStr := C.CString(tableName)
defer C.free(unsafe.Pointer(cStr))
return int(C.taos_write_raw_block(conn, (C.int)(numOfRows), (*C.char)(pData), cStr))
}

i don't known what happend and how to deal with it.

编译报错

环境:
go version go1.16.7 windows/amd64

gcc version 5.3.0

TDengine-client-2.0.20.13-Windows-x64.exe

使用:
import (
"database/sql"
"fmt"
_ "github.com/taosdata/driver-go/taosSql"

编译报错:

github.com/taosdata/driver-go/taosSql

C:\Users\XXX\AppData\Local\Temp\go-build2056628199\b167_x003.o: In function _cgo_3c14f7af3093_Cfunc_taosGetErrno': /tmp/go-build/cgo-gcc-prolog:63: undefined reference to taosGetErrno'
C:\Users\XXX\AppData\Local\Temp\go-build2056628199\b167_x003.o: In function _cgo_3c14f7af3093_Cfunc_taos_is_null': /tmp/go-build/cgo-gcc-prolog:278: undefined reference to taos_is_null'
C:\Users\XXX\AppData\Local\Temp\go-build2056628199\b167_x003.o: In function _cgo_3c14f7af3093_Cfunc_taos_stmt_is_insert': /tmp/go-build/cgo-gcc-prolog:470: undefined reference to taos_stmt_is_insert'
C:\Users\XXX\AppData\Local\Temp\go-build2056628199\b167_x003.o: In function _cgo_3c14f7af3093_Cfunc_tstrerror': /tmp/go-build/cgo-gcc-prolog:581: undefined reference to tstrerror'
collect2.exe: error: ld returned 1 exit status

Compilation finished with exit code 2

could not determine kind of name for C.taos_write_raw_block_with_fields

go版本:1.19
tdengin版本:3.0.1.8
driver-go版本: v3.0.4

启动时报错:

github.com/taosdata/driver-go/v3/wrapper

D:\GOPATH\pkg\mod\github.com\taosdata\driver-go\[email protected]\wrapper\block.go:34:13: could not determine kind of name for C.taos_write_raw_block_with_fields

go原生连接:
var taosUri = "root:taosdata@tcp(localhost:6030)/"
taos, err := sql.Open("taosSql", taosUri)
if err != nil {
fmt.Println("failed to connect TDengine, err:", err)
return
}

restful conn Ping should verify a connection

currently restful conn do nothing in Ping function. Both Open and Ping function will not verify the connection. It breaks the conventional process described in database/sql standard library。
I suggest to verify the connection in Ping function to stay the same with standard library.
Below is the comment from database/sql Ping function.
// Ping verifies a connection to the database is still alive,
// establishing a connection if necessary.
//
// Ping uses context.Background internally; to specify the context, use
// PingContext.

driver-go don't work well

安装后运行测试程序报错,错误信息如下
~/go/src/github.com/taosdata/driver-go/wrapper/stmt.go:58:13: could not determine kind of name for C.taos_stmt_set_tbname
~/go/src/github.com/taosdata/driver-go/wrapper/stmt.go:39:14: could not determine kind of name for C.taos_stmt_set_tbname_tags

libtaos.so已存在,版本为2.2.0.0,具体位置和链接信息下

root@localhost:/usr/lib# ll |grep libtaos.so
lrwxrwxrwx  1 root root      27 Sep  9 18:51 libtaos.so -> /usr/local/lib/libtaos.so.1*
root@localhost:/usr/lib# cd /usr/local/lib
root@localhost:/usr/local/lib# ll|grep libtaos.so
lrwxrwxrwx  1 root root        12 Jul 27 10:41 libtaos.so -> libtaos.so.1*
lrwxrwxrwx  1 root root        33 Sep  9 14:57 libtaos.so.1 -> /usr/local/lib/libtaos.so.2.2.0.0*
-rwxr-xr-x  1 root root   8340544 Jul 27 10:41 libtaos.so.2.0.20.10*
-rwxr-xr-x  1 root root  10280216 Sep  9 14:57 libtaos.so.2.2.0.0*
root@localhost:/usr/local/lib#

AGPL协议?

  1. 我看到咱们产品都是使用AGPL这种协议的,感觉这种协议限制性太大了吧
  2. 使用了就要开源,那公司就没办法使用了啊

在windows下编译linux可执行程序报错

用 mingw64 或 cmd设置set GOOS=linux,编译可执行程序报错:
imports github.com/taosdata/driver-go/v2/taosSql
imports github.com/taosdata/driver-go/v2/wrapper: build constraints exclude all Go files in
work\go\pkg\mod\github.com\taosdata\driver-go\[email protected]\wrapper

taosdata / driver-go 版本升级后报错(2.0.0 -> 2.0.4)

  1. Go 版本: go version go1.18.4 windows/amd64
  2. 操作系统: Win11
  3. 报错内容
    # github.com/taosdata/driver-go/v2/wrapper D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b251\_x009.o: in function _cgo_e608cae81cef_Cfunc_taos_is_update_query':
    /tmp/go-build/cgo-gcc-prolog:279: undefined reference to taos_is_update_query' D:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b251\_x009.o: in function _cgo_e608cae81cef_Cfunc_taos_reset_current_db':
    /tmp/go-build/cgo-gcc-prolog:387: undefined reference to taos_reset_current_db' collect2.exe: error: ld returned 1 exit status error Command failed with exit code 2.
    image

go程循环执行查询时,一会就会报错 Unable to establish connection,time.Sleep(time.Millisecond * 300)这样控制速率才不会报错

func queryPage() {
// go程标识
tag := fmt.Sprintf("分页查询:%v-%v", time.Now().Nanosecond(), numb)
wokerHum := worker{Tag: tag}
goMap[tag] = wokerHum
for i := 0; i < numb; i++ {

	go func() {
		db, _ := sql.Open("taosSql", "root:taosdata@tcp(127.0.0.1:6030)/newdb?charset=utf8&parseTime=true")
		defer db.Close()
		rnd := rand.New(rand.NewSource(time.Now().UnixNano()))
		for {

			paramStr := fmt.Sprintf("select * from humiture order by datetime desc limit 10 offset %v;", rnd.Int31n(1000000))

			now1 := time.Now()
			_, err := db.Query(paramStr)
			if err != nil {
				log.Println(err)

				time.Sleep(time.Millisecond * time.Duration(rnd.Int31n(1000)))

			}
			now2 := time.Now().Sub(now1)
			//fmt.Println(res)
			wokerHum.Delay = now2.Milliseconds()

			manageChan <- wokerHum
			//time.Sleep(time.Millisecond * 300)
			//time.Sleep(time.Millisecond * time.Duration(rnd.Int31n(1000)))

		}

	}()
}

}

a long insert taos_connect failed.

image
image
image
Background: Golang/taoSql/taos_connect fail()/long insert taos_connect
Hello, td expert. this database was adopted to collect monitor status in our project, it inserted success but also happen many taos_connect fail()! error and
How can I solve this problem?

发现这里应该是有问题的,这里判断sql语句有?就标识为参数,但是有一种情况,假如插入的值本身就有?的情况下,就会出现问题

stmt.paramCount = strings.Count(query, "?")

例如:
create table if not exists MD5_fa0f7ac06608830346a51c03de15eaf2 using http_client_requests_seconds_sum tags("339ac2bfa5fd9d673a96f112ea0e738d","false","xxx","xx.com","xxxx","dev","127.0.0.1","xx-service","GET","APP","xxx","200","xxx","xxx","/uu/get?corpid={1}&corpsecret={2}")

这种情况是不是就会出现问题了

插入和查询数据,内存会持续增长

下列程序运行时,内存会持续增长,上限是多少没有测试到,目前测试的结果,几百兆是已经测试到的。

import (
"fmt"
log "github.com/sirupsen/logrus"
"math/rand"
"strconv"
"strings"
"time"
"database/sql"
_ "github.com/taosdata/driver-go/taosSql"
)

var SQLDB *sql.DB

func Insert(insertStr string, args ...interface{}) (int64, error) {
result, err := SQLDB.Exec(insertStr, args...)
if err != nil {
return 0, err
}
affect, err := result.RowsAffected()
return affect, err
}

func Get(queryStr string, args ...interface{}) (map[string]interface{}, error) {
rows, err := SQLDB.Query(queryStr, args...)
if err != nil {
if err == sql.ErrNoRows {
return map[string]interface{}{}, nil
}
return map[string]interface{}{}, err
}
defer rows.Close()

//将查询结果集Scan到map
result := make([]map[string]interface{}, 0, 10)
columns, _ := rows.Columns()
for rows.Next() {
	value := make([]interface{}, len(columns))
	columnPointers := make([]interface{}, len(columns))
	for i := 0; i < len(columns); i++ {
		columnPointers[i] = &value[i]
	}

	rows.Scan(columnPointers...)
	data := make(map[string]interface{})
	for i := 0; i < len(columns); i++ {
		columnName := columns[i]
		columnValue := columnPointers[i].(*interface{})
		data[columnName] = *columnValue
	}
	result = append(result, data)
}
if len(result) > 0 {
	return result[0], nil
}
return nil, nil

}

func Run() {
user := "root"
password := "taosdata"
address := "127.0.0.1"
port := 6030
schema := "xxx"
dataSourceName := fmt.Sprintf("%s:%s@/tcp(%s:%v)/%s", user, password, address, port, schema)
SQLDB, _ = sql.Open("taosSql", dataSourceName)

for {
	sqlStr := strings.Builder{}
	sqlStr.WriteString("insert into ")
	rd := make([]string, 0, 40)
	for i:=0;i<20;i++ {
		rand.Seed(time.Now().UnixNano())
		dn := strconv.FormatInt(rand.Int63(), 10)
		rid := strconv.FormatInt(rand.Int63n(1000000), 10)
		rd = append(rd, dn, rid)
		sqlStr.WriteString("xxx.t")
		sqlStr.WriteString(dn)
		sqlStr.WriteString(" using xxx.xp tags (")
		sqlStr.WriteString(dn)
		sqlStr.WriteString(",'test') ")
		sqlStr.WriteString("values (now,0,")
		sqlStr.WriteString(rid)
		sqlStr.WriteString(") ")
	}

	_, err := Insert(sqlStr.String())
	if err != nil {
		log.Errorf("error:%s\nsql:%s\n", err.Error(), sqlStr.String())
	}
	for i:=0;i<20;i+=2 {
		sql1 := `select max(time) time from xxx.xp where did = ? and run_id = ?`
		_, _ = Get(sql1, rd[i], rd[i+1])
		sql2 := `select min(time) time from xxx.xp where did = ? and run_id = ?`
		_, _ = Get(sql2, rd[i], rd[i+1])
		sql3 := `select max(run_id) run_id from xxx.xp where did = ?`
		_, _ = Get(sql3, rd[i])
	}
}

}

使用ps找到进程ID后,通过/proc/进程ID/status看到内存使用情况

20分钟:
VmHWM: 176440 kB
VmRSS: 176440 kB

使用go pprof 查看程序运行情况,看到allocs 和 heap 在不断的增长

在go程序中实时获取内存使用情况,能看到自动GC垃圾回收,使用内存量不会持续增长。
var m runtime.MemStats
runtime.ReadMemStats(&m)

怀疑是调用C的类库,有内存申请但是没有释放。这部分内存go无法自动回收。

请帮忙看一下什么问题

HTP ERROR context:0x7fd8500dc8c0, is already released, refCount:-1

When I made a high number of concurrent requests to the Resful API, the number of concurrent requests was 100, there was a large number of such errors,Only 16 requests were successful.

09/06 17:50:41.913078 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913091 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913101 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913111 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913121 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913130 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913139 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913149 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913158 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913168 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913190 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913202 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913212 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913222 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913231 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913241 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913250 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913260 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913269 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913278 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913288 00001576 HTP ERROR context:0x7fd8500e1b40, is already released, refCount:-1
09/06 17:50:41.913571 00001575 HTP ERROR context:0x7fd8500e1460, is already released, refCount:-1

go get error

➜ tdengine-test git:(master) ✗ go get github.com/taosdata/TDengine/src/connector/go/src/taosSql
go: found github.com/taosdata/TDengine/src/connector/go/src/taosSql in github.com/taosdata/TDengine v0.0.0-20200303093529-58efbd6b99fe

github.com/taosdata/TDengine/src/connector/go/src/taosSql

../../../pkg/mod/github.com/taosdata/!t![email protected]/src/connector/go/src/taosSql/result.go:23:10: fatal error: 'taos.h' file not found
#include <taos.h>
^~~~~~~~
1 error generated.

application exit due to cannot open log file

when I create an application with the golang driver, it exits with below error:

open /var/log/taos/taosgo.log: permission denied

though sudo could be a workaround, it is not a correct behavior for a library package.

suggest disabling log by default, and let application explicitly initialize the logger if it is required.

出现报错: Scan error on column index 20, name "dev_mod": converting driver.Value type string ("YXA1-5F-CE16808-HX1-3") to a float64: invalid syntax

现象

报错: Scan error on column index 20, name "dev_mod": converting driver.Value type string ("YXA1-5F-CE16808-HX1-3") to a float64: invalid syntax
字段每次都随机,都是第20行无法解析,报错 float64。对应的地方就是 strings,key value都对的上,查询就是报错 float64 类型错误,显示出来的也是字符串,字段里面也没有空值。 删除数据库再弄也没用。
image
image
删除数据库重来
image
image
解析结构体 都是string
image
报错内容:
Scan error on column index 20, name "dev_mod": converting driver.Value type string ("YXA1-5F-CE16808-HX1-3") to a float64: invalid syntax

调试

自己简单调试了下 感觉是源码立马 for rows.next() 是依次解析的 把上一个字段的属性去解析下一个字段 没有置空 我就更改了下结构体的属性 每次会报错一个新字段错误。

代码:

package cronalarm

import "time"

/**

// 这个是要解析的结构体
type TaskCallResult struct {
Ts time.Time json:"ts" gorm:"ts"
Times float64 json:"time"
Updatetime string json:"update_time"
IndexName string json:"index_name"
TaskResult interface{} json:"task_result" //
Status string json:"status" //
PacketsSent float64 json:"packets_sent" //
DevMod string json:"dev_mod" //
DevAddr string json:"dev_addr" //
DevName string json:"dev_name" //
DevStat string json:"dev_stat" //
DevOID string json:"dev_oid" //
DevVendor string json:"dev_vendor" //
Value int json:"value" //
PicType string json:"pic_type" //
PacketLoss float64 json:"packet_loss" //
PacketsRecv float64 json:"packets_recv" //
TaskId string json:"task_id" //
TaskType string json:"task_type" //
MItemId string json:"m_item_id" //
MItemVUnits string json:"m_item_v_units"
MItemName string json:"m_item_name" //
MItemConfName string json:"m_item_conf_name" //
MItemConfId string json:"m_item_conf_id" //
MItemValueRespUnits string json:"m_item_value_resp_units" //
MItemValueUnits string json:"m_item_value_units" //
MVUnits string json:"m_v_units" //
MItemVRespUnits string json:"m_item_v_resp_units"
ErrMsg string json:"errmsg" //
IpAddr string json:"ip_addr" //
RuleInterval string json:"rule_interval"
RuleName string json:"rule_name"
RuleUid string json:"rule_uid"
StandardData string json:"standard_data"
Grade string json:"grade"
TriggerLevel string json:"trigger_level" //
}

// 这是数据库里面的数据
/*
SELECT * FROM snmp华为云_CE16808_.1.3.6.1.2.1.2.2.1.10.10_IN WHERE ts > NOW - 1000s ORDER BY ts LIMIT 14716;
ts | m_item_v_resp_units | packets_recv | dev_vendor | m_item_id | dev_name | | dev_oid | packets_sent | packet_loss | m_item_name | m_item_ | dev_addr | m_item_v_units | index_name | ip_addr | m_v_units | dev_mod | dev_stat nf_name | task_id | task_type | update_time |

2022-07-03 21:15:28.314 | Counter32 | 2683817043.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854128314
2022-07-03 21:22:13.356 | Counter32 | 2684182944.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854533356
2022-07-03 21:21:48.265 | Counter32 | 2684159690.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854508265 |
2022-07-03 21:21:53.340 | Counter32 | 2684170770.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854513340 |
2022-07-03 21:21:58.253 | Counter32 | 2684171036.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854518253 |
2022-07-03 21:22:03.221 | Counter32 | 2684174360.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854523221 |
2022-07-03 21:22:08.348 | nil | 0.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 1.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | loss | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854528348
2022-07-03 21:20:58.330 | nil | 0.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 1.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | loss | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854458330 |
2022-07-03 21:21:03.335 | Counter32 | 2684124472.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854463335 |
2022-07-03 21:21:08.206 | Counter32 | 2684129318.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854468206 |
2022-07-03 21:21:13.290 | Counter32 | 2684129494.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854473290 |
2022-07-03 21:21:18.346 | Counter32 | 2684134192.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854478346 |
2022-07-03 21:21:23.238 | Counter32 | 2684134192.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854483238 |
2022-07-03 21:21:28.356 | nil | 0.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 1.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | loss | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854488356 |
2022-07-03 21:21:33.396 | Counter32 | 2684149970.000000000 | Huawei | 0x640fe6 | Huawei/Switch/YXA1-5F-CE168... |00000000 | .1.3.6.1.2.1.2.2.1.10.10 | 1.000000000 | 0.000000000 | 华为云 CE16808 .1.3.6.1.2.1... | 0x6416a | 湖南/长沙总部机房/机柜1 | Counter32 | successful | 172.22.0.102 | mb | YXA1-5F-CE16808-HX1-3 | product & 在线 1.3.6.1.2.1... | /corn/task/snmp/0x6416a8 | SNMP | 1656854493396
*/

// 这是数据结构表
/*
taos> desc snmp华为云_CE16808_.1.3.6.1.2.1.2.2.1.10.10_IN ;
Field | Type | Length | Note |

ts | TIMESTAMP | 8 | |
m_item_v_resp_units | BINARY | 9 | |
packets_recv | DOUBLE | 8 | |
dev_vendor | BINARY | 6 | |
m_item_id | BINARY | 8 | |
dev_name | BINARY | 35 | |
status | BINARY | 72 | |
value | DOUBLE | 8 | |
dev_oid | BINARY | 24 | |
packets_sent | DOUBLE | 8 | |
packet_loss | DOUBLE | 8 | |
m_item_name | BINARY | 45 | |
m_item_conf_id | BINARY | 8 | |
errmsg | BINARY | 74 | |
pic_type | BINARY | 4 | |
dev_addr | BINARY | 33 | |
m_item_v_units | BINARY | 9 | |
index_name | BINARY | 10 | |
ip_addr | BINARY | 12 | |
m_v_units | BINARY | 2 | |
dev_mod | BINARY | 21 | |
dev_stat | BINARY | 16 | |
task_result | BINARY | 117 | |
m_item_conf_name | BINARY | 45 | |
task_id | NCHAR | 24 | TAG |
task_type | NCHAR | 4 | TAG |
update_time | NCHAR | 13 | TAG |
Query OK, 27 row(s) in set (0.000293s)

*/

/*
我写入的时候的代码
tags := map[string]string{
"task_id": result.TaskId,
"task_type": result.TaskType,
"update_time": format.Str(time.Now().UnixNano() / 1e6),
}
fields := map[string]interface{}{
"status": fmt.Sprintf("%s", format.StructToMapString(result.Status)),
"task_result": fmt.Sprintf("%s", format.StructToMapString(result.TaskResult)),
"pic_type": fmt.Sprintf("%s", result.PicType),
"index_name": fmt.Sprintf("%s", result.IndexName),
"value": result.Value,
"errmsg": fmt.Sprintf("%s", errmsg),
"packets_sent": result.PacketsSent,
"packets_recv": result.PacketsRecv,
"packet_loss": result.PacketLoss,
"m_item_id": fmt.Sprintf("%s", result.MItemId),
"m_item_name": fmt.Sprintf("%s", result.MitemName),
"m_item_conf_name": fmt.Sprintf("%s", result.MitemConfName),
"m_item_conf_id": fmt.Sprintf("%s", result.MitemConfId),
"m_item_v_units": fmt.Sprintf("%s", result.MitemValueUnits),
"m_item_v_resp_units": fmt.Sprintf("%s", result.MitemValueRespUnits),
"m_v_units": fmt.Sprintf("%s", result.MVUnits),
"ip_addr": fmt.Sprintf("%s", result.IpAddr),
"dev_mod": fmt.Sprintf("%s", result.DevMod),
"dev_stat": fmt.Sprintf("%s", result.DevStat),
"dev_name": fmt.Sprintf("%s", result.DevName),
"dev_addr": fmt.Sprintf("%s", result.DevAddr),
"dev_vendor": fmt.Sprintf("%s", result.DevVendor),
"dev_oid": fmt.Sprintf("%s", result.DevOID),
}

*/

// 读取时候的代码 就是读取报错
/*
query = fmt.Sprintf("SELECT * FROM %s WHERE ts > NOW - %s;", tablename, logendtime)
fmt.Println(query, "query sql")
res, err = db.RB.Query(query)
if err != nil {
log.Logger.Error(err)
return err
}
if c, _ := res.Columns(); len(c) == 0 {
return nil
}
for res.Next() {
taskresult = TaskCallResult{}
err = res.Scan(
&taskresult.Ts,
&taskresult.Status,
&taskresult.PacketsRecv,
&taskresult.MItemValueRespUnits,
&taskresult.DevName,
&taskresult.DevStat,
&taskresult.DevAddr,
&taskresult.DevMod,
&taskresult.DevOID,
&taskresult.MVUnits,
&taskresult.ErrMsg,
&taskresult.MItemConfName,
&taskresult.DevVendor,
&taskresult.PicType,
&taskresult.IpAddr,
&taskresult.MItemConfId,
&taskresult.IndexName,
&taskresult.TaskResult,
&taskresult.MItemName,
&taskresult.MItemVUnits,
&taskresult.PacketsSent,
&taskresult.MItemId,
&taskresult.Value,
&taskresult.PacketLoss,
&taskresult.TaskId,
&taskresult.TaskType,
&taskresult.Updatetime,
)
if err != nil {
log.Logger.Error("query tdengine alarm log parse err ,reason is ", err)
return err
}
*/

运行查询报错内容
/*
SELECT * FROM snmp华为云_CE16808_.1.3.6.1.2.1.2.2.1.10.10_IN WHERE ts > NOW - 1000s; query sql
2022-07-04 09:59:11 ERROR cronalarm/alarm_checklog.go:132 query tdengine alarm log parse err ,reason is sql: Scan error on column index 20, name "dev_mod": converting driver.Value type string ("YXA1-5F-CE16808-HX1-3") to a float64: invalid syntax

*/

怀疑是逐行解析的时候变量未置空,轮到下一个还是用上一个变量特性来解析

driver should be goroutine safe.

DB is a database handle representing a pool of zero or more underlying connections.

It's safe for concurrent use by multiple goroutines.

根据官方文档Open之后的*DB应该是可以在任意多协程使用的。这与本项目中

如果客户想要用多个goroutine并发访问TDengine, 那么需要在各个goroutine中分别创建一个sql.Open对象并用之访问TDengine

是矛盾的。

表中插入字符串时报语法错误

往数据库中插入字符串的时候,如果不在字符串上手动使用''包裹,会报语法错误。

测试步骤如下 :
如果有一张有表
create TABLE if not exists test(ts timestamp,
testValue VARCHAR(120)
);

Exec("insert into test(ts,testValue) values(?,?)", "2022-08-17 09:23:09.978", "xyzaaaaaaaaaa")
驱动common.InterpolateParams(query, args) 解析后的sql语句为
insert into test(ts,testValue) values(2022-08-17 09:23:09.978,xyzaaaaaaaaaa)
执行报警,原因是字符串没有加引号
[0x216] syntax error near '2022-08-17 09:23:09.978,xyzaaaaaaaaaa)' (invalid timestamp), insert into test(ts,testValue) values('2022-08-17 09:23:09.978','xyzaaaaaaaaaa')

Exec("insert into test(ts,testValue) values(?,?)", "'2022-08-17 09:23:09.978'", "xyzaaaaaaaaaa")
驱动common.InterpolateParams(query, args) 解析后的sql语句为
insert into test(ts,testValue) values('2022-08-17 09:23:09.978',xyzaaaaaaaaaa)
[0x216] syntax error near 'xyzaaaaaaaaaa)' (invalid data or symbol), insert into test(ts,testValue) values(''2022-08-17 09:23:09.978'','xyzaaaaaaaaaa')

Exec("insert into test(ts,testValue) values(?,?)", "'2022-08-17 09:23:09.978'", "'xyzaaaaaaaaaa'")
驱动common.InterpolateParams(query, args) 解析后的sql语句为
insert into test(ts,testValue) values('2022-08-17 09:23:09.978','xyzaaaaaaaaaa')

会报sql语法错误,原因是“test” 在sql 拼接的时候,会拼成 insert into test(ts,value) values(2022-08-17 09:03:09.978, test);插入时报Error: [0x216] syntax error near '2022-08-17 09:23:09.978,'8-1000-16604792291907' (invalid timestamp)

Exec("insert into test(ts,testValue) values(?,?)", time.Now(), "'xyzaaaaaaaaaa'")
这种写法也没有问题

如果插入的字符串都要额外加 '' , 显示不合适,看了mysql 的代码,他们是在字符串那自动补充了'', 建议修改成判断字符串,自动加一个''

tdegine 的处理
func InterpolateParams(query string, args []driver.Value) (string, error) {
....
case time.Time:
t := v.Format(time.RFC3339Nano)
buf.WriteByte(''')
buf.WriteString(t)
buf.WriteByte(''')
case []byte:
buf.Write(v)
case string:
buf.WriteString(v)
default:
return "", driver.ErrSkip
}
if buf.Len() > MaxTaosSqlLen {
return "", errors.New("sql statement exceeds the maximum length")
}

mysql 的处理
func (mc *mysqlConn) interpolateParams(query string, args []driver.Value) (string, error) {
...
case string:
buf = append(buf, ''')
if mc.status&statusNoBackslashEscapes == 0 {
buf = escapeStringBackslash(buf, v)
} else {
buf = escapeStringQuotes(buf, v)
}
buf = append(buf, ''')
default:
return "", driver.ErrSkip
}

问题:go程序超表查询不到数据问题,通过taos命令行工具可以查询到,程序debug时偶尔可以查询到。

问题:go程序超表查询不到数据问题,通过taos命令行工具可以查询到,程序debug时偶尔可以查询到。
场景:超表包含多个子表,每个子表有3列数据,每列均有数据。
通过go程序执行超表查询平均值sql如下,程序执行后debug分步运行程序偶尔可以查询到数据,直接运行程序查询不到数据,通过taos命令行直接执行以下SQL可以查询到数据。
select avg(ed1) as avged1 from db_e.group1 where aaa2 = 'bbb2' and ts >= '1646359200000' and ts < '1646366400000' interval(1h)
td版本:2.2.2.10
go语言客户端:2.0.1
操作系统:Ubuntu / ARM
td参数:除了存储时间,其他未更改。

taosRestful 并发出错

"error": "Post "http://root:***@127.0.0.1:6041/rest/sqlutc\": write tcp 127.0.0.1:50354->127.0.0.1:6041: use of closed network connection"}

taosd : 2.4.0.0

单线程执行正常, 改为 goroutine 并发执行时报上面的错.

执行方式改为: _ "github.com/taosdata/driver-go/v2/taosSql"

10个并发一切正常。

字表中的 tag 在插入第一条数据时是否已被写死?

比如:tags(location) 中,假定第一条数据插入的为 beijing,那么之后再在同一张字表中,location 插入 shanghai 是否无法插入?

以及根据 demo 中给多表中插入数据,实际只能插入一条:INSERT INTO b1 USING bots TAGS ('eth_balance') VALUES(NOW,15967002,6.3207) b1 USING bots TAGS ('eth_balance') VALUES(NOW,15967002,4.0112)
;

image

使用golang客户端报错

使用dirver-go的样例代码进行测试,无法通过编译,报错如下:

# github.com/taosdata/driver-go/v2/wrapper
D:\Develop\go\pkg\mod\github.com\taosdata\driver-go\v2@v2.0.0\wrapper\field.go:4:10: fatal error: taos.h: No such file or directory
 #include <taos.h>
          ^~~~~~~~
compilation terminated.

环境是:Windows11 go版本为:1.17.3
使用mac编译也是相同的报错

go-api 测试4秒才插入1万条数据,这个慢在什么地方呢,使用driver_test.go改的,每条0.3ms,算下来1万条接近4秒,查看了服务器资源,进程使用cpu也不高

// CreateTables createtable
func CreateTables(db *sql.DB, numOfSubTab int) {
db.Exec("drop table if exists super")
db.Exec("CREATE TABLE super (ts timestamp, value BOOL) tags (degress int)")
for i := 0; i < numOfSubTab; i++ {
db.Exec(fmt.Sprintf("create table t%d using super tags(%d)", i%10, i))
}
}

// InsertInto insert
func InsertInto(db *sql.DB, numOfSubTab, numOfItems int) {
now := time.Now()
t := now.Add(-100 * time.Hour)
for i := 0; i < numOfItems; i++ {
ts1 := time.Now()
db.Exec(fmt.Sprintf("insert into t%d values(%d, %t)", i%numOfSubTab, t.UnixNano()/int64(time.Millisecond)+int64(i), i%2 == 0))
ts2 := time.Now()
fmt.Printf("timecost=%v\n", ts2.Sub(ts1))
}
}

func main() {
db, err := sql.Open(DRIVER_NAME, dataSourceName)
if err != nil {
log.Panicf("error on: sql.open %s", err.Error())
return
}
defer db.Close()
var numOfSubTables = 10
var numOfItems = 10000
CreateTables(db, numOfSubTables)
fmt.Printf("time=%v\n", time.Now())
ts1 := time.Now()
InsertInto(db, numOfSubTables, numOfItems)
ts2 := time.Now()
fmt.Printf("totaltime=%v\n", ts2.Sub(ts1))
fmt.Println()
}

// 打印输出
timecost=349.21µs
timecost=313.596µs
timecost=369.4µs
timecost=340.919µs
totaltime=3.642698487s

我后来改成批量插入,每次insert 1000条数据,1000万需要53秒,算下来每毫秒188条。我看其他网友java测试的,但表插入,每毫秒有300多条,也是每次insert 1000条

如何显示指定时区?

var taosDSN = "root:taosdata@http(localhost:6041)/test"
"root:taosdata@http(ip:port)/db_name?tz=Asia/Shanghai"

image

使用go api(根据该driver-test改的)创建表,但是实际没有,到insert数据时也很慢

func CreateTables(db *sql.DB, numOfSubTab int) {
db.Exec("drop table if exists super")
db.Exec("CREATE TABLE super (ts timestamp, value BOOL) tags (degress int)")
for i := 0; i < numOfSubTab; i++ {
db.Exec(fmt.Sprintf("create table t%d using super tags(%d)", i%10, i))
}
}

func InsertInto(db *sql.DB, numOfSubTab, numOfItems int) {
now := time.Now()
t := now.Add(-100 * time.Hour)
for i := 0; i < numOfItems; i++ {
db.Exec(fmt.Sprintf("insert into t%d values(%d, %t)", i%numOfSubTab, t.UnixNano()/int64(time.Millisecond)+int64(i), i%2 == 0))
}
}

执行时发现没报错,但是数据库没有创建表,insert也执行很慢;
后来在客户端上的hosts文件中配置上服务器的fqdn后就正常了

后来抓包发现mnode返回的节点信息中使用的是fqdn,客户端再次访问需要解析。

我的疑问是这种情况,解析不出来这个机器,是否应该报错,实际是没报错,然后表也没创建成功

按照 DEMO 通过 restful 方式操作 DB,直接报错。

package main

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

func main() {
	var taosDSN = "root:taosdata@http(localhost:6041)/"
	taos, err := sql.Open("taosRestful", taosDSN)
	if err != nil {
		fmt.Println("failed to connect TDengine, err:", err)
		return
	}
	defer taos.Close()

	// taos.Exec("create database if not exists test")
	// taos.Exec("create table if not exists tb1 (ts timestamp, a int)")
	_, err = taos.Exec("insert into test.d0 values(NOW, 9.96000, 116, 0.32778)")
	if err != nil {
		fmt.Println("failed to insert, err:", err)
		return
	}

	rows, err := taos.Query("select * from test.d0 limit 10")
	if err != nil {
		fmt.Println("failed to select from table, err:", err)
		return
	}

	defer rows.Close()
	for rows.Next() {
		var r struct {
			Ts      time.Time
			Current float64
			Voltage int
			Phase   float64
		}
		err := rows.Scan(&r.Ts, &r.Current, &r.Voltage, &r.Phase)
		if err != nil {
			fmt.Println("scan error:\n", err)
			return
		}
		fmt.Println(r.Ts, r.Current)
	}
}

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.