Result not match in coroutines usage of TDengine go connector

37 Views Asked by At

The problem happens on Windows, with Go 1.5, driver-go at win branch, taos 2.1.0.0 .

For a simple use case:

func myexecute(db *sql.DB, sql string, id int, wg *sync.WaitGroup) {
    defer wg.Add(1)
    rows, err := db.Query(sql)
    checkErr(err, sql)
    count := 0
    for rows.Next() {
        // do scan and print
        count++
    }
}
func main() {
    // ...
    wg := &sync.WaitGroup{}
    sqls := make([]string, 2)
    sqls[0] = "select * from stb1 where t1='v1' limit 1"
    sqls[1] = "select * from stb1 where t1='v2' limit 5"

    for i := 0; i < 2; i++ {
        go myexecute(db, sqls[i], i, wg)
    }
    wg.Wait()
    //...
}

The result is randomly mismatched with sqls - that means, sql B results has the result that selected with sql A.

0

There are 0 best solutions below